Skip to content

[SYCL] Forward AOT backend/linker options as individual tokens#22645

Open
bader wants to merge 9 commits into
intel:syclfrom
bader:sycl-aot-token-fix
Open

[SYCL] Forward AOT backend/linker options as individual tokens#22645
bader wants to merge 9 commits into
intel:syclfrom
bader:sycl-aot-token-fix

Conversation

@bader

@bader bader commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Route -Xsycl-target-backend and -Xsycl-target-linker options through
--device-compiler=/--device-linker= uniformly for JIT and AOT SYCL
targets, one flag per token instead of joining tokens into a single
string. clang-linker-wrapper now keeps CLI-supplied AOT options as a
token list end-to-end and appends them to ocloc/opencl-aot argv
individually, avoiding a lossy re-split of values with embedded
spaces. JIT targets keep the existing string-joining behavior for the
image's compile-opts/link-opts properties.

bader added 2 commits July 15, 2026 10:14
Route -Xsycl-target-backend and -Xsycl-target-linker options through
--device-compiler=/--device-linker= uniformly for JIT and AOT SYCL
targets, one flag per token instead of joining tokens into a single
string. clang-linker-wrapper now keeps CLI-supplied AOT options as a
token list end-to-end and appends them to ocloc/opencl-aot argv
individually, avoiding a lossy re-split of values with embedded
spaces. JIT targets keep the existing string-joining behavior for the
image's compile-opts/link-opts properties.

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 adjusts SYCL option forwarding so that -Xsycl-target-backend / -Xsycl-target-linker are forwarded to clang-linker-wrapper as one --device-compiler= / --device-linker= flag per token (instead of joining tokens into a single space-separated string), and updates clang-linker-wrapper to preserve and forward those tokens end-to-end for AOT backends.

Changes:

  • Emit one --device-compiler=...=<token> / --device-linker=...=<token> per translated SYCL backend/link option in the driver.
  • Keep CLI-supplied AOT options as a token list in clang-linker-wrapper and append them directly to ocloc / opencl-aot argv (avoiding lossy re-splitting).
  • Update driver/wrapper tests to reflect the new per-token forwarding behavior (including AOT coverage).

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
clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp Thread AOT device args as token lists through the SYCL pipeline and append to AOT tool invocations.
clang/lib/Driver/ToolChains/Clang.cpp Forward SYCL backend/linker options to clang-linker-wrapper as one flag per token.
clang/test/Driver/sycl-offload.cpp Update checks to expect per-token --device-compiler/--device-linker forwarding.
clang/test/Driver/sycl-offload-new-driver.cpp Add coverage ensuring AOT targets also forward backend/linker options as separate tokens.
clang/test/Driver/clang-linker-wrapper.cpp Extend wrapper tests for split -device reconstruction and multi-arg AOT option forwarding.

Comment on lines +1939 to +1947
std::string AOTOptions;
if (Triple.isSPIRAOT()) {
AOTOptions = CompileLinkOptions.first;
if (!CompileLinkOptions.second.empty()) {
if (!AOTOptions.empty())
AOTOptions += ' ';
AOTOptions += CompileLinkOptions.second;
}
}
bader added 7 commits July 15, 2026 15:46
Update the CHK-NO-CMDS-AOT-GEN-LINKERARG test to assert on the actual
ocloc invocation instead of an unrelated sycl-post-link line, matching
the new one-CLI-token-equals-one-argv-entry contract for
--device-compiler=/--device-linker=. Remove CHK-NO-CMDS-AOT-GEN (relied
on a single-token "-device pvc" CLI value that is no longer split, and
is unreachable via the real driver since -Xsycl-target-backend already
tokenizes it into separate flags) and CHK-MULTI-DEVICE-LINKER-AOT
(duplicated the same reconstruction behavior as the fixed test).
-Xsycl-target-backend/-Xsycl-target-linker require the driver and
clang-linker-wrapper to parse and re-serialize ocloc's own option
syntax (e.g. the literal "-options " split in addOclocOptions), which
is fragile — appended link-opts can be silently absorbed into the
-options value. Note the deprecation/removal of these options as a
follow-up to avoid this class of parsing entirely.
Add a comment cross-referencing Driver::getOffloadArchs, which performs
a similar "-device" token detection on the driver side for spir64_gen
Arch selection, so a future edit to either detector's handling of
-Xsycl-target-backend syntax prompts a check of the other.
…Module

Triple parsing, AOTOptions/BackendOptions derivation, and the
-device detection in IsDevicePassedWithSyclTargetBackend were
recomputed on every call to postLinkProcessModule, even though the
value is identical across all split modules sharing a triple. Moved
the computation up to runSYCLOffloadingPipeline, which now computes
it once before looping over Modules and passes the results down.
invokeBackendForSYCLDevice and compileDeviceAndBundle are single-caller
helpers whose only call sites already pass AOTDeviceArgs explicitly, so
the `= {}` defaults were unreachable and misleadingly implied some
caller omits the argument.
BuildArgs is joined into a single space-separated compile-opts=/link-opts=
string before being embedded in the offload image, then later re-split on
spaces by clang-linker-wrapper for AOT triples. This corrupts any token
containing an embedded space unless it happens to fall inside the
pre-existing "-options \"...\"" wrapper convention. The CLI-supplied
counterpart (--device-compiler=/--device-linker=) already avoids this by
forwarding individual tokens via AOTDeviceArgs.
linkAndWrapDeviceFiles() and runSYCLOffloadingPipeline() each decide
independently whether CLI-supplied AOT options go through the token
vector or the flat-string path, with nothing enforcing the two
isSPIRAOT() checks stay in agreement.
@bader
bader marked this pull request as ready for review July 16, 2026 00:26
@bader
bader requested review from a team as code owners July 16, 2026 00:26
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.

2 participants