Skip to content

Commit 0fc9087

Browse files
author
Vyacheslav Zakharin
committed
[libomptarget][NFC] Link plugins with threads support library due to std::call_once usage.
Differential Revision: https://reviews.llvm.org/D95572
1 parent 8d8be87 commit 0fc9087

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
lines changed

openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,28 @@ if (NOT LIBOMPTARGET_CUDA_TOOLKIT_ROOT_DIR_PRESET AND
251251
endif()
252252
endif()
253253
endif()
254+
255+
if (OPENMP_STANDALONE_BUILD)
256+
# This duplicates code from llvm/cmake/config-ix.cmake
257+
if( WIN32 AND NOT CYGWIN )
258+
# We consider Cygwin as another Unix
259+
set(PURE_WINDOWS 1)
260+
endif()
261+
262+
# library checks
263+
if( NOT PURE_WINDOWS )
264+
check_library_exists(pthread pthread_create "" HAVE_LIBPTHREAD)
265+
endif()
266+
267+
if(HAVE_LIBPTHREAD)
268+
# We want to find pthreads library and at the moment we do want to
269+
# have it reported as '-l<lib>' instead of '-pthread'.
270+
# TODO: switch to -pthread once the rest of the build system can deal with it.
271+
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
272+
set(THREADS_HAVE_PTHREAD_ARG Off)
273+
find_package(Threads REQUIRED)
274+
set(OPENMP_PTHREAD_LIB ${CMAKE_THREAD_LIBS_INIT})
275+
endif()
276+
else()
277+
set(OPENMP_PTHREAD_LIB ${LLVM_PTHREAD_LIB})
278+
endif()

openmp/libomptarget/plugins/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
4646
${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
4747
${LIBOMPTARGET_DEP_LIBELF_LIBRARIES}
4848
dl
49+
${OPENMP_PTHREAD_LIB}
4950
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports")
5051

5152
list(APPEND LIBOMPTARGET_TESTED_PLUGINS

openmp/libomptarget/plugins/cuda/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ target_link_libraries(omptarget.rtl.cuda
5252
MemoryManager
5353
${LIBOMPTARGET_DEP_LIBRARIES}
5454
${LIBOMPTARGET_DEP_LIBELF_LIBRARIES}
55+
${OPENMP_PTHREAD_LIB}
5556
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports"
5657
"-Wl,-z,defs")
5758

openmp/libomptarget/plugins/remote/server/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,5 @@ add_executable(openmp-offloading-server
2727
target_link_libraries(openmp-offloading-server
2828
grpc++
2929
protobuf
30+
${OPENMP_PTHREAD_LIB}
3031
"-ldl" "-lomp" "-fopenmp" "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../../exports" ${LIBOMPTARGET_DEP_LIBELF_LIBRARIES})

openmp/libomptarget/plugins/remote/src/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ target_link_libraries(omptarget.rtl.rpc
3535
grpc++
3636
protobuf
3737
"-ldl"
38+
${OPENMP_PTHREAD_LIB}
3839
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../../exports")
3940

4041
# Report to the parent scope that we are building a plugin for RPC.

0 commit comments

Comments
 (0)