openmp-fix-runtimes-build
authorLLVM Packaging Team <pkg-llvm-team@lists.alioth.debian.org>
Mon, 16 Oct 2023 13:14:10 +0000 (13:14 +0000)
committerAndres Salomon <dilinger@debian.org>
Mon, 16 Oct 2023 13:14:10 +0000 (13:14 +0000)
include required runtimes as dependencies to openmp targets to make sure
they are built first when included as part of a runtimes build since openmp
can depend on them

Gbp-Pq: Name openmp-fix-runtimes-build.diff

llvm/runtimes/CMakeLists.txt
openmp/CMakeLists.txt
openmp/libomptarget/plugins/CMakeLists.txt
openmp/libomptarget/plugins/cuda/CMakeLists.txt
openmp/libomptarget/src/CMakeLists.txt
openmp/runtime/CMakeLists.txt
openmp/runtime/src/CMakeLists.txt
openmp/tools/archer/CMakeLists.txt

index 694f346ee8e936476d6bd1a36752503164567b77..04ed296bde9e18a5f771e0f55902aff6eb5f7a0e 100644 (file)
@@ -233,6 +233,7 @@ function(runtime_default_target)
                                       -DLLVM_ENABLE_PROJECTS_USED=${LLVM_ENABLE_PROJECTS_USED}
                                       -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=${LLVM_ENABLE_PER_TARGET_RUNTIME_DIR_default}
                                       -DLLVM_BUILD_TOOLS=${LLVM_BUILD_TOOLS}
+                                      -DCMAKE_SYSTEM_PROCESSOR=${CMAKE_SYSTEM_PROCESSOR}
                                       -DCMAKE_C_COMPILER_WORKS=ON
                                       -DCMAKE_CXX_COMPILER_WORKS=ON
                                       -DCMAKE_ASM_COMPILER_WORKS=ON
@@ -480,7 +481,7 @@ if(runtimes)
     # build directory cannot find the C++ headers in certain configurations.
     # I need to build a mechanism for runtime projects to provide CMake code
     # that executes at LLVM configuration time to handle this case.
-    add_dependencies(clang-bootstrap-deps runtimes-configure)
+    #add_dependencies(clang-bootstrap-deps runtimes-configure)
     # 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)
index a87ea2fb57c516bafa5a748f349841ab3b4e5578..823691c893d83c529919e7916a81e0bca2224ab4 100644 (file)
@@ -91,6 +91,28 @@ else()
   set(LIBOMP_HEADERS_INSTALL_PATH "${OPENMP_INSTALL_LIBDIR}/clang/${CLANG_VERSION}/include")
 endif()
 
+option(OPENMP_USE_LLVM_UNWINDER "Build and use the LLVM unwinder" OFF)
+
+option(LIBOMP_ENABLE_RTTI "Enabling RTTI forces libomp to be a c++ lib" ${LLVM_ENABLE_RTTI})
+
+macro(add_runtimes_build_depends_if_needed target)
+  if(RUNTIMES_BUILD)
+    # required for rtti and libomp/libomptarget profiling if enabled
+    add_dependencies(${target} cxx-headers cxxabi_static cxx_static cxxabi_shared cxx_shared)
+    if(OPENMP_USE_LLVM_UNWINDER AND (NOT target STREQUAL "omp" AND NOT LIBOMP_ENABLE_RTTI))
+      add_dependencies(${target} unwind_static unwind_shared)
+      get_target_property(target_link_flags ${target} LINK_FLAGS)
+      set(runtimes_link_flags "-lunwind")
+      if(target_link_flags)
+        set(runtimes_link_flags "${target_link_flags} -lunwind")
+      endif()
+      set_target_properties(${target}
+        PROPERTIES
+        LINK_FLAGS "${runtimes_link_flags}")
+    endif()
+  endif()
+endmacro()
+
 # Build host runtime library, after LIBOMPTARGET variables are set since they are needed
 # to enable time profiling support in the OpenMP runtime.
 add_subdirectory(runtime)
