[llvm] [BOLT] Enable cross compilation of runtime libraries (PR #101180)

Gergely Bálint via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 3 01:55:51 PDT 2024


================
@@ -29,24 +29,25 @@ if(NOT BOLT_BUILT_STANDALONE)
   add_custom_command(TARGET bolt_rt_hugify POST_BUILD
     COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_CURRENT_BINARY_DIR}/lib/libbolt_rt_hugify.a" "${LLVM_LIBRARY_DIR}")
 endif()
-
-set(BOLT_RT_FLAGS
+# In case of compiling with clang, the '--target' option is passed in BOLT_RT_FLAGS.
+set(BOLT_RT_FLAGS ${BOLT_RT_FLAGS}
   -ffreestanding
   -fno-exceptions
   -fno-rtti
   -fno-stack-protector
   -fPIC
   -mgeneral-regs-only)
-if (CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+if(CMAKE_TARGET_SYSTEM_PROCESSOR STREQUAL "x86_64")
   set(BOLT_RT_FLAGS ${BOLT_RT_FLAGS} "-mno-sse")
 endif()
-if (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
+if(CMAKE_TARGET_SYSTEM_PROCESSOR STREQUAL "aarch64")
----------------
bgergely0 wrote:

Oops. CMAKE_TARGET_SYSTEM_PROCESSOR was indeed empty in this scenario, which (incorrectly) fixed the error I had. I will pass a variable specifying the target from the invocation of the RT build in bolt/CMakeLists.txt to here. 

(Leaving it as CMAKE_SYSTEM_PROCESSOR is incorrect because when cross compiling, it tries to pass x86 flags to the aarch64 build. And setting CMAKE_SYSTEM_PROCESSOR is also not an option as we are building the rest of BOLT for x86.)

https://github.com/llvm/llvm-project/pull/101180


More information about the llvm-commits mailing list