Skip to content

[SYCL] [ClangSYCLLinker] Add full sycl-post-link functionality to clang-sycl-linker#21977

Draft
srividya-sundaram wants to merge 5 commits into
intel:syclfrom
srividya-sundaram:move-device-linking-to-csl
Draft

[SYCL] [ClangSYCLLinker] Add full sycl-post-link functionality to clang-sycl-linker#21977
srividya-sundaram wants to merge 5 commits into
intel:syclfrom
srividya-sundaram:move-device-linking-to-csl

Conversation

@srividya-sundaram
Copy link
Copy Markdown
Contributor

@srividya-sundaram srividya-sundaram commented May 8, 2026

This is patch number 2 in the SYCL Device Pipeline migration from clang-linker-wrapper to clang-sycl-linker
Patch number 1 can be found here.

This PR adds full sycl-post-link functionality to clang-sycl-linker with 100% feature parity to clang-linker-wrapper, advancing the new SYCL offload model migration.

Changes:

  • Implemented 4 core functions: getSYCLPostLinkSettings(), getTripleBasedSYCLPostLinkOpts(), runSYCLPostLinkTool(), and runSYCLPostLinkLibrary()
  • Added 14 command-line options for controlling module splitting, ESIMD handling, specialization constants, entry point optimization, thin LTO, and device libraries
  • Supports both tool mode (external sycl-post-link executable) and library mode (direct API) with configurable module split modes (kernel, source, auto, none)
  • Triple-specific configurations for Intel GPU, Intel CPU, NVIDIA, AMD, and NativeCPU targets
  • Added 32 comprehensive test cases covering all options, functions, and execution paths
  • All 131 SYCL driver tests pass with no regressions

Note: sycl-post-link logic remains in clang-linker-wrapper for now during the offload model migration.

@srividya-sundaram
Copy link
Copy Markdown
Contributor Author

@YuriPlyakhin @maksimsab Could you please take a look at this first-pass patch for adding sycl-post-link support/infrastructure in clang-sycl-linker tool. Thanks!

// and inter-image symbol export. Without setting it here, ESIMD processing
// silently ignores the flag and always behaves as if device-image
// dependencies are disallowed.
Settings.ESIMDOptions.AllowDeviceImageDependencies =
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This seemed like a bug. Please weigh in.

For context:
--sycl-allow-device-image-dependencies was correctly preventing EmitOnlyKernelsAsEntryPoints from being set, but ESIMDOptions.AllowDeviceImageDependencies was never set.
This meant ESIMD processing (module cleanup, dependency graph construction, symbol export decisions) always behaved as if device image dependencies were disallowed, even when the user passed --sycl-allow-device-image-dependencies. The wrong behavior would be silent, no error, just subtly incorrect ESIMD output.

The fix was:
Add Settings.ESIMDOptions.AllowDeviceImageDependencies = Args.hasArg(OPT_sycl_allow_device_image_dependencies) in both clang-sycl-linker and clang-linker-wrapper. The pre-existing TODO comment in clang-linker-wrapper was tracking this missing piece

@YuriPlyakhin
Copy link
Copy Markdown
Contributor

@YuriPlyakhin @maksimsab Could you please take a look at this first-pass patch for adding sycl-post-link support/infrastructure in clang-sycl-linker tool. Thanks!

@srividya-sundaram ,
please take a look at these patches in community:
llvm/llvm-project#195362
llvm/llvm-project#197571

would it be possible to align this patch design to what we are doing in community as much as possible?


/// Run sycl-post-link tool for SYCL offloading.
static Expected<std::vector<SplitModule>>
runSYCLPostLinkTool(ArrayRef<StringRef> InputFiles, const ArgList &Args,
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.

Do we need to bring SYCLPostLinkTool to clang-sycl-linker at all?
I thought the idea was to get rid of sycl-post-link-tool in new offloading model and use library instead, if necessary.

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