File: openmp-fix-runtimes-build.diff

package info (click to toggle)
llvm-toolchain-15 1%3A15.0.6-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,554,644 kB
  • sloc: cpp: 5,922,452; ansic: 1,012,136; asm: 674,362; python: 191,568; objc: 73,855; f90: 42,327; lisp: 31,913; pascal: 11,973; javascript: 10,144; sh: 9,421; perl: 7,447; ml: 5,527; awk: 3,523; makefile: 2,520; xml: 885; cs: 573; fortran: 567
file content (148 lines) | stat: -rw-r--r-- 7,841 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
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
Index: llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe/llvm/runtimes/CMakeLists.txt
===================================================================
--- llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe.orig/llvm/runtimes/CMakeLists.txt
+++ llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe/llvm/runtimes/CMakeLists.txt
@@ -245,6 +245,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
@@ -472,7 +473,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: llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe/openmp/CMakeLists.txt
===================================================================
--- llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe.orig/openmp/CMakeLists.txt
+++ llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe/openmp/CMakeLists.txt
@@ -77,6 +77,28 @@ option(OPENMP_ENABLE_LIBOMPTARGET_PROFIL
        ${ENABLE_LIBOMPTARGET_PROFILING})
 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: llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe/openmp/libomptarget/plugins/CMakeLists.txt
===================================================================
--- llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe.orig/openmp/libomptarget/plugins/CMakeLists.txt
+++ llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe/openmp/libomptarget/plugins/CMakeLists.txt
@@ -52,6 +52,8 @@ if(CMAKE_SYSTEM_PROCESSOR MATCHES "${tma
         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: llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe/openmp/libomptarget/plugins/cuda/CMakeLists.txt
===================================================================
--- llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe.orig/openmp/libomptarget/plugins/cuda/CMakeLists.txt
+++ llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe/openmp/libomptarget/plugins/cuda/CMakeLists.txt
@@ -88,6 +88,8 @@ else()
 endif()
 add_dependencies(omptarget.rtl.cuda omptarget.devicertl.nvptx)
 
+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: llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe/openmp/libomptarget/src/CMakeLists.txt
===================================================================
--- llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe.orig/openmp/libomptarget/src/CMakeLists.txt
+++ llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe/openmp/libomptarget/src/CMakeLists.txt
@@ -35,7 +35,9 @@ add_llvm_library(omptarget
   ${CMAKE_DL_LIBS}
   "-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: llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe/openmp/runtime/CMakeLists.txt
===================================================================
--- llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe.orig/openmp/runtime/CMakeLists.txt
+++ llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe/openmp/runtime/CMakeLists.txt
@@ -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: llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe/openmp/runtime/src/CMakeLists.txt
===================================================================
--- llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe.orig/openmp/runtime/src/CMakeLists.txt
+++ llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe/openmp/runtime/src/CMakeLists.txt
@@ -133,6 +133,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()
@@ -190,6 +191,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: llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe/openmp/tools/archer/CMakeLists.txt
===================================================================
--- llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe.orig/openmp/tools/archer/CMakeLists.txt
+++ llvm-toolchain-snapshot_15~++20220723123759+d959324e1efe/openmp/tools/archer/CMakeLists.txt
@@ -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})