Skip to content

[SYCL][clang-linker-wrapper] Wrap all architectures in one module for -fno-sycl-rdc - #23492

Merged
uditagarwal97 merged 8 commits into
intel:syclfrom
srividya-sundaram:sycl-linker-wrapper-nordc-multi-arch
Oct 20, 2026
Merged

uditagarwal97 merged 8 commits into
intel:syclfrom
srividya-sundaram:sycl-linker-wrapper-nordc-multi-arch

Conversation

@srividya-sundaram

@srividya-sundaram srividya-sundaram commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #23488.

With the new offloading model, -fno-sycl-rdc -c for several architectures of one triple (e.g. -fsycl-targets=intel_gpu_pvc,intel_gpu_dg2) failed with "Expect single output from the SYCL device linker", because each architecture's device image was put into its own offload wrapper module.

clang-linker-wrapper now puts all architectures' images into one wrapper module, which the host compilation embeds. All images in a wrapper module are labeled with one target triple, so SYCL inputs with different triples are now diagnosed before any device compilation. The driver already rejects that case; supporting it is tracked in #23526.

New E2E test AOT/early_aot_multi_arch.cpp builds a -fno-sycl-rdc -c object for two GPUs and runs it, checking that the runtime picks the right image.

Split out of #23441, whose tests need it.

… -fno-sycl-rdc

The -fno-sycl-rdc compile step (--emit-fatbin-only) wrapped the images of
each target group separately and then expected a single output, so a
compile for several architectures of one triple, e.g.
-fsycl-targets=intel_gpu_pvc,intel_gpu_dg2, failed with "Expect single
output from the SYCL device linker".

Collect the images of all groups and wrap them into a single wrapper module,
as is done for the other offload kinds. The per-architecture information,
such as the compile_target, is carried by each image. Inputs with different
target triples, which the driver already rejects with -fno-sycl-rdc, are
diagnosed rather than labelled with one triple.
@srividya-sundaram srividya-sundaram added the new-offload-model Enables testing with NewOffloadModel. label Oct 14, 2026

@iclsrc iclsrc left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This PR changes the -fno-sycl-rdc compile step so the modules from all architecture groups are wrapped into one wrapper module, not one module per group. The wrapping now happens after the parallel loop. Modules are collected per input group, so their order is stable, and mixed target triples are rejected. Overall the logic looks sound. I found no critical issues, only two minor points below.

Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated

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.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

4 open findings
What changed in this PR

Updates clang-linker-wrapper’s SYCL --no-sycl-rdc flow to wrap multiple architecture images into a single wrapper module, avoiding “Expect single output from the SYCL device linker” failures for multi-arch inputs.

Changes:

  • Defer --no-sycl-rdc wrapping until all inputs are processed, then emit a single wrapper module across architectures.
  • Add a diagnostic for mixed SYCL target triples under --no-sycl-rdc.
  • Extend the test suite to cover multi-architecture wrapping and mixed-triple rejection.
File Description
clang/​tools/​clang-linker-wrapper/​ClangLinkerWrapper.cpp Defers --no-sycl-rdc wrapping, aggregates modules across architectures, and enforces single target triple.
clang/​test/​OffloadTools/​clang-linker-wrapper/​linker-wrapper-sycl.cpp Adds coverage for multi-arch single-wrapper emission and mixed-triple error behavior.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
Comment thread clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper-sycl.cpp Outdated
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
Also diagnose a missing triple, use a dedicated mutex and explain why the
global arguments are used for wrapping.
@srividya-sundaram

Copy link
Copy Markdown
Contributor Author

The Windows BMG failure is unrelated to this PR.

@srividya-sundaram
srividya-sundaram marked this pull request as ready for review October 15, 2026 02:08
@srividya-sundaram
srividya-sundaram requested a review from a team as a code owner October 15, 2026 02:08

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

sorry, i dont really understand this change so i think we will need to wait for yury

Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
@YuriPlyakhin

Copy link
Copy Markdown
Contributor

Inputs with different triples, which the driver already rejects with -fno-sycl-rdc, are diagnosed

Does it match old offload model behavior?

@YuriPlyakhin

