[Openmp-commits] [openmp] 0fc9087 - [libomptarget][NFC] Link plugins with threads support library due to std::call_once usage.

Vyacheslav Zakharin via Openmp-commits openmp-commits at lists.llvm.org
Wed Jan 27 19:31:34 PST 2021


Author: Vyacheslav Zakharin
Date: 2021-01-27T19:26:18-08:00
New Revision: 0fc90873b2ef9049c4aa100631acad806c3cfa72

URL: https://github.com/llvm/llvm-project/commit/0fc90873b2ef9049c4aa100631acad806c3cfa72
DIFF: https://github.com/llvm/llvm-project/commit/0fc90873b2ef9049c4aa100631acad806c3cfa72.diff

LOG: [libomptarget][NFC] Link plugins with threads support library due to std::call_once usage.

Differential Revision: https://reviews.llvm.org/D95572

Added: 
    

Modified: 
    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

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
index 28165ac1b8c0..317260cd34f1 100644
--- a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
+++ b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake
@@ -251,3 +251,28 @@ if (NOT LIBOMPTARGET_CUDA_TOOLKIT_ROOT_DIR_PRESET AND
     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()

diff  --git a/openmp/libomptarget/plugins/CMakeLists.txt b/openmp/libomptarget/plugins/CMakeLists.txt
index 210ee2f52e01..9fb54765e517 100644
--- a/openmp/libomptarget/plugins/CMakeLists.txt
+++ b/openmp/libomptarget/plugins/CMakeLists.txt
@@ -46,6 +46,7 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
         ${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

diff  --git a/openmp/libomptarget/plugins/cuda/CMakeLists.txt b/openmp/libomptarget/plugins/cuda/CMakeLists.txt
index cb4d5d391f85..7f77bcc364f5 100644
--- a/openmp/libomptarget/plugins/cuda/CMakeLists.txt
+++ b/openmp/libomptarget/plugins/cuda/CMakeLists.txt
@@ -52,6 +52,7 @@ target_link_libraries(omptarget.rtl.cuda
   MemoryManager
   ${LIBOMPTARGET_DEP_LIBRARIES}
   ${LIBOMPTARGET_DEP_LIBELF_LIBRARIES}
+  ${OPENMP_PTHREAD_LIB}
   "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports"
   "-Wl,-z,defs")
 

diff  --git a/openmp/libomptarget/plugins/remote/server/CMakeLists.txt b/openmp/libomptarget/plugins/remote/server/CMakeLists.txt
index 667bb15375a0..038a7edc05c7 100644
--- a/openmp/libomptarget/plugins/remote/server/CMakeLists.txt
+++ b/openmp/libomptarget/plugins/remote/server/CMakeLists.txt
@@ -27,4 +27,5 @@ add_executable(openmp-offloading-server
 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})

diff  --git a/openmp/libomptarget/plugins/remote/src/CMakeLists.txt b/openmp/libomptarget/plugins/remote/src/CMakeLists.txt
index 17eedc190a0f..de3177ffedca 100644
--- a/openmp/libomptarget/plugins/remote/src/CMakeLists.txt
+++ b/openmp/libomptarget/plugins/remote/src/CMakeLists.txt
@@ -35,6 +35,7 @@ target_link_libraries(omptarget.rtl.rpc
   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.


        


More information about the Openmp-commits mailing list