Skip to content

[NewOffloadModel] Add additional options for clang-sycl-linker#21692

Open
YixingZhang007 wants to merge 8 commits intointel:syclfrom
YixingZhang007:add_new_option_clang_sycl_linker
Open

[NewOffloadModel] Add additional options for clang-sycl-linker#21692
YixingZhang007 wants to merge 8 commits intointel:syclfrom
YixingZhang007:add_new_option_clang_sycl_linker

Conversation

@YixingZhang007
Copy link
Copy Markdown
Contributor

@YixingZhang007 YixingZhang007 commented Apr 7, 2026

This patch is part of the ongoing effort to migrate to clang-sycl-linker. It adds the support for new options required for clang-sycl-linker, where they will be used during the linking and backend compilation stages.
Specifically, the following changes are made:

  1. New options supported by clang-sycl-linker are defined in SYCLLinkOpts.td.
  2. In ClangLinkerWrapper.cpp, appendClangSYCLLinkerArgsis introduced to forward the required flags toclang-sycl-linkervia-XlinkerwhenUseClangSYCLLinkeris enabled.UseClangSYCLLinkeris a temporary guard that will be removed onceclang-sycl-linker` is fully supported.
  3. Updated to process arguments passed to clang and forward any -Xlinker arguments to clang-sycl-linker in SPIRV.cpp.

@dm-vodopyanov dm-vodopyanov changed the title [NewOffloadModel] Add additional options for clang-sycl-sinker [NewOffloadModel] Add additional options for clang-sycl-linker Apr 7, 2026
@YixingZhang007 YixingZhang007 added the new-offload-model Enables testing with NewOffloadModel. label Apr 7, 2026
@YixingZhang007 YixingZhang007 force-pushed the add_new_option_clang_sycl_linker branch from 4915195 to 81ce781 Compare April 7, 2026 14:29
@YixingZhang007 YixingZhang007 marked this pull request as ready for review April 7, 2026 14:35
@YixingZhang007 YixingZhang007 requested review from a team as code owners April 7, 2026 14:35
if (A->getOption().matches(options::OPT_Xlinker)) {
CmdArgs.push_back(A->getValue());
}
}
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.

Why is this needed? I'm seeing values of -Xlinker already being passed as expected.

clang++ --sycl-link --target=spirv64 -### a.o -Xlinker -blah
Intel SYCL compiler development build based on:
clang version 23.0.0git (https://github.com/mdtoguchi/llvm accf054)
Target: spirv64
Thread model: posix
InstalledDir: /localdisk2/mtoguchi/github/llvm/build/bin
Build config: +assertions
"clang-sycl-linker" "a.o" "-blah" "-o" "a.out"

};
for (auto [Opt, Flag] : SimpleFlags)
if (Args.hasArg(Opt))
XLinker(Flag);
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 looks like we have a bit of duplication of option names, etc, which would lead to a maintenance issue with any option name changes or even capturing new flags that need to be forwarded.

Leveraging the Args information would be beneficial here. A new 'Group' can be added for any of these options that need to be forwarded to the clang-sycl-linker. From there, check if an Arg is part of the group and then forward with render()

for (Arg *A : Args.filtered(options::OPT_sycl_Group))
  A->render(Args, CmdArgs);

@YixingZhang007 YixingZhang007 requested a review from maksimsab April 8, 2026 13:27
Copy link
Copy Markdown
Contributor

@elizabethandrews elizabethandrews left a comment

Choose a reason for hiding this comment

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

I am not familiar with this and defer to @mdtoguchi for review and approval.

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.

3 participants