Skip to content

[SYCL][NewOffloadModel] Enable -fno-sycl-rdc in Clang Driver for New Offload Model - #22832

Merged
sarnex merged 5 commits into
intel:syclfrom
srividya-sundaram:sycl-no-rdc-compile
Jul 31, 2026
Merged

[SYCL][NewOffloadModel] Enable -fno-sycl-rdc in Clang Driver for New Offload Model#22832
sarnex merged 5 commits into
intel:syclfrom
srividya-sundaram:sycl-no-rdc-compile

Conversation

@srividya-sundaram

@srividya-sundaram srividya-sundaram commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Summary

This patch adds -fno-sycl-rdc support to the new SYCL offload model in the Clang driver. It is based on the work by @maksimsab in #21973, with review fixes applied.

What this patch does

By default (-fsycl-rdc), all device code across translation units is linked together into one module at link time before post-link processing. With -fno-sycl-rdc, each object file's device code is processed independently — skipping the llvm-link step — which can significantly reduce peak memory and compile time.

Changes:

  • clang/lib/Driver/ToolChains/Clang.cpp: In LinkerWrapper::ConstructJob, propagate --no-sycl-rdc to clang-linker-wrapper when -fno-sycl-rdc is passed at link time.
  • sycl/doc/design/OffloadDesign.md: Document NoRDC mode for the new offload model.
  • sycl/doc/design/NonRelocatableDeviceCode.md: Add a note clarifying that document covers the old offload model only.
  • sycl/test-e2e/AOT/early_aot.cpp: Un-XFAIL the test for the new offload model; adjust RUN lines to pass -fno-sycl-rdc at the correct step per model.
  • clang/test/Driver/sycl-no-rdc-new-driver.cpp: New driver test verifying --no-sycl-rdc is propagated to clang-linker-wrapper correctly.

Key behavioral difference from the old offload model

Model Where to pass -fno-sycl-rdc
Old (--no-offload-new-driver) At each compile step (-c)
New (--offload-new-driver) At the link step

This inversion exists because in the new model all SYCL offload processing (post-link, AOT, wrapping) lives in clang-linker-wrapper at link time.

Follow-up work

Supporting -fno-sycl-rdc -c in the new model (matching the old model's compile-step ergonomics) will be addressed in a follow-up patch. The plan is to invoke clang-linker-wrapper --sycl-device-link --no-sycl-rdc per translation unit at compile time, embedding the finalized device image directly into the host object.

Supporting -fno-sycl-rdc -c in the new model (matching old model compile-step ergonomics) is addressed in #22833.

Fixes: CMPLRLLVM-51875

🤖 Generated with Claude Code

maksimsab and others added 3 commits July 30, 2026 13:44
Fix --no-offload-old-driver typo to --no-offload-new-driver in the
old offload model usage example. Add a note that compile-step support
for -fno-sycl-rdc (matching the old model's -c usage pattern) will
be implemented in a follow-up patch via clang-linker-wrapper
--sycl-device-link --no-sycl-rdc per translation unit.

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.

Pull request overview

This PR enables -fno-sycl-rdc support for the new SYCL offload model by propagating the flag at link time to clang-linker-wrapper, updates the related design documentation, and adjusts/extends tests to validate the new behavior.

Changes:

  • Propagate NoRDC to clang-linker-wrapper from the Clang driver when linking SYCL with the new offload model.
  • Document NoRDC behavior and clarify old-vs-new offload model flag placement (compile step vs link step).
  • Update/add tests to reflect the new model’s link-step -fno-sycl-rdc usage and verify driver propagation.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
sycl/test-e2e/AOT/early_aot.cpp Un-XFAIL for new offload model and adjust RUN lines to pass -fno-sycl-rdc at the correct step per model.
sycl/doc/design/OffloadDesign.md Document NoRDC support and explicitly describe the old vs new model usage inversion.
sycl/doc/design/NonRelocatableDeviceCode.md Clarify the document applies to the old offload model’s NoRDC design.
clang/test/Driver/sycl-no-rdc-new-driver.cpp Add driver coverage ensuring --no-sycl-rdc is propagated to clang-linker-wrapper for --offload-new-driver.
clang/lib/Driver/ToolChains/Clang.cpp Driver change to translate -fno-sycl-rdc into --no-sycl-rdc for clang-linker-wrapper in SYCL link jobs.

Comment thread clang/lib/Driver/ToolChains/Clang.cpp Outdated
@srividya-sundaram

Copy link
Copy Markdown
Contributor Author

The build_run_native_cpu_e2e_tests failure is unrelated to this PR. SYCL :: KernelParams/has-special-captures.cpp has XFAIL: native_cpu (tracked via #20127) but the underlying issue seems to be fixed, so the test now unexpectedly passes. This needs a separate cleanup PR to remove the stale XFAIL marker and is un-related to the changes in this PR.

Comment thread clang/test/Driver/sycl-no-rdc-new-driver.cpp Outdated
Comment thread sycl/doc/design/OffloadDesign.md Outdated
Comment thread sycl/test-e2e/AOT/early_aot.cpp Outdated

@sarnex sarnex 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.

lgtm just some nits

Comment thread sycl/test-e2e/AOT/early_aot.cpp Outdated
Comment thread clang/lib/Driver/ToolChains/Clang.cpp
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sarnex

sarnex commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

lgtm thx

@sarnex
sarnex merged commit 05bbca4 into intel:sycl Jul 31, 2026
29 of 32 checks passed
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.

5 participants