[SYCL] Forward AOT backend/linker options as individual tokens#22645
Open
bader wants to merge 9 commits into
Open
[SYCL] Forward AOT backend/linker options as individual tokens#22645bader wants to merge 9 commits into
bader wants to merge 9 commits into
Conversation
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.
Contributor
There was a problem hiding this comment.
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-wrapperand append them directly toocloc/opencl-aotargv (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; | ||
| } | ||
| } |
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
marked this pull request as ready for review
July 16, 2026 00:26
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.