[compiler-rt] Create a combined compiler-rt builtin bitcode for SPIRV64 target (PR #214149)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 5 01:15:54 PDT 2026
https://github.com/jinge90 updated https://github.com/llvm/llvm-project/pull/214149
>From d5da7915086770b9cf0371d9264459adb7d46e36 Mon Sep 17 00:00:00 2001
From: jinge90 <ge.jin at intel.com>
Date: Wed, 5 Aug 2026 16:04:19 +0800
Subject: [PATCH] Create a combined compiler-rt builtin bitcode for SPIRV64
target
Signed-off-by: jinge90 <ge.jin at intel.com>
---
compiler-rt/lib/builtins/CMakeLists.txt | 32 +++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/compiler-rt/lib/builtins/CMakeLists.txt b/compiler-rt/lib/builtins/CMakeLists.txt
index aca50c78aa147..357fb2238a9d6 100644
--- a/compiler-rt/lib/builtins/CMakeLists.txt
+++ b/compiler-rt/lib/builtins/CMakeLists.txt
@@ -1168,6 +1168,38 @@ else ()
get_compiler_rt_output_dir(${arch} BUILTIN_LIB_OUTPUT_DIR)
set_output_name(BUILTIN_LIB_OUTPUT_NAME clang_rt.builtins ${arch})
file(WRITE "${BUILTIN_LIB_OUTPUT_DIR}/${BUILTIN_LIB_OUTPUT_NAME}.sources.txt" "${${arch}_SOURCES}")
+
+ # For spirv64, produce a combined bitcode file alongside the static archive.
+ # -mlink-builtin-bitcode expects raw LLVM IR and cannot unpack a static archive,
+ # so we use llvm-link to merge the archive members into a single .bc file.
+ if("${arch}" MATCHES "^spirv64")
+ find_program(LLVM_LINK llvm-link
+ PATHS ${LLVM_TOOLS_BINARY_DIR}
+ NO_DEFAULT_PATH)
+ if(LLVM_LINK)
+ set(SPIRV64_BC_OUTPUT "${BUILTIN_LIB_OUTPUT_DIR}/lib${BUILTIN_LIB_OUTPUT_NAME}.bc")
+ add_custom_command(
+ OUTPUT "${SPIRV64_BC_OUTPUT}"
+ COMMAND "${LLVM_LINK}"
+ "$<TARGET_FILE:clang_rt.builtins-spirv64>"
+ -o "${SPIRV64_BC_OUTPUT}"
+ DEPENDS clang_rt.builtins-${arch}
+ COMMENT "Linking lib${BUILTIN_LIB_OUTPUT_NAME}.bc"
+ VERBATIM)
+ add_custom_target(clang_rt.builtins-spirv64-bc ALL
+ DEPENDS "${SPIRV64_BC_OUTPUT}")
+ add_dependencies(builtins clang_rt.builtins-spirv64-bc)
+ get_compiler_rt_install_dir(${arch} BUILTIN_INSTALL_DIR)
+ install(FILES "${SPIRV64_BC_OUTPUT}"
+ DESTINATION "${BUILTIN_INSTALL_DIR}"
+ COMPONENT builtins)
+ else()
+ message(WARNING
+ "llvm-link not found (LLVM_TOOLS_BINARY_DIR='${LLVM_TOOLS_BINARY_DIR}'); "
+ "skipping libclang_rt.builtins.bc for spirv64")
+ endif()
+ endif()
+
cmake_pop_check_state()
endif ()
endforeach ()
More information about the llvm-commits
mailing list