openmp-fix-runtimes-build
authorLLVM Packaging Team <pkg-llvm-team@lists.alioth.debian.org>
Mon, 23 Sep 2024 11:23:31 +0000 (13:23 +0200)
committerSylvestre Ledru <sylvestre@debian.org>
Mon, 23 Sep 2024 11:23:31 +0000 (13:23 +0200)
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
<<<<<<< Updated upstream

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

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

index 8c48d85a4346f478f2b9133aa8cc532fdebed434..47904e366fb860ac37cce5e41881acb0abf15440 100644 (file)
@@ -247,6 +247,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
@@ -517,7 +518,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 03068af22629f7136f2fd661d79b6ef216dff7e6..4b2a3d89c7b161d8bdca825257987e0f34b58b17 100644 (file)
@@ -113,6 +113,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 f5fc3b6211109ac56f8abcd93d99acb1d99b169d..616db772d9869be0f45f21bbd47497b5674077f6 100644 (file)
@@ -74,6 +74,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
       "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/../exports")
   endif()
 
+  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 95b288cab31149681c127349a33465bf1e2827f0..51b873226ba0d50d74e29326a08bba12adff1fb0 100644 (file)
@@ -80,6 +80,8 @@ else()
                    " Use 'LIBOMPTARGET_FORCE_NVIDIA_TESTS' to override.")
 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 1a0e26f104be63af97ff0fe16174fbb60ecae28a..db873aa32e4e882f6fd3783987eafb10fc21b079 100644 (file)
@@ -41,7 +41,9 @@ add_llvm_library(omptarget
   omp
 
   NO_INSTALL_RPATH
-)
+  )
+add_runtimes_build_depends_if_needed(omptarget)
+
 target_include_directories(omptarget PRIVATE ${LIBOMPTARGET_INCLUDE_DIR})
 
 if (LIBOMP_HAVE_VERSION_SCRIPT_FLAG)
index 6ae807bcc849c5f503132a4439f8825d28b5b559..df44e3a66a1c480accb373112877aab2f1f09e5d 100644 (file)
@@ -318,6 +318,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 619d4f7ba45822b02814ed411e649e16087dd5f3..fb86de53bebc88632731355e49b045d07da4a90d 100644 (file)
@@ -144,6 +144,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()
@@ -205,6 +206,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})