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

Peter Waller via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 3 06:44:56 PDT 2024


Gergely =?utf-8?q?Bálint?= <gergely.balint at arm.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/101180 at github.com>


================
@@ -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++)
----------------
peterwaller-arm wrote:

It seems unfortunate to hard-code a cross compiler name here. What if you wanted to cross compile using clang for example?

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


More information about the llvm-commits mailing list