From b63241829f6a58dfabef1a50138b2a0d2a085129 Mon Sep 17 00:00:00 2001 From: Harald van Dijk Date: Tue, 9 Sep 2025 15:37:44 +0100 Subject: [PATCH] Specify --target when calling clang. ${clang_exe} may not default to the same target as ${CMAKE_CXX_COMPILER}. This change is not sufficient to fix all cases, as it does not ensure compatibility with target flags in ${CMAKE_CXX_FLAGS}, but handles the most common cases when cross compiling. --- sycl-jit/jit-compiler/CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/sycl-jit/jit-compiler/CMakeLists.txt b/sycl-jit/jit-compiler/CMakeLists.txt index d8f66d6a719d9..aa691d7f36bd3 100644 --- a/sycl-jit/jit-compiler/CMakeLists.txt +++ b/sycl-jit/jit-compiler/CMakeLists.txt @@ -56,7 +56,12 @@ endif() add_custom_command( OUTPUT ${SYCL_JIT_RESOURCE_OBJ} COMMAND - ${clang_exe} ${SYCL_JIT_RESOURCE_CPP} -I ${CMAKE_CURRENT_SOURCE_DIR}/include -c -o ${SYCL_JIT_RESOURCE_OBJ} ${SYCL_JIT_RESOURCE_CXX_FLAGS} + # ${clang_exe}'s default target is not necessarily ${LLVM_HOST_TRIPLE}: when + # cross compiling, it will be whatever the host tools were configured with, + # and when building a cross compiler, it will be + # ${LLVM_DEFAULT_TARGET_TRIPLE}. Rather than special casing these, just always + # specify --target=${LLVM_HOST_TRIPLE}. + ${clang_exe} --target=${LLVM_HOST_TRIPLE} ${SYCL_JIT_RESOURCE_CPP} -I ${CMAKE_CURRENT_SOURCE_DIR}/include -c -o ${SYCL_JIT_RESOURCE_OBJ} ${SYCL_JIT_RESOURCE_CXX_FLAGS} DEPENDS ${SYCL_JIT_RESOURCE_CPP} ${CMAKE_CURRENT_SOURCE_DIR}/include/Resource.h