Skip to content

[sycl][NewOffloadModel]Init commit for moving device-compiler handling to clang-sycl-linker.#22254

Open
bviyer wants to merge 5 commits into
syclfrom
bviyer-be-parsing-to-clang-sycl-ld
Open

[sycl][NewOffloadModel]Init commit for moving device-compiler handling to clang-sycl-linker.#22254
bviyer wants to merge 5 commits into
syclfrom
bviyer-be-parsing-to-clang-sycl-ld

Conversation

@bviyer

@bviyer bviyer commented Jun 8, 2026

Copy link
Copy Markdown
Contributor

--device-compiler handling is moved from clang to clang-sycl-linker.

For example, when the user passes the following flags into clang++ on a x86_64 host:

clang++ -fsycl --offload-new-driver -fsycl-targets=spir64_gen -Xsycl-target-backend=spir64_gen "-device pvc -DFOO" <file>.cpp

The clang-linker-wrapper will get the following:

clang-linker-wrapper" "--host-triple=x86_64-unknown-linux-gnu" "-sycl-device-library-location=<VALUE>" "--sycl-post-link-options=-O2 -device-globals" "--llvm-spirv-options=-spirv-max-version=1.5" "--device-compiler=sycl:spir64_gen-unknown-unknown=-device pvc -DFOO" " ...

NOTE: To avoid IP/Path leaks, certain fields - that are irrelevant for this discussion - are replaced with

@bviyer bviyer requested review from a team as code owners June 8, 2026 19:51
@bviyer bviyer force-pushed the bviyer-be-parsing-to-clang-sycl-ld branch from 933abbc to 5ef7006 Compare June 8, 2026 20:07
@bviyer bviyer force-pushed the bviyer-be-parsing-to-clang-sycl-ld branch from 8429b97 to a41ff48 Compare June 8, 2026 20:27
@bviyer bviyer requested a review from a team as a code owner June 8, 2026 21:07
Otherwise driver thinks these flags are unused.
@bviyer bviyer changed the title Init commit for moving device-compiler handling to clang-sycl-linker. [sycl][NewOffloadModel]Init commit for moving device-compiler handling to clang-sycl-linker. Jun 9, 2026
@bviyer bviyer added the new-offload-model Enables testing with NewOffloadModel. label Jun 9, 2026
before using its value in the range-based for.
I think this is the cause of an issue in windows
CI.
@YuriPlyakhin

Copy link
Copy Markdown
Contributor

pls, use SYCL - all capital letters in PR title.

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

It seems some CI failures are related to this PR, could you please check?

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

We don't want to support -fsycl-targets=spir64_gen in clang driver for new offloading model. Could you please update PR description and PR itself, if needed.

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

I'm a bit confused by PR title and description.
Title says that this PR is about moving of device-compiler handling to clang-sycl-linker. Yet, in PR description, it highlights what will be passed to clang-linker-wrapper and says nothing about clang-sycl-linker.
Could you please clarify?

SYCLTC.TranslateBackendTargetArgs(TC->getTriple(), Args, BuildArgs);
for (const auto &A : BuildArgs)
appendOption(BackendOptString, A);
const llvm::Triple &TCTriple = TC->getTriple();

@YuriPlyakhin YuriPlyakhin Jun 10, 2026

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.

Could you please add to PR description some summary, of what this change to clang.cpp is achieving?
maybe "before" and "after" states.
Also, if the behavior of clang driver is changed, I would expect some lit test changes required. Probably some new driver tests should be added?

#include "clang/Driver/CommonArgs.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Options/Options.h"

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.

It seems quite a lot of things are happening in this PR.
Is it possible to split it into smaller chunks (for example separate refactoring from functional changes or split changes to different tools into different PRs if it makes sense)?
Could you please add a bit more details into description for each meaningful change.
And I see a lot of changes in SYCL.cpp, but no driver tests affected. Is it solely NFC refactoring or do we just have a gap in our testing?

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

And maybe the most important feedback:
could you please provide design doc or something that would explain what we want to achieve by this move? What's the current state, why it is a problem and what we will have as a result of this move. And how it aligns SYCL with how device-compiler and device-linker options are handled for other programming models and targets in clang-linker-wrapper in upstream LLVM.
Maybe such document already exists, but I don't remember from the top of my head.

; Test that IMG_Object image kind is set for AOT compilation (Intel CPU).
; RUN: llvm-objdump --offloading %t/aot-cpu.out | FileCheck %s --check-prefix=IMAGE-KIND-OBJECT
;
; --device-compiler=[<kind>:][<triple>=]<value> reaches ocloc only when the

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.

hmm, I thought the plan was to use ocloc_options_EQ for that in clang-sycl-linker.
But I guess this confusion is related to my previous comment about need for some design doc that would explain the direction we are trying to achieve by this pr.

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.

2 participants