Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
2d50750
remove dummy bin
jinge90 Nov 24, 2025
9c76946
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Nov 26, 2025
fe628a9
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Nov 27, 2025
7a7e62b
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Nov 28, 2025
4de8fa5
merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Dec 1, 2025
e52bb98
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Dec 4, 2025
4b63322
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Dec 10, 2025
544d912
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Dec 12, 2025
2ad6143
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Dec 17, 2025
cf391d9
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Dec 24, 2025
e0f2a15
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Jan 6, 2026
aa7a97c
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Jan 12, 2026
9244680
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Jan 30, 2026
b4b5793
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Feb 3, 2026
50f8f75
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Feb 4, 2026
ebc7166
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Feb 4, 2026
159748c
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Feb 4, 2026
17362e0
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Mar 3, 2026
9e38387
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Mar 5, 2026
dd1e30b
Merge remote-tracking branch 'origin/sycl' into sycl
jinge90 Mar 5, 2026
01fa557
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Mar 25, 2026
78adbd8
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Mar 26, 2026
c681812
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Apr 9, 2026
0726c0d
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Apr 10, 2026
f96405d
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Apr 14, 2026
d1f74f4
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Apr 21, 2026
eac7780
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Apr 24, 2026
ff388a2
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 May 7, 2026
fc841dd
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 May 8, 2026
615606d
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 May 14, 2026
5418d34
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 May 21, 2026
63315b5
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 May 22, 2026
8f6fca3
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 May 26, 2026
11f299c
Merge remote-tracking branch 'upstream/sycl' into sycl
jinge90 Jun 9, 2026
40f4f14
Enable libc string functions in SYCL
jinge90 Jun 9, 2026
3fc5890
a workaround to bypass address space issue
jinge90 Jun 9, 2026
7407a85
revert unneeded change
jinge90 Jun 9, 2026
f7db9b2
fix strcpy
jinge90 Jun 9, 2026
10dc0e5
fix memcmp strcmp
jinge90 Jun 10, 2026
0c69de2
apply fdefault-addr-space-is-generic
jinge90 Jun 10, 2026
b965b27
recover cstring for cuda and amd devices
jinge90 Jun 10, 2026
a89b061
fix clang format
jinge90 Jun 10, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 16 additions & 7 deletions buildbot/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,16 @@ def do_configure(args, passthrough_args):
"-DBUG_REPORT_URL=https://github.com/intel/llvm/issues",
]

llvm_spirv64_runtimes = "libc"
runtime_targets += ";spirv64-unknown-unknown"
cmake_cmd.extend(
[
"-DRUNTIMES_spirv64-unknown-unknown_LLVM_ENABLE_RUNTIMES={}".format(
llvm_spirv64_runtimes
),
]
)