index 005a3721b1f7087386d642f5fe41cf73b798e532..ba3d78761e18ebe056d4d6af2ced7a79722685a3 100644 (file)
@@ -48,6 +48,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
       NO_INSTALL_RPATH
     )
 
+  add_runtimes_build_depends_if_needed("omptarget.rtl.${tmachine_libname}")
+
     # Install plugin under the lib destination folder.
     install(TARGETS "omptarget.rtl.${tmachine_libname}"
       LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}")
index 6d0b767cecbb3274201452909b69e970b4fb14d7..a4d97b27be707935edca67dd33cd5c49985bd0a5 100644 (file)
@@ -83,6 +83,8 @@ else()
   )
 endif()
 
+add_runtimes_build_depends_if_needed(omptarget.rtl.cuda)
+
 # Install plugin under the lib destination folder.
 install(TARGETS omptarget.rtl.cuda LIBRARY DESTINATION "${OPENMP_INSTALL_LIBDIR}")
 set_target_properties(omptarget.rtl.cuda PROPERTIES 
index 2a6cd93c6ec987869da9e3cfd41f45c37ceb86f0..16e1334f149b0e532d31284efb15a4923561716c 100644 (file)
@@ -35,7 +35,9 @@ add_llvm_library(omptarget
   PRIVATE
   "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports"
   NO_INSTALL_RPATH
-)
+  )
+add_runtimes_build_depends_if_needed(omptarget)
+
 target_include_directories(omptarget PRIVATE ${LIBOMPTARGET_INCLUDE_DIR})
 
 # libomptarget.so needs to be aware of where the plugins live as they
index 4c67ad11a8e248e56e162d88e891f82dabfa78dd..e36a20246f8028404b89d480be2cfaa612f56355 100644 (file)
@@ -292,6 +292,10 @@ if(LIBOMP_STATS)
   set(LIBOMP_USE_STDCPPLIB TRUE)
 endif()
 
+if(LIBOMP_ENABLE_RTTI)
+  set(LIBOMP_USE_STDCPPLIB TRUE)
+endif()
+
 # Shared library can be switched to a static library
 set(LIBOMP_ENABLE_SHARED TRUE CACHE BOOL
   "Shared library instead of static library?")
index 09a05abdf7bf9c7242d7a912197f1710c1057bd5..1db26f8e01445da40e2e393182d6155464085e0e 100644 (file)
@@ -140,6 +140,7 @@ set_source_files_properties(${LIBOMP_GNUASMFILES} PROPERTIES LANGUAGE C)
 if(NOT ${LIBOMP_USE_STDCPPLIB})
   set(LIBOMP_LINKER_LANGUAGE C)
   set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES)
+  set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -nostdlib++")
 else()
   set(LIBOMP_LINKER_LANGUAGE CXX)
 endif()
@@ -201,6 +202,8 @@ else()
   )
 endif()
 
+add_runtimes_build_depends_if_needed(omp)
+
 # Get the library's location within the build tree for the unit tester
 if(NOT WIN32)
   get_target_property(LIBOMP_LIBRARY_DIR omp LIBRARY_OUTPUT_DIRECTORY)
index 85405affe8f1acff87386c2c1cda21e04c8f4871..97715b2e2c2555c52cfac38b0ff4d37193430cab 100644 (file)
@@ -14,6 +14,9 @@ if(LIBOMP_OMPT_SUPPORT)
   add_library(archer SHARED ompt-tsan.cpp)
   add_library(archer_static STATIC ompt-tsan.cpp)
 
+  add_runtimes_build_depends_if_needed(archer)
+  add_runtimes_build_depends_if_needed(archer_static)
+
   install(TARGETS archer archer_static
     LIBRARY DESTINATION ${OPENMP_INSTALL_LIBDIR}
     ARCHIVE DESTINATION ${OPENMP_INSTALL_LIBDIR})