diff --git a/var/spack/repos/builtin/packages/llvm/llvm15-thread.patch b/var/spack/repos/builtin/packages/llvm/llvm15-thread.patch new file mode 100644 index 0000000000..cffb559185 --- /dev/null +++ b/var/spack/repos/builtin/packages/llvm/llvm15-thread.patch @@ -0,0 +1,23 @@ +diff --git a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake +index 1f2a50667c4f..d3ff232f6bd3 100644 +--- a/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake ++++ b/openmp/libomptarget/cmake/Modules/LibomptargetGetDependencies.cmake +@@ -280,4 +280,5 @@ if (NOT LIBOMPTARGET_CUDA_TOOLKIT_ROOT_DIR_PRESET AND + endif() + endif() + +-set(OPENMP_PTHREAD_LIB ${LLVM_PTHREAD_LIB}) ++find_package(Threads REQUIRED) ++set(OPENMP_PTHREAD_LIB Threads::Threads) +diff --git a/openmp/libomptarget/src/CMakeLists.txt b/openmp/libomptarget/src/CMakeLists.txt +index 071ec61889a2..b782c3b07e6f 100644 +--- a/openmp/libomptarget/src/CMakeLists.txt ++++ b/openmp/libomptarget/src/CMakeLists.txt +@@ -33,6 +33,7 @@ add_llvm_library(omptarget + LINK_LIBS + PRIVATE + ${CMAKE_DL_LIBS} ++ ${OPENMP_PTHREAD_LIB} + "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports" + NO_INSTALL_RPATH + ) diff --git a/var/spack/repos/builtin/packages/llvm/package.py b/var/spack/repos/builtin/packages/llvm/package.py index cff8f2e758..e8658f61ec 100644 --- a/var/spack/repos/builtin/packages/llvm/package.py +++ b/var/spack/repos/builtin/packages/llvm/package.py @@ -360,6 +360,7 @@ class Llvm(CMakePackage, CudaPackage): # add -lpthread to build OpenMP libraries patch("llvm13-14-thread.patch", when="@13:14") + patch("llvm15-thread.patch", when="@15") # avoid build failed with Fujitsu compiler patch("llvm13-fujitsu.patch", when="@13 %fj")