Skip to content

Commit d824d87

Browse files
authored
[offload] - Add omp as a dependency for clang-bootstrap-deps (#90793)
If openmp is on the LLVM_ENABLE_PROJECTS list and offload is on LLVM_ENABLE_RUNTIMES list when using CLANG_ENABLE_BOOTSTRAP, then the runtimes will be configured before the openmp project. This will throw a cannot find libomp.so dependency error. Add omp as a dependency when this is the case. Update offload cmake for detection of LIBOMP_HAVE_VERSION_SCRIPT.
1 parent cb5d6a5 commit d824d87

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

llvm/runtimes/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -559,6 +559,13 @@ if(runtimes)
559559
# We need to add the runtimes as a dependency because compiler-rt can be
560560
# built as part of runtimes and we need the profile runtime for PGO
561561
add_dependencies(clang-bootstrap-deps runtimes)
562+
# The bootstrap build will attempt to configure the offload runtime
563+
# before the openmp project which will error out due to failing to
564+
# find libomp.so. We must add omp as a dependency before runtimes
565+
# are configured.
566+
if("openmp" IN_LIST LLVM_ENABLE_PROJECTS AND "offload" IN_LIST LLVM_ENABLE_RUNTIMES)
567+
add_dependencies(clang-bootstrap-deps omp)
568+
endif()
562569
endif()
563570

564571
if(LLVM_INCLUDE_TESTS)

offload/CMakeLists.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -267,11 +267,6 @@ if(OPENMP_STANDALONE_BUILD)
267267
${LLVM_LIBRARY_DIRS}
268268
REQUIRED
269269
)
270-
# Check LIBOMP_HAVE_VERSION_SCRIPT_FLAG
271-
include(LLVMCheckCompilerLinkerFlag)
272-
if(NOT APPLE)
273-
llvm_check_compiler_linker_flag(C "-Wl,--version-script=${CMAKE_CURRENT_LIST_DIR}/../openmp/runtime/src/exports_test_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
274-
endif()
275270

276271
macro(pythonize_bool var)
277272
if (${var})
@@ -282,6 +277,14 @@ if(OPENMP_STANDALONE_BUILD)
282277
endmacro()
283278
endif()
284279

280+
if(OPENMP_STANDALONE_BUILD OR TARGET omp)
281+
# Check LIBOMP_HAVE_VERSION_SCRIPT_FLAG
282+
include(LLVMCheckCompilerLinkerFlag)
283+
if(NOT APPLE)
284+
llvm_check_compiler_linker_flag(C "-Wl,--version-script=${CMAKE_CURRENT_LIST_DIR}/../openmp/runtime/src/exports_test_so.txt" LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
285+
endif()
286+
endif()
287+
285288
# OMPT support for libomptarget
286289
# Follow host OMPT support and check if host support has been requested.
287290
# LIBOMP_HAVE_OMPT_SUPPORT indicates whether host OMPT support has been implemented.

0 commit comments

Comments
 (0)