openmp-fix-runtimes-build
authorLLVM Packaging Team <pkg-llvm-team@lists.alioth.debian.org>
Wed, 4 Dec 2024 12:11:08 +0000 (13:11 +0100)
committerSylvestre Ledru <sylvestre@debian.org>
Wed, 4 Dec 2024 12:11:08 +0000 (13:11 +0100)
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
offload/plugins-nextgen/cuda/CMakeLists.txt
offload/plugins-nextgen/host/CMakeLists.txt
offload/src/CMakeLists.txt
openmp/CMakeLists.txt
openmp/runtime/CMakeLists.txt
openmp/runtime/src/CMakeLists.txt
openmp/tools/archer/CMakeLists.txt

index 42b1b86ebaadf0e17ef9c6d18e663df8971a67e9..1dd9b846877dd6dfef32ab4dee4934002bbc8c2e 100644 (file)
@@ -261,6 +261,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}
                                       -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
@@ -637,7 +638,7 @@ if(build_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 5fdfb8f9cf6282490637a3d3c57fef2bc09d7c23..d5837983b5ac331621d768d37676950384b4d061 100644 (file)
@@ -26,3 +26,5 @@ else()
   message(STATUS "Not generating NVIDIA tests, no supported devices detected."
                    " Use 'LIBOMPTARGET_FORCE_NVIDIA_TESTS' to override.")
 endif()
+
+add_runtimes_build_depends_if_needed(omptarget.rtl.cuda)
index 817d128f924109cf74a125dad410f6058eb172a4..994495c663580c76d78f06253d05e66ec7f9b5d4 100644 (file)
@@ -27,6 +27,8 @@ else()
   target_include_directories(omptarget.rtl.host PRIVATE dynamic_ffi)
 endif()
 
+add_runtimes_build_depends_if_needed("omptarget.rtl.${machine}")
+
 target_include_directories(omptarget.rtl.host PRIVATE
                            ${LIBOMPTARGET_INCLUDE_DIR})
 
index efa5cdab33ec9079e1122e05510a3848ea4218e6..f45ced4a182a4c3222de3f5df77e334feb84940f 100644 (file)
@@ -38,6 +38,9 @@ add_llvm_library(omptarget
   NO_INSTALL_RPATH
   BUILDTREE_ONLY
 )
+
+add_runtimes_build_depends_if_needed(omptarget)
+
 target_include_directories(omptarget PRIVATE
   ${LIBOMPTARGET_INCLUDE_DIR} ${LIBOMPTARGET_BINARY_INCLUDE_DIR}
 )
index 3b4259dfa380e892a362674c77185f383860b494..b025a250ddf9cd5ca4300bed9db0428f74575930 100644 (file)
@@ -122,6 +122,28 @@ else()
   get_clang_resource_dir(LIBOMP_HEADERS_INSTALL_PATH SUBDIR 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 29ef972333f7dd022540abeb9e2ec1a44ccff919..bf853c2b25591356d50816f2cfbbbcdf3b8e5489 100644 (file)
@@ -326,6 +326,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 f106694841ce8d074b9479d01b0cb2fbd24d5f07..f162a482cd52ecfd82559e1246e07748ad2eac84 100644 (file)
@@ -151,6 +151,7 @@ set_source_files_properties(${LIBOMP_ASMFILES} ${LIBOMP_GNUASMFILES} PROPERTIES
 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()
@@ -220,6 +221,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 980eb2b0b675fb904f3645de19adba1070eee4e2..9f018f7f72703a3884ed88be501e179cf5e9d399 100644 (file)
@@ -15,6 +15,9 @@ if(LIBOMP_OMPT_SUPPORT AND LIBOMP_ARCHER_SUPPORT)
   target_link_libraries(archer ${CMAKE_DL_LIBS})
   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})