Skip to content

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

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

vishalshetagar wants to merge 2 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 currently 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, including mixed empty/nonempty inputs, and NativeCPU placeholders.

Extend existing regression tests to cover these cases and host linking without the SYCL runtime.

Validation:

  • 134 tests passed: the two affected Clang tests and the complete llvm/test/tools/sycl-post-link suite, using rebuilt affected tools with assertions enabled and a prebuilt DPC++ frontend.
  • Both driver paths passed Linux executable and shared-library linking without the SYCL runtime for host-only and kernel-free inputs; executables ran successfully. Nonempty kernel inputs retained registration references.
  • 12 additional wrapper checks passed across ELF and COFF targets.
  • Seven Windows executable cases linked with Microsoft's linker and ran; seven DLLs linked, loaded, and executed a test function without the SYCL runtime. Two nonempty-image controls correctly failed to link without the runtime. Windows objects were generated by the patched tools in WSL; linking and execution were native Windows. The compiler tools were not built natively on Windows.

The non-RDC wrapper and linker-wrapper command tests now use real kernels where they require a nonempty image. This preserves their section, registration, and missing-ocloc checks after empty images are omitted. Integration-header inclusion is disabled in these standalone fixtures, and the non-RDC test additionally checks empty ELF and COFF objects.

Follow-up validation with the PR's CI-built Clang 24 toolchain: both original compiler-test failures were reproduced, then passed after the fixture changes. The wider SYCL driver, linker-wrapper, and complete post-link selection finished with 294 passed, 3 expected failures, 15 unsupported, and no unexpected failures. An empty non-RDC COFF object also passed native Microsoft executable linking/execution and DLL linking/loading/calling with automatic SYCL library linkage disabled (-nolibsycl).

The GPU E2E failures are separate from these compiler-test fixes:

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

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

2 participants