[Openmp-commits] [PATCH] D95572: [libomptarget][NFC] Link plugins with threads support library due to std::call_once usage.
Vyacheslav Zakharin via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Wed Jan 27 15:48:17 PST 2021
vzakhari created this revision.
vzakhari added a reviewer: grokos.
Herald added a subscriber: mgorny.
vzakhari requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.
The title is self-descriptive. There are some details here: https://reviews.llvm.org/D93727#2524458
I was going to assert that the threads support library is found in `openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake`, but I guess there may be plugins that do not use `Debug.h`, so I left it undefined what happens, if the library is not found.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D95572
Files:
openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
openmp/libomptarget/plugins/CMakeLists.txt
openmp/libomptarget/plugins/cuda/CMakeLists.txt
openmp/libomptarget/plugins/remote/server/CMakeLists.txt
openmp/libomptarget/plugins/remote/src/CMakeLists.txt
Index: openmp/libomptarget/plugins/remote/src/CMakeLists.txt
===================================================================
--- openmp/libomptarget/plugins/remote/src/CMakeLists.txt
+++ openmp/libomptarget/plugins/remote/src/CMakeLists.txt
@@ -35,6 +35,7 @@
grpc++
protobuf
"-ldl"
+ ${OPENMP_PTHREAD_LIB}
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../../exports")
# Report to the parent scope that we are building a plugin for RPC.
Index: openmp/libomptarget/plugins/remote/server/CMakeLists.txt
===================================================================
--- openmp/libomptarget/plugins/remote/server/CMakeLists.txt
+++ openmp/libomptarget/plugins/remote/server/CMakeLists.txt
@@ -27,4 +27,5 @@
target_link_libraries(openmp-offloading-server
grpc++
protobuf
+ ${OPENMP_PTHREAD_LIB}
"-ldl" "-lomp" "-fopenmp" "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../../exports" ${LIBOMPTARGET_DEP_LIBELF_LIBRARIES})
Index: openmp/libomptarget/plugins/cuda/CMakeLists.txt
===================================================================
--- openmp/libomptarget/plugins/cuda/CMakeLists.txt
+++ openmp/libomptarget/plugins/cuda/CMakeLists.txt
@@ -52,6 +52,7 @@
MemoryManager
${LIBOMPTARGET_DEP_LIBRARIES}
${LIBOMPTARGET_DEP_LIBELF_LIBRARIES}
+ ${OPENMP_PTHREAD_LIB}
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports"
"-Wl,-z,defs")
Index: openmp/libomptarget/plugins/CMakeLists.txt
===================================================================
--- openmp/libomptarget/plugins/CMakeLists.txt
+++ openmp/libomptarget/plugins/CMakeLists.txt
@@ -46,6 +46,7 @@
${LIBOMPTARGET_DEP_LIBFFI_LIBRARIES}
${LIBOMPTARGET_DEP_LIBELF_LIBRARIES}
dl
+ ${OPENMP_PTHREAD_LIB}
"-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports")
list(APPEND LIBOMPTARGET_TESTED_PLUGINS
Index: openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
===================================================================
--- openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
+++ openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
@@ -251,3 +251,28 @@
endif()
endif()
endif()
+
+if (OPENMP_STANDALONE_BUILD)
+ # This duplicates code from llvm/cmake/config-ix.cmake
+ if( WIN32 AND NOT CYGWIN )
+ # We consider Cygwin as another Unix
+ set(PURE_WINDOWS 1)
+ endif()
+
+ # library checks
+ if( NOT PURE_WINDOWS )
+ check_library_exists(pthread pthread_create "" HAVE_LIBPTHREAD)
+ endif()
+
+ if(HAVE_LIBPTHREAD)
+ # We want to find pthreads library and at the moment we do want to
+ # have it reported as '-l<lib>' instead of '-pthread'.
+ # TODO: switch to -pthread once the rest of the build system can deal with it.
+ set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
+ set(THREADS_HAVE_PTHREAD_ARG Off)
+ find_package(Threads REQUIRED)
+ set(OPENMP_PTHREAD_LIB ${CMAKE_THREAD_LIBS_INIT})
+ endif()
+else()
+ set(OPENMP_PTHREAD_LIB ${LLVM_PTHREAD_LIB})
+endif()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D95572.319698.patch
Type: text/x-patch
Size: 3070 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210127/70f500d0/attachment-0001.bin>
More information about the Openmp-commits
mailing list