if llvm_enable_runtimes:
cmake_cmd.extend(
[
Expand All @@ -225,19 +235,18 @@ def do_configure(args, passthrough_args):

if libclc_enabled:
for target in runtime_targets.split(";"):
if target == "default":
if target == "default" or target == "spirv64-unknown-unknown":
continue
cmake_cmd.extend(
[
f"-DRUNTIMES_{target}_LLVM_ENABLE_RUNTIMES=libclc",
]
)
cmake_cmd.extend(
[
"-DLLVM_RUNTIME_TARGETS={}".format(runtime_targets),
]
)

cmake_cmd.extend(
[
"-DLLVM_RUNTIME_TARGETS={}".format(runtime_targets),
]
)
if args.l0_headers and args.l0_loader:
cmake_cmd.extend(
[
Expand Down
1 change: 1 addition & 0 deletions clang/include/clang/Basic/LangOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ LANGOPT(GPUDeferDiag, 1, 0, NotCompatible, "defer host/device related diagnostic
LANGOPT(GPUExcludeWrongSideOverloads, 1, 0, NotCompatible, "always exclude wrong side overloads in overloading resolution for CUDA/HIP")
LANGOPT(OffloadingNewDriver, 1, 0, NotCompatible, "use the new driver for generating offloading code.")
LANGOPT(OffloadViaLLVM, 1, 0, NotCompatible, "target LLVM/Offload as portable offloading runtime.")
LANGOPT(DefaultAddrSpaceIsGeneric, 1, 0, NotCompatible, "use generic address space as default address space for SPIR-V targets")

LANGOPT(SYCLIsDevice , 1, 0, NotCompatible, "Generate code for SYCL device")
LANGOPT(SYCLIsHost , 1, 0, NotCompatible, "SYCL host compilation")
Expand Down
4 changes: 4 additions & 0 deletions clang/include/clang/Options/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -9202,6 +9202,10 @@ def fdefault_calling_conv_EQ : Joined<["-"], "fdefault-calling-conv=">,
NormalizedValuesScope<"LangOptions">,
NormalizedValues<["DCC_CDecl", "DCC_FastCall", "DCC_StdCall", "DCC_VectorCall", "DCC_RegCall", "DCC_RtdCall"]>,
MarshallingInfoEnum<LangOpts<"DefaultCallingConv">, "DCC_None">;
def fdefault_addr_space_is_generic : Flag<["-"], "fdefault-addr-space-is-generic">,
HelpText<"Use generic address space as the default address space for SPIR-V targets">,
Visibility<[CC1Option]>,
MarshallingInfoFlag<LangOpts<"DefaultAddrSpaceIsGeneric">>;

// These options cannot be marshalled, because they are used to set up the LangOptions defaults.
def finclude_default_header : Flag<["-"], "finclude-default-header">,
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Basic/Targets/SPIR.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ class LLVM_LIBRARY_VISIBILITY BaseSPIRTargetInfo : public TargetInfo {
// SYCL and HIP/CUDA.
setAddressSpaceMap(
/*DefaultIsGeneric=*/Opts.SYCLIsDevice ||
Opts.DefaultAddrSpaceIsGeneric ||
// The address mapping from HIP/CUDA language for device code is only
// defined for SPIR-V, and all Intel SPIR-V code should have the default
// AS as generic.
Expand Down
9 changes: 9 additions & 0 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5863,6 +5863,15 @@ class OffloadingActionBuilder final {
SmallVector<SmallString<128>, 4> LibLocCandidates;
SYCLInstallation.getSYCLDeviceLibPath(LibLocCandidates);

if (TC->getTriple().isSPIROrSPIRV()) {
SmallVector<SmallString<128>, 4> OriginalLibLocs(LibLocCandidates);
for (auto LibLoc : OriginalLibLocs) {
SmallString<128> SPIRVLibLoc(LibLoc);
llvm::sys::path::append(SPIRVLibLoc, "spirv64-unknown-unknown");
if (llvm::sys::fs::exists(SPIRVLibLoc))
LibLocCandidates.emplace_back(SPIRVLibLoc);
}
}
const toolchains::SYCLToolChain &SYCLTC =
static_cast<const toolchains::SYCLToolChain &>(*TC);
SmallVector<ToolChain::BitCodeLibraryInfo, 8> DeviceLibraries;
Expand Down
14 changes: 13 additions & 1 deletion clang/lib/Driver/ToolChains/SYCL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ SYCLToolChain::getDeviceLibNames(const Driver &D,
#if defined(_WIN32)
"libsycl-msvc-math",
#endif
"libsycl-imf"};
"libsycl-imf", "libc"};
auto addLibraries = [&](const SYCLDeviceLibsList &LibsList) {
for (const StringRef &Lib : LibsList)
addLibToList(Args.MakeArgString(Lib + ".bc"));
Expand Down Expand Up @@ -883,6 +883,9 @@ const char *SYCL::Linker::constructLLVMLinkCommand(
InputFilename.contains("libspirv") ||
InputFilename.contains("libdevice")))
return true;
if ((InputFilename.compare("libc.bc") == 0) &&
(FileName.find("spirv64-unknown-unknown") != std::string::npos))
return true;
StringRef LibSyclPrefix("libsycl-");
if (!InputFilename.starts_with(LibSyclPrefix) ||
!InputFilename.ends_with(LibPostfix))
Expand Down Expand Up @@ -1978,6 +1981,15 @@ SYCLToolChain::getDeviceLibs(
SmallVector<SmallString<128>, 4> LibraryPaths;
SYCLInstallation.getSYCLDeviceLibPath(LibraryPaths);

if (getTriple().isSPIROrSPIRV()) {
SmallVector<SmallString<128>, 4> OriginalLibraryPaths(LibraryPaths);
for (auto LP : OriginalLibraryPaths) {
SmallString<128> SPIRVLibraryPath(LP);
llvm::sys::path::append(SPIRVLibraryPath, "spirv64-unknown-unknown");
if (llvm::sys::fs::exists(SPIRVLibraryPath))
LibraryPaths.emplace_back(SPIRVLibraryPath);
}
}
// Formulate all of the device libraries needed for this compilation.
SmallVector<BitCodeLibraryInfo, 8> DeviceLibs =
getDeviceLibNames(getDriver(), DriverArgs, getTriple());
Expand Down
2 changes: 2 additions & 0 deletions libc/cmake/modules/LLVMLibCCompileOptionRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ function(_get_common_compile_options output_var flags)
endif()
elseif(LIBC_TARGET_ARCHITECTURE_IS_AMDGPU)
list(APPEND compile_options "SHELL:-Xclang -mcode-object-version=none")
elseif(LIBC_TARGET_ARCHITECTURE_IS_SPIRV)
list(APPEND compile_options "SHELL:-Xclang -fdefault-addr-space-is-generic")
endif()
endif()
set(${output_var} ${compile_options} PARENT_SCOPE)
Expand Down
47 changes: 46 additions & 1 deletion libc/cmake/modules/LLVMLibCLibraryRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ endfunction()
# A rule to build a library from a collection of entrypoint objects and bundle
# it in a single LLVM-IR bitcode file.
# Usage:
# add_bitcode_entrypoint_library(
# add_gpu_entrypoint_library(
# DEPENDS <list of add_entrypoint_object targets>
# )
function(add_bitcode_entrypoint_library target_name base_target_name)
Expand Down Expand Up @@ -119,6 +119,51 @@ function(add_bitcode_entrypoint_library target_name base_target_name)
add_dependencies(${base_target_name} ${target_name})
endfunction(add_bitcode_entrypoint_library)

# A rule to build a library from a collection of entrypoint objects and bundle
# it in a single LLVM-IR bitcode file with llvm-link
# Usage:
# link_bitcode_library(
# DEPENDS <list of add_entrypoint_object targets>
# )
function(link_bitcode_library target_name base_target_name output_name)
cmake_parse_arguments(
"ENTRYPOINT_LIBRARY"
"" # No optional arguments
"" # No single value arguments
"DEPENDS" # Multi-value arguments
${ARGN}
)
if(NOT ENTRYPOINT_LIBRARY_DEPENDS)
message(FATAL_ERROR "'link_bitcode_library' target requires a DEPENDS list "
"of 'add_entrypoint_object' targets.")
endif()

get_fq_deps_list(fq_deps_list ${ENTRYPOINT_LIBRARY_DEPENDS})
get_all_object_file_deps(all_deps "${fq_deps_list}")

set(objects "")
foreach(dep IN LISTS all_deps)
set(object $<$<STREQUAL:$<TARGET_NAME_IF_EXISTS:${dep}>,${dep}>:$<TARGET_OBJECTS:${dep}>>)
list(APPEND objects ${object})
endforeach()

find_program(LLVM_LINK_EXE
NAMES llvm-link
PATHS ${LLVM_TOOLS_BINARY_DIR}
NO_DEFAULT_PATH)
string(REPLACE ";" "\n" rsp_contents "${objects}")
file(GENERATE
OUTPUT ${CMAKE_BINARY_DIR}/${target_name}.rsp
CONTENT "${rsp_contents}")
if(LLVM_LINK_EXE)
set(bc_file ${CMAKE_BINARY_DIR}/libc/lib/${output_name})
add_custom_target(${target_name}
COMMAND ${LLVM_LINK_EXE} -o ${bc_file} @${CMAKE_BINARY_DIR}/${target_name}.rsp
DEPENDS ${objects})
add_dependencies(${base_target_name} ${target_name})
endif()
endfunction(link_bitcode_library)

# A rule to build a library from a collection of entrypoint objects.
# Usage:
# add_entrypoint_library(
Expand Down
80 changes: 54 additions & 26 deletions libc/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,37 @@ foreach(archive IN ZIP_LISTS
# Add the offloading version of the library for offloading languages. These
# are installed in the standard search path separate from the other libraries.
if(LIBC_TARGET_OS_IS_GPU)
add_bitcode_entrypoint_library(
${archive_1}bitcode
${archive_1}
DEPENDS
${${archive_2}}
)
set_target_properties(
${archive_1}bitcode
PROPERTIES
OUTPUT_NAME ${archive_1}.bc
)
if (NOT WIN32)
add_bitcode_entrypoint_library(
${archive_1}bitcode
${archive_1}
DEPENDS
${${archive_2}}
)
set_target_properties(
${archive_1}bitcode
PROPERTIES
OUTPUT_NAME ${archive_1}.bc
)
else()
link_bitcode_library(
${archive_1}bitcode
${archive_1}
${archive_1}.bc
DEPENDS
${${archive_2}}
)
set_target_properties(
${archive_1}bitcode
PROPERTIES
LINK_OUTPUT_NAME ${CMAKE_BINARY_DIR}/libc/lib/${archive_1}.bc
)
set_target_properties(
${archive_1}bitcode
PROPERTIES
OUTPUT_NAME ${archive_1}.bc
)
endif()
list(APPEND added_bitcode_targets ${archive_1}bitcode)
endif()
endforeach()
Expand All @@ -62,13 +82,23 @@ install(
COMPONENT libc
)

foreach(file ${added_bitcode_targets})
install(FILES $<TARGET_FILE:${file}>
DESTINATION ${LIBC_INSTALL_LIBRARY_DIR}
RENAME $<TARGET_PROPERTY:${file},OUTPUT_NAME>
COMPONENT libc
)
endforeach()
if(WIN32)
foreach(file ${added_bitcode_targets})
install(FILES $<TARGET_PROPERTY:${file},LINK_OUTPUT_NAME>
DESTINATION ${LIBC_INSTALL_LIBRARY_DIR}
RENAME $<TARGET_PROPERTY:${file},OUTPUT_NAME>
COMPONENT libc
)
endforeach()
else()
foreach(file ${added_bitcode_targets})
install(FILES $<TARGET_FILE:${file}>
DESTINATION ${LIBC_INSTALL_LIBRARY_DIR}
RENAME $<TARGET_PROPERTY:${file},OUTPUT_NAME>
COMPONENT libc
)
endforeach()
endif()

set(startup_target "")
if(LLVM_LIBC_FULL_BUILD AND NOT LIBC_TARGET_OS_IS_BAREMETAL)
Expand All @@ -83,19 +113,17 @@ if(LLVM_LIBC_FULL_BUILD)
set(header_install_target install-libc-headers)
endif()

set(install-libc-depends ${added_archive_targets} ${added_bitcode_targets} ${header_install_target})
if (NOT LIBC_TARGET_ARCHITECTURE_IS_SPIRV)
list(APPEND install-libc-depends ${startup_target})
endif()
add_custom_target(install-libc
DEPENDS ${added_archive_targets}
${added_bitcode_targets}
${startup_target}
${header_install_target}
DEPENDS ${install-libc-depends}
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=libc
-P "${CMAKE_BINARY_DIR}/cmake_install.cmake")
add_custom_target(install-libc-stripped
DEPENDS ${added_archive_targets}
${added_bitcode_targets}
${startup_target}
${header_install_target}
DEPENDS ${install-libc-depends}
COMMAND "${CMAKE_COMMAND}"
-DCMAKE_INSTALL_COMPONENT=libc
-DCMAKE_INSTALL_DO_STRIP=1
Expand Down
2 changes: 2 additions & 0 deletions libdevice/crt_wrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
__attribute__((weak)) DeviceGlobal<uint64_t[RAND_NEXT_LEN]> RandNext;

#ifdef __LIBDEVICE_TARGET_SUPPORT
#if defined(__NVPTX__) || defined(__AMDGCN__)
DEVICE_EXTERN_C_INLINE
void *memcpy(void *dest, const void *src, size_t n) {
return __devicelib_memcpy(dest, src, n);
Expand Down Expand Up @@ -84,6 +85,7 @@ int strncmp(const char *s1, const char *s2, size_t n) {

return s1[idx] - s2[idx];
}
#endif

// This simple rand is for ease of use only, the implementation aligns with
// LLVM libc rand which is based on xorshift64star pseudo random number
Expand Down
6 changes: 5 additions & 1 deletion sycl-jit/jit-compiler/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ set(SYCL_JIT_RESOURCE_INSTALL_COMPONENTS
sycl-headers
OpenCL-Headers
clang-resource-headers
libsycldevice)
libsycldevice
runtimes-spirv64-unknown-unknown)

set(libclc_enabled FALSE)
foreach(target IN LISTS LLVM_RUNTIME_TARGETS)
Expand Down Expand Up @@ -53,6 +54,9 @@ foreach(component IN LISTS SYCL_JIT_RESOURCE_INSTALL_COMPONENTS)
sycl_jit_add_install_command("${component}" "${CMAKE_BINARY_DIR}/runtimes/runtimes-${tgt}-bins/libclc")
endif()
endforeach()
elseif("${component}" STREQUAL "runtimes-spirv64-unknown-unknown")
list(APPEND SYCL_JIT_RESOURCE_DEPS runtimes-spirv64-unknown-unknown)
sycl_jit_add_install_command("libc" "${CMAKE_BINARY_DIR}/runtimes/runtimes-spirv64-unknown-unknown-bins/libc")
else()
list(APPEND SYCL_JIT_RESOURCE_DEPS ${component})
sycl_jit_add_install_command("${component}" "${CMAKE_BINARY_DIR}")
Expand Down
14 changes: 9 additions & 5 deletions sycl-jit/jit-compiler/lib/rtc/DeviceCompilation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -796,7 +796,7 @@ static void getDeviceLibraries(const ArgList &Args,
#if defined(_WIN32)
"libsycl-msvc-math",
#endif
"libsycl-imf"};
"libsycl-imf", "libc"};

StringRef LibSuffix = ".bc";
auto AddLibraries = [&](const SYCLDeviceLibsList &LibsList) {
Expand Down Expand Up @@ -850,10 +850,14 @@ Error jit_compiler::linkDeviceLibraries(llvm::Module &Module,
? "nvptx64-nvidia-cuda"
: "amdgcn-amd-amdhsa";

std::string LibPath =
(LibName.find("libspirv") != std::string::npos)
? (TC.getLibclcDir() + TripleName + "/" + LibName).str()
: (TC.getPrefix() + getLibPathSuffix() + LibName).str();
std::string LibPath;
if (LibName.find("libspirv") != std::string::npos)
LibPath = (TC.getLibclcDir() + TripleName + "/" + LibName).str();
else if (LibName == "libc.bc")
LibPath =
(TC.getPrefix() + "/lib/spirv64-unknown-unknown/" + LibName).str();
else
LibPath = (TC.getPrefix() + getLibPathSuffix() + LibName).str();

ModuleUPtr LibModule;
if (auto Error =
Expand Down
5 changes: 5 additions & 0 deletions sycl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,11 @@ if("lld" IN_LIST LLVM_ENABLE_PROJECTS)
list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS lld)
endif()

if ("libc" IN_LIST RUNTIMES_spirv64-unknown-unknown_LLVM_ENABLE_RUNTIMES)
add_dependencies(sycl-toolchain runtimes-spirv64-unknown-unknown)
list(APPEND SYCL_TOOLCHAIN_DEPLOY_COMPONENTS runtimes-spirv64-unknown-unknown)
endif()

set(libclc_enabled FALSE)
foreach(target IN LISTS LLVM_RUNTIME_TARGETS)
if("libclc" IN_LIST RUNTIMES_${target}_LLVM_ENABLE_RUNTIMES)
Expand Down
Loading