|
| 1 | +From 7ae15bf526f06b5e6c18e9f908b6c58236f7c6a4 Mon Sep 17 00:00:00 2001 |
| 2 | +From: conda-forge <noreply@conda-forge.org> |
| 3 | +Date: Fri, 24 Jul 2026 10:00:23 +0200 |
| 4 | +Subject: [PATCH] Use build-native tools for device bitcode when |
| 5 | + cross-compiling |
| 6 | + |
| 7 | +The SSCP libkernel bitcode is target-independent (the device triple is |
| 8 | +passed explicitly) but is generated on the build host. Route the clang and |
| 9 | +llvm-link invocations through ACPP_BITCODE_CLANG / ACPP_BITCODE_LLVM_LINK, |
| 10 | +which default to the target tools for native builds and can be overridden |
| 11 | +with build-native tools when cross-compiling (e.g. linux-aarch64 on x86_64). |
| 12 | +--- |
| 13 | + src/libkernel/sscp/CMakeLists.txt | 15 +++++++++++++-- |
| 14 | + 1 file changed, 13 insertions(+), 2 deletions(-) |
| 15 | + |
| 16 | +diff --git a/src/libkernel/sscp/CMakeLists.txt b/src/libkernel/sscp/CMakeLists.txt |
| 17 | +index 672553a..7ab74f4 100644 |
| 18 | +--- a/src/libkernel/sscp/CMakeLists.txt |
| 19 | ++++ b/src/libkernel/sscp/CMakeLists.txt |
| 20 | +@@ -1,3 +1,14 @@ |
| 21 | ++# Cross-compilation: the device bitcode below is target-independent (the |
| 22 | ++# device triple is set explicitly), but it is generated on the *build* host. |
| 23 | ++# Use build-native clang/llvm-link so they can execute when cross-compiling, |
| 24 | ++# while CLANG_EXECUTABLE_PATH stays pointed at the target toolchain for the |
| 25 | ++# runtime configuration. Both default to the target tools for native builds. |
| 26 | ++if(NOT ACPP_BITCODE_CLANG) |
| 27 | ++ set(ACPP_BITCODE_CLANG "${CLANG_EXECUTABLE_PATH}") |
| 28 | ++endif() |
| 29 | ++if(NOT ACPP_BITCODE_LLVM_LINK) |
| 30 | ++ set(ACPP_BITCODE_LLVM_LINK "${LLVM_TOOLS_BINARY_DIR}/llvm-link") |
| 31 | ++endif() |
| 32 | + |
| 33 | + function(libkernel_generate_bitcode_library) |
| 34 | + set(options) |
| 35 | +@@ -32,7 +43,7 @@ function(libkernel_generate_bitcode_library) |
| 36 | + |
| 37 | + add_custom_command( |
| 38 | + OUTPUT ${target_output_file} |
| 39 | +- COMMAND ${CLANG_EXECUTABLE_PATH} -target ${triple} -fno-exceptions -fno-rtti -O3 -emit-llvm -std=c++17 -DHIPSYCL_SSCP_LIBKERNEL_LIBRARY |
| 40 | ++ COMMAND ${ACPP_BITCODE_CLANG} -target ${triple} -fno-exceptions -fno-rtti -O3 -emit-llvm -std=c++17 -DHIPSYCL_SSCP_LIBKERNEL_LIBRARY |
| 41 | + -I ${HIPSYCL_SOURCE_DIR}/include ${additional} ${platform_specific} -o ${target_output_file} -c ${CMAKE_CURRENT_SOURCE_DIR}/${source} |
| 42 | + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${source} ${target_depends} |
| 43 | + VERBATIM) |
| 44 | +@@ -77,7 +88,7 @@ function(libkernel_generate_bitcode_target) |
| 45 | + set(linked_output ${CMAKE_CURRENT_BINARY_DIR}/libkernel-sscp-${target}-full.bc) |
| 46 | + add_custom_command( |
| 47 | + OUTPUT ${linked_output} |
| 48 | +- COMMAND ${LLVM_TOOLS_BINARY_DIR}/llvm-link -o=${linked_output} ${output_files} |
| 49 | ++ COMMAND ${ACPP_BITCODE_LLVM_LINK} -o=${linked_output} ${output_files} |
| 50 | + DEPENDS ${output_files} ${target_depends} |
| 51 | + ) |
| 52 | + |
| 53 | +-- |
| 54 | +2.53.0 |
| 55 | + |
0 commit comments