[PATCH] D115038: [runtimes][VE] Change to compile crtbegin/end before compiler-rt

Kazushi Marukawa via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 3 05:05:47 PST 2021


kaz7 created this revision.
kaz7 added reviewers: ldionne, smeenai, beanz, jdoerfert, phosek.
kaz7 added projects: LLVM, libc++, libc++abi.
Herald added subscribers: mgorny, dberris.
kaz7 requested review of this revision.
Herald added a subscriber: llvm-commits.

VE doesn't distribute crtbegin/end, so compilation of LLVM for VE
requires to compile crtbegin/end first similar to builtin.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115038

Files:
  llvm/runtimes/CMakeLists.txt


Index: llvm/runtimes/CMakeLists.txt
===================================================================
--- llvm/runtimes/CMakeLists.txt
+++ llvm/runtimes/CMakeLists.txt
@@ -128,6 +128,51 @@
                            ${EXTRA_ARGS})
 endfunction()
 
+function(builtin_crt_register_target compiler_rt_path target)
+  cmake_parse_arguments(ARG "" "" "DEPENDS" ${ARGN})
+
+  check_apple_target(${target} builtin)
+
+  set(${target}_extra_args ${ARG_CMAKE_ARGS})
+  get_cmake_property(variableNames VARIABLES)
+  foreach(variableName ${variableNames})
+    string(FIND "${variableName}" "BUILTINS_${target}" out)
+    if("${out}" EQUAL 0)
+      string(REPLACE "BUILTINS_${target}_" "" new_name ${variableName})
+      string(REPLACE ";" "|" new_value "${${variableName}}")
+      list(APPEND ${target}_extra_args "-D${new_name}=${new_value}")
+    endif()
+  endforeach()
+
+  llvm_ExternalProject_Add(builtins-crt-${target}
+                           ${compiler_rt_path}
+                           DEPENDS ${ARG_DEPENDS}
+                           CMAKE_ARGS -DLLVM_LIBRARY_OUTPUT_INTDIR=${LLVM_LIBRARY_DIR}
+                                      -DLLVM_RUNTIME_OUTPUT_INTDIR=${LLVM_TOOLS_BINARY_DIR}
+                                      -DLLVM_DEFAULT_TARGET_TRIPLE=${target}
+                                      -DLLVM_ENABLE_PER_TARGET_RUNTIME_DIR=ON
+                                      -DCMAKE_C_COMPILER_WORKS=ON
+                                      -DCMAKE_ASM_COMPILER_WORKS=ON
+                                      -DCOMPILER_RT_DEFAULT_TARGET_ONLY=ON
+                                      -DCOMPILER_RT_BUILD_BUILTINS=OFF
+                                      -DCOMPILER_RT_BUILD_CRT=ON
+                                      -DCOMPILER_RT_BUILD_SANITIZERS=OFF
+                                      -DCOMPILER_RT_BUILD_XRAY=OFF
+                                      -DCOMPILER_RT_BUILD_LIBFUZZER=OFF
+                                      -DCOMPILER_RT_BUILD_PROFILE=OFF
+                                      -DCOMPILER_RT_BUILD_MEMPROF=OFF
+                                      -DCOMPILER_RT_BUILD_ORC=OFF
+                                      -DCOMPILER_RT_BUILD_GWP_ASAN=OFF
+                                      -DTEST_COMPILE_ONLY=ON
+                                      -DCMAKE_C_FLAGS=-nostdlib
+                                      -DCMAKE_CXX_FLAGS=-nostdlib
+                                      ${COMMON_CMAKE_ARGS}
+                                      ${${target}_extra_args}
+                           USE_TOOLCHAIN
+                           TARGET_TRIPLE ${target}
+                           ${EXTRA_ARGS})
+endfunction()
+
 # If compiler-rt is present we need to build the builtin libraries first. This
 # is required because the other runtimes need the builtin libraries present
 # before the just-built compiler can pass the configuration tests.
@@ -154,6 +199,19 @@
       add_dependencies(builtins builtins-${target})
       add_dependencies(install-builtins install-builtins-${target})
       add_dependencies(install-builtins-stripped install-builtins-${target}-stripped)
+      # If compiler-rt is present and compiling for VE, we need to build not
+      # only the builtin libraries but also crtbegin/end object files first.
+      # This is required because the other runtimes need the builtin libraries
+      # and crtbegin/end object files present before the just-built compiler
+      # can pass the configuration tests.  And those crtbegin/end object files
+      # for VE are a part of NEC SDK and not distributed freely.
+      if(${target} MATCHES "^ve-")
+        builtin_crt_register_target(${compiler_rt_path} ${target}
+          DEPENDS clang-resource-headers)
+        add_dependencies(builtins builtins-crt-${target})
+        add_dependencies(install-builtins install-builtins-crt-${target})
+        add_dependencies(install-builtins-stripped install-builtins-crt-${target}-stripped)
+      endif()
     endforeach()
   endif()
   set(deps builtins)


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D115038.391614.patch
Type: text/x-patch
Size: 4031 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211203/80bd3242/attachment.bin>


More information about the llvm-commits mailing list