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

Gergely Bálint via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 4 00:56:38 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++)
+      set(BOLT_RT_LIBRARY_DIR "${LLVM_LIBRARY_DIR}/AArch64")
+    elseif(${tgt} STREQUAL "RISCV")
+      set(BOLT_RT_C_COMPILER riscv64-unknown-linux-gnu-gcc)
+      set(BOLT_RT_CXX_COMPILER riscv64-unknown-linux-gnu-g++)
+      set(BOLT_RT_LIBRARY_DIR "${LLVM_LIBRARY_DIR}/RISCV")
+    endif()
----------------
bgergely0 wrote:

I assumed that is not a common scenario, but I will add that to be complete.

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


More information about the llvm-commits mailing list