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

Gergely Bálint via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 2 07:54:35 PDT 2024


================
@@ -136,35 +135,60 @@ if (LLVM_INCLUDE_TESTS)
 endif()
 
 if (BOLT_ENABLE_RUNTIME)
-  message(STATUS "Building BOLT runtime libraries for X86")
+  if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+    set(HOST_NAME "X86")
+  elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")
+    set(HOST_NAME "AArch64")
+  elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "riscv64")
+    set(HOST_NAME "RISCV")
+  endif()
+
+  foreach(tgt ${BOLT_TARGETS_TO_BUILD})
+    message(STATUS "Building BOLT runtime libraries for ${tgt}")
   set(extra_args "")
   if(CMAKE_SYSROOT)
     list(APPEND extra_args -DCMAKE_SYSROOT=${CMAKE_SYSROOT})
   endif()
 
+    if(${tgt} STREQUAL ${HOST_NAME})
+      set(BOLT_RT_C_COMPILER ${CMAKE_C_COMPILER})
+      set(BOLT_RT_CXX_COMPILER ${CMAKE_CXX_COMPILER})
+      set(BOLT_RT_LIBRARY_DIR "${LLVM_LIBRARY_DIR}")
+    elseif(${tgt} STREQUAL "AArch64")
+      set(BOLT_RT_C_COMPILER aarch64-linux-gnu-gcc)
+      set(BOLT_RT_CXX_COMPILER aarch64-linux-gnu-g++)
----------------
bgergely0 wrote:

New version checks compatibility both for Clang and GNU compilers.

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


More information about the llvm-commits mailing list