openmp-fix-runtimes-build
authorLLVM Packaging Team <pkg-llvm-team@lists.alioth.debian.org>
Fri, 22 Jul 2022 13:10:20 +0000 (14:10 +0100)
committerSylvestre Ledru <sylvestre@debian.org>
Fri, 22 Jul 2022 13:10:20 +0000 (14:10 +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
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 3436cd8bdfbef31487bdacf57e4acad47c586a9a..d04960fc32f1adc0f2857997157251e3ddcc5f9f 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
@@ -448,7 +449,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 45c400351f32e351bf32da50e64d4c76e801bf4f..2cc8bcb9c4bcc4f4a89ed589645e7bcbac443bb9 100644 (file)
@@ -67,6 +67,28 @@ option(OPENMP_ENABLE_LIBOMPTARGET_PROFILING "Enable time profiling for libomptar
        ${ENABLE_LIBOMPTARGET})
 option(OPENMP_ENABLE_LIBOMP_PROFILING "Enable time profiling for libomp." OFF)
 
+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 ac156785c9a0f643f19b7f060edb9e43235b521f..5a49bdf17429a2ad9b55141fd4a4f25427a6af1b 100644 (file)
@@ -36,6 +36,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tmachine}$")
       add_library("omptarget.rtl.${tmachine_libname}" SHARED
         ${CMAKE_CURRENT_SOURCE_DIR}/../generic-elf-64bit/src/rtl.cpp)
 
+      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 7f77bcc364f527256d53f6cec0484ae72e550a56..e240bd401d82ba8089684fdd461596ae907b6f7b 100644 (file)
@@ -44,6 +44,8 @@ else()
   set (LIBOMPTARGET_DEP_LIBRARIES ${CMAKE_DL_LIBS})
 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}")
 
index 46387e203bd067f7208331f0a6275343c5317b9e..3546899e4acc8b2b5131aa63c0189b44195d275d 100644 (file)
@@ -38,6 +38,8 @@ target_link_libraries(omptarget PRIVATE
   ${CMAKE_DL_LIBS}
   "-Wl,--version-script=${CMAKE_CURRENT_SOURCE_DIR}/exports")
 
+add_runtimes_build_depends_if_needed(omptarget)
+
 # Install libomptarget under the lib destination folder.
 install(TARGETS omptarget LIBRARY COMPONENT omptarget
   DESTINATION "${OPENMP_INSTALL_LIBDIR}")
index 80852d9d9466c03d7d62bc38e5eacf8a8e91b0eb..5872774003bcc5439b708b28c9a739dc70494eb5 100644 (file)
@@ -287,6 +287,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 bdb867e352f7885e6dfd24f81afd8f454dcc05a8..5f0cd7dbedfd7e8c37e4fc4a2c08da84843994c6 100644 (file)
@@ -136,6 +136,7 @@ endif()
 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()
@@ -164,6 +165,8 @@ set_target_properties(omp PROPERTIES
   LINKER_LANGUAGE ${LIBOMP_LINKER_LANGUAGE}
 )
 
+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})