Skip to content

[SYCL] Avoid runtime registration for empty device pre-link outputs - #23545

Open
vishalshetagar wants to merge 5 commits into
intel:syclfrom
vishalshetagar:fix/23528-sycl-link-empty-images
Open

vishalshetagar wants to merge 5 commits into
intel:syclfrom
vishalshetagar:fix/23528-sycl-link-empty-images

Conversation

@vishalshetagar

@vishalshetagar vishalshetagar commented Oct 19, 2026 •

Copy link
Copy Markdown

-fsycl-link emits SYCL runtime registration references even when there are no device images to register. This prevents host-only and kernel-free configurations from linking with a host linker unless they also link the SYCL runtime.

This change makes both the old and new offload driver paths produce the required output object without references to __sycl_register_lib or __sycl_unregister_lib when there are no device images or all images are empty.

  • Skip registration for empty image sets in both offload wrappers.
  • Omit empty device modules from post-link image tables in both the tool and library implementations.
  • Produce an empty object when the new driver's device pre-link step has no device inputs.
  • Preserve registration for nonempty images, mixed empty/nonempty inputs, and NativeCPU placeholders.
  • Preserve the required non-RDC container after empty-image filtering in the upstream flow that now performs wrapping during host compilation. Add an empty placeholder only when the combined image set is empty.

Extend existing regression tests for empty inputs, mixed targets, ELF/COFF wrapping, and host linking without the SYCL runtime. Fixtures whose section, registration, or missing-ocloc checks require a nonempty image use real kernels with integration-header inclusion disabled.

Validation after merging upstream 55a172cc383c:

  • 139 focused regression tests passed: seven relevant Clang tests and the complete llvm/test/tools/sycl-post-link suite. Clang and the affected tools were rebuilt in WSL with assertions enabled; auxiliary tools and device libraries came from the matching upstream CI toolchain.
  • Both driver paths passed Linux executable and shared-library linking without the SYCL runtime for host-only and kernel-free pre-link inputs. Executables ran successfully. Empty non-RDC inputs also passed; nonempty kernel inputs retained registration references.
  • All 12 additional shared-wrapper checks passed across ELF and COFF, including mixed images and NativeCPU placeholders.
  • Eight Windows executable cases linked with Microsoft's linker and ran; eight DLLs linked, loaded, and executed a test function without the SYCL runtime. Two nonempty-image controls correctly failed to link without the runtime. The empty non-RDC case used -nolibsycl.
  • The new empty-container regression reproduced the missing-output failure before the follow-up fix and passed afterward. Formatting and whitespace checks passed.

Windows objects were generated by the rebuilt tools in WSL; linking and execution were native Windows. The compiler tools were not built natively on Windows.

The previously observed GPU E2E failures remain outside this fix:

These hardware-dependent failures were not changed or validated locally on Intel GPU hardware.

Fixes #23528.

When -fsycl-link has no device images or only empty images, emit the
required output object without references to __sycl_register_lib or
__sycl_unregister_lib. This allows a host linker to link host-only and
kernel-free configurations without the SYCL runtime.

Handle empty images in both offload wrappers, omit empty modules from
post-link image tables, and generate an empty object when the new driver
has no device-link outputs. Preserve registration for nonempty images
and NativeCPU placeholders.

Extend existing regression tests for empty and mixed images, host-only
inputs, and empty modules through both post-link implementations.

Fixes intel#23528

Assisted-by: OpenAI Codex
@vishalshetagar
vishalshetagar requested review from a team as code owners October 19, 2026 19:22
Copilot AI balanced review requested due to automatic review settings October 19, 2026 19:22

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.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Give the non-RDC wrapper and linker-wrapper command tests a kernel so
post-link processing retains an image. Empty sources now correctly omit
images and registration, so they cannot exercise image sections or the
missing-ocloc diagnostic.

Disable integration-header inclusion to keep these standalone fixtures
independent of installed SYCL headers and host C++ libraries. Extend the
non-RDC test to check that empty ELF and COFF objects contain no embedded
device image or SYCL registration references.

Reproduced both original failures with the PR's CI-built compiler. The
updated tests pass, along with the surrounding SYCL driver, wrapper, and
post-link tests: 294 passed, 3 expected failures, 15 unsupported, and no
unexpected failures.

Assisted-by: OpenAI Codex
@sarnex

sarnex commented Oct 21, 2026

Copy link
Copy Markdown
Contributor

@vishalshetagar Looks like the PR needs to be merged with HEAD since there are merge conflicts, could you take a look? Thanks

…mpty-images

# Conflicts:
#	clang/test/OffloadTools/clang-linker-wrapper/linker-wrapper-sycl.cpp
#	clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
…mpty-images

# Conflicts:
#	clang/test/Driver/sycl-nordc-wrapper-object.cpp
#	clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
Keep the SYCL image group when post-link removes every image. Emit a
container with one empty image only when the combined group is empty,
so the host compilation still has its required input and omits runtime
registration. Mixed target groups retain only their nonempty images.

Extend the existing image test for empty tool/library post-link paths,
ELF and COFF host wrapping, and mixed targets. Give the no-RDC section
fixture a real kernel because its checks require a nonempty image.

Validated with 139 focused lit tests, Linux host linking for both drivers,
12 ELF/COFF wrapper checks, and native Windows linking/execution of eight
executables and eight DLLs plus two nonempty failure controls.

Assisted-by: Codex
@vishalshetagar

Copy link
Copy Markdown
Author

Thanks @sarnex I’ve merged the latest upstream sycl branch and resolved the conflicts. Retesting caught an empty-image issue with the updated non-RDC flow, which I fixed in the follow-up commit.

All 139 focused regression tests passed, along with Linux and native Windows linking checks. The changes are pushed and the PR description is updated.

This branch has not been deployed

No deployments
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.

Device pre-link with -fsycl-link of object files that define no kernels generates an object file with unneeded SYCL RT dependencies

3 participants