close
Skip to content

[SYCL] Add /OPT:NOREF on Windows when -fsycl-allow-device-image-dependencies is used#21929

Open
srividya-sundaram wants to merge 2 commits intointel:syclfrom
srividya-sundaram:add-no-ref
Open

[SYCL] Add /OPT:NOREF on Windows when -fsycl-allow-device-image-dependencies is used#21929
srividya-sundaram wants to merge 2 commits intointel:syclfrom
srividya-sundaram:add-no-ref

Conversation

@srividya-sundaram
Copy link
Copy Markdown
Contributor

When -fsycl-allow-device-image-dependencies is used, linked libraries may
contain device-side symbols that are required only for SYCL device image
resolution and are not referenced directly from host code.

On Windows, linker optimization /OPT:REF may discard such seemingly unused
import-library references, causing required device image dependencies to be
dropped from the final executable. This can lead to runtime failures such
as "No device image found" when external device images (for example from
oneMKL device API DLLs) are needed.

Add /OPT:NOREF when -fsycl-allow-device-image-dependencies is present to preserve these
dependencies and ensure correct runtime device image discovery.

/// our flag overrides the user's optimization setting for correctness.
// RUN: %clang_cl -fsycl --offload-new-driver \
// RUN: -fsycl-allow-device-image-dependencies /O2 \
// RUN: -### %s /link /OPT:REF 2>&1 \
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.

For this particular test case, having -- %s /link /opt:ref makes everything after it treated as input files not options.

And having /link /opt:ref before -- %s captures all remaining arguments after it as linker arguments

And finally /link is needed to pass /OPT:REF in clang-cl, without it, we get warning: argument unused during compilation: '/OPT:REF' - it's ignored, doesn't reach the linker.

@srividya-sundaram
Copy link
Copy Markdown
Contributor Author

SYCL pre-commit test failure on Linux us unrelated to this patch

Timed Out Tests (1):
  SYCL :: bindless_images/vulkan_interop/vulkan_sycl_image_unsampled_timeline_semaphore.cpp

@srividya-sundaram srividya-sundaram marked this pull request as ready for review May 5, 2026 02:07
@srividya-sundaram srividya-sundaram requested a review from a team as a code owner May 5, 2026 02:07
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.

1 participant