[llvm] [offload] - Add omp as a dependency for clang-bootstrap-deps (PR #90793)

via llvm-commits llvm-commits at lists.llvm.org
Wed May 1 15:53:19 PDT 2024


https://github.com/estewart08 created https://github.com/llvm/llvm-project/pull/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.

>From ac456819c5d0d2717bebdc7034ff893a7bf06521 Mon Sep 17 00:00:00 2001
From: Ethan Stewart <ethan.stewart at amd.com>
Date: Wed, 1 May 2024 17:47:30 -0500
Subject: [PATCH] [offload] - Add omp as a dependency for clang-bootstrap-deps

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.
---
 llvm/runtimes/CMakeLists.txt |  7 +++++++
 offload/CMakeLists.txt       | 13 ++++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/llvm/runtimes/CMakeLists.txt b/llvm/runtimes/CMakeLists.txt
index 8159d7f8a0a104..3020ba72f4a60b 100644
--- a/llvm/runtimes/CMakeLists.txt
+++ b/llvm/runtimes/CMakeLists.txt
@@ -559,6 +559,13 @@ if(runtimes)
     # We need to add the runtimes as a dependency because compiler-rt can be
     # built as part of runtimes and we need the profile runtime for PGO
     add_dependencies(clang-bootstrap-deps runtimes)
+    # The bootstrap build will attempt to configure the offload runtime
+    # before the openmp project which will error out due to failing to
+    # find libomp.so. We must add omp as a dependency before runtimes
+    # are configured.
+    if("openmp" IN_LIST LLVM_ENABLE_PROJECTS AND "offload" IN_LIST LLVM_ENABLE_RUNTIMES)
+      add_dependencies(clang-bootstrap-deps omp)
+    endif()
   endif()
 
   if(LLVM_INCLUDE_TESTS)
diff --git a/offload/CMakeLists.txt b/offload/CMakeLists.txt
index 42e0f5740f116d..3f77583ffa3b85 100644
--- a/offload/CMakeLists.txt
+++ b/offload/CMakeLists.txt
@@ -267,11 +267,6 @@ if(OPENMP_STANDALONE_BUILD)
       ${LLVM_LIBRARY_DIRS}
     REQUIRED
   )
-# Check LIBOMP_HAVE_VERSION_SCRIPT_FLAG
-  include(LLVMCheckCompilerLinkerFlag)
-  if(NOT APPLE)
-    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)
-  endif()
 
   macro(pythonize_bool var)
   if (${var})
@@ -282,6 +277,14 @@ if(OPENMP_STANDALONE_BUILD)
   endmacro()
 endif()
 
+if(OPENMP_STANDALONE_BUILD OR TARGET omp)
+  # Check LIBOMP_HAVE_VERSION_SCRIPT_FLAG
+  include(LLVMCheckCompilerLinkerFlag)
+  if(NOT APPLE)
+    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)
+  endif()
+endif()
+
 # OMPT support for libomptarget
 # Follow host OMPT support and check if host support has been requested.
 # LIBOMP_HAVE_OMPT_SUPPORT indicates whether host OMPT support has been implemented.



More information about the llvm-commits mailing list