YuriPlyakhin commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Do we have SYCL E2E test that would demonstrate that no-rdc fat binary (2 architectures, e.g. "" and "pvc" or something) works end to end (compilation + runtime)?

My concern is that without runtime check, we can easily write anything into wrapper, and nobody catches that wrapper is incorrect.

Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
Comment thread clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper-sycl.cpp Outdated
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
Collect the per-group modules without a lock, make the target triple a
required argument of wrapSYCLBinariesFromFile, and check in the test that
the images of both architectures reach the one wrapper module.
@srividya-sundaram

Copy link
Copy Markdown
Contributor Author

Does it match old offload model behavior?

No. The old model accepts it: it runs one clang-offload-wrapper per triple (Clang.cpp).
The new model has one clang-linker-wrapper job per TU, which writes one wrapper module for one triple, so the driver already rejects multiple triples with -fno-sycl-rdc (Driver.cpp).
This PR keeps that restriction; the wrapper check only reports it clearly for direct clang-linker-wrapper runs.

@YuriPlyakhin

Copy link
Copy Markdown
Contributor

Does it match old offload model behavior?

No. The old model accepts it: it runs one clang-offload-wrapper per triple (Clang.cpp). The new model has one clang-linker-wrapper job per TU, which writes one wrapper module for one triple, so the driver already rejects multiple triples with -fno-sycl-rdc (Driver.cpp). This PR keeps that restriction; the wrapper check only reports it clearly for direct clang-linker-wrapper runs.

It means, this PR is not final then for no-rdc in new offload model. Please, submit issue to enable multiple triples.

@srividya-sundaram

Copy link
Copy Markdown
Contributor Author

It means, this PR is not final then for no-rdc in new offload model. Please, submit issue to enable multiple triples.

Opened #23526 to support multiple triples with -fno-sycl-rdc in the new offloading model.
Also encountered another bug while testing this: #23527

@srividya-sundaram

Copy link
Copy Markdown
Contributor Author

CI failures are unrelated to this PR.

@srividya-sundaram

Copy link
Copy Markdown
Contributor Author

Please, submit issue to enable multiple triples.

Do we have SYCL E2E test that would demonstrate that no-rdc fat binary (2 architectures, e.g. "" and "pvc" or something) works end to end (compilation + runtime)?

My concern is that without runtime check, we can easily write anything into wrapper, and nobody catches that wrapper is incorrect.

Added AOT/early_aot_multi_arch.cpp

srividya-sundaram added a commit to srividya-sundaram/llvm that referenced this pull request Oct 19, 2026
The bundler, runtime and sanitizer library fixes have landed in sycl
(intel#23491, intel#23493, intel#23494), so their copies are dropped here. The linker
wrapper fix is updated to the version in intel#23492.
@YuriPlyakhin

Copy link
Copy Markdown
Contributor

CI failures are unrelated to this PR.

@srividya-sundaram , are there github issues for those failures? If not, could you please file them?

Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Outdated
@srividya-sundaram

Copy link
Copy Markdown
Contributor Author

@srividya-sundaram , are there github issues for those failures? If not, could you please file them?

#22293

CI failures are unrelated to this PR.

@srividya-sundaram , are there github issues for those failures? If not, could you please file them?

#22293 is already filed for WorkGroupMemory/basic_usage.cpp on Intel Arc With Level 0 Windows

Comment thread clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Comment thread sycl/test-e2e/AOT/early_aot_multi_arch.cpp Outdated

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

Other than few nits, LGTM. Thanks!

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

no flags from me but my review is not worth much here :P

Without -fsycl, the Windows link uses the static C runtime, but the object
was compiled for the dynamic one (__imp__wassert is unresolved).
Comment thread sycl/test-e2e/AOT/early_aot_multi_arch.cpp
@uditagarwal97
uditagarwal97 merged commit 077c40d into intel:sycl Oct 20, 2026
33 of 36 checks passed
srividya-sundaram added a commit to srividya-sundaram/llvm that referenced this pull request Oct 20, 2026
The linker wrapper fix has landed in sycl (intel#23492), so its copy is
dropped here.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

new-offload-model Enables testing with NewOffloadModel.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[SYCL][NewOffloadModel] -fno-sycl-rdc fails with several intel_gpu_* targets: "Expect single output from the SYCL device linker"

6 participants