Skip to content

[SYCL][libc] Enable spirv64 libc for SYCL device code - #23622

Open
jinge90 wants to merge 8 commits into
intel:syclfrom
jinge90:enable_spirv64_libc_for_sycl
Open

jinge90 wants to merge 8 commits into
intel:syclfrom
jinge90:enable_spirv64_libc_for_sycl

Conversation

@jinge90

@jinge90 jinge90 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

This PR enables LLVM libc for spirv64 target in SYCL compiler, we also remove all string functions provided by libdevice and use the ones from libc instead.

Signed-off-by: jinge90 <ge.jin@intel.com>
Signed-off-by: Jin <ge.jin@intel.com>
@jinge90
jinge90 requested review from a team, bader and cperkinsintel as code owners October 26, 2026 06:34
@jinge90
jinge90 marked this pull request as draft October 26, 2026 06:34
@jinge90
jinge90 requested a balanced review from Copilot October 26, 2026 06:37

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Unresolved deployment, library-path, runtime-dependency, and fallback-availability regressions can leave supported configurations without required device libraries.

5 open issues
What changed in this PR

This PR integrates spirv64 LLVM libc into SYCL device compilation, deployment, and runtime compilation, replacing selected libdevice string and memory implementations.

Changes:

  • Enable libc in spirv64 runtime builds and package it with the SYCL toolchain and JIT resources.
  • Add libc discovery and linking to both driver models and runtime compilation.
  • Disable SPIR/SPIR-V fallback implementations and update driver test expectations.
File Description
sycl/​CMakeLists.txt Add libc build dependencies and deployment handling.
sycl-jit/​jit-compiler/​lib/​rtc/​DeviceCompilation.cpp Locate and link libc during runtime compilation.
sycl-jit/​jit-compiler/​CMakeLists.txt Include libc in embedded JIT resources.
libdevice/​fallback-cstring.hpp Exclude fallback helpers for SPIR/SPIR-V.
libdevice/​crt_wrapper.cpp Exclude string and memory wrappers for SPIR/SPIR-V.
libc/​cmake/​modules/​LLVMLibCCompileOptionRules.cmake Enable generic default address space for SPIR-V libc.
clang/​test/​Driver/​sycl-no-rdc-win.cpp Update Windows compilation phases for libc linking.
clang/​test/​Driver/​sycl-no-rdc-old-model.cpp Update old-model compilation phases for libc linking.
clang/​test/​Driver/​sycl-device-lib.cpp Check libc linking with the new driver.
clang/​test/​Driver/​sycl-device-lib-win.cpp Check Windows device-library linking includes libc.
clang/​test/​Driver/​sycl-device-lib-old-model.cpp Check old-model libc linking, including sanitizer cases.
clang/​test/​Driver/​Inputs/​SYCL/​lib/​spirv64-unknown-unknown/​libc.bc Add a libc discovery fixture.
clang/​lib/​Driver/​ToolChains/​SYCL.cpp Discover libc and recognize it as a device library.
clang/​lib/​Driver/​ToolChain.cpp Add spirv64 runtime-directory fallback lookup.
clang/​lib/​Driver/​Driver.cpp Add libc selection to the old offload driver.
buildbot/​configure.py Enable libc in non-Darwin spirv64 runtime builds.

Review effort: Balanced

Comment thread libdevice/crt_wrapper.cpp

#ifdef __LIBDEVICE_TARGET_SUPPORT

#if !defined(__SPIR__) && !defined(__SPIRV__)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will always build libc for spirv64 and only support spir64.

Comment thread sycl/CMakeLists.txt Resolved
Comment on lines +6173 to +6175
if (std::optional<std::string> StdlibPath = TC->getStdlibPath()) {
LinkDeviceLibc = true;
LibLocCandidates.emplace_back(*StdlibPath);
Comment on lines +46 to +48
foreach(tgt IN LISTS libc_targets)
list(APPEND SYCL_JIT_RESOURCE_INSTALL_COMPONENTS libc)
endforeach()
jit_compiler::resource::ToolchainPrefix.Size};
std::string ClangXXExe = (Prefix + "/bin/clang++").str();
std::string LibclcDir = GetResourcesPath(ClangXXExe) + "/lib/";
std::string StdlibPathBase = (Prefix + "/lib/").str();
jinge90 and others added 2 commits October 26, 2026 15:22
…ibclc installation'

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: jinge90 <ge.jin@intel.com>
@sarnex

sarnex commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

please ping me when this is ready for review, thanks :)

@jinge90
jinge90 marked this pull request as ready for review November 3, 2026 03:28
@jinge90

jinge90 commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Hi, @sarnex @bader @mdtoguchi @srividya-sundaram
Could you help review this PR?
Thanks very much.

getDriver().Diag(diag::err_drv_no_sycl_device_lib) << DeviceLib.Path;
}

// Link deivce libc for spirv64 target.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo *device

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants