Skip to content

[SYCL] Add -Wno-sycl-undefined-func-in-image to silence spurious undefined-function warnings - #23012

Open
bviyer wants to merge 13 commits into
syclfrom
bviyer-remove-unwanted-warnings
Open

[SYCL] Add -Wno-sycl-undefined-func-in-image to silence spurious undefined-function warnings#23012
bviyer wants to merge 13 commits into
syclfrom
bviyer-remove-unwanted-warnings

Conversation

@bviyer

@bviyer bviyer commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

Silences sycl-post-link's "Undefined function found in " warning. Intended for symbols resolved by the GPU driver / JIT. Adds the SyclUndefinedFuncInImage DiagGroup; the driver forwards suppress-undefined-func-warnings to sycl-post-link.

@bviyer
bviyer requested review from a team as code owners August 24, 2026 21:02
Comment thread clang/include/clang/Basic/DiagnosticGroups.td
Comment thread sycl/test/warnings/undefined_functions.cpp Outdated

@srividya-sundaram srividya-sundaram 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.

Clang Driver changes LGTM. Thanks!

Comment thread clang/include/clang/Options/Options.td Outdated
Comment thread clang/include/clang/Basic/DiagnosticGroups.td
Comment thread clang/include/clang/Options/Options.td Outdated
Comment thread clang/lib/Driver/ToolChains/Clang.cpp Outdated
@bviyer
bviyer requested a review from mdtoguchi August 26, 2026 21:39
Comment on lines 302 to 305

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.

I'd prefer to avoid duplicating code or stating the evident in comments.

Suggested change
// Set indirectly by clang's -Wno-sycl-undefined-func-in-image

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.

I think auto-apply just messed things up... :(

Comment on lines 309 to 310

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.

let's avoid implementation details in the option description, even internal. We may change what we pass from driver, that should not invalidate this internal option.

Suggested change
"in a device image"));

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.

same here - code now looks incorrect.

bviyer and others added 2 commits August 26, 2026 18:13
Co-authored-by: Yury Plyakhin <yury.plyakhin@intel.com>
Co-authored-by: Yury Plyakhin <yury.plyakhin@intel.com>
@bviyer
bviyer requested a review from YuriPlyakhin August 26, 2026 23:15
Comment thread sycl/doc/UsersManual.md
Co-authored-by: Yury Plyakhin <yury.plyakhin@intel.com>
@bviyer
bviyer requested a review from YuriPlyakhin August 26, 2026 23:21

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.

This is the only cl::opt in all of llvm/lib/SYCLPostLink/. The library is intentionally option-free because it's linked into three consumers with different option front-ends: the sycl-post-link tool, clang-linker-wrapper, and sycl-jit. All configuration is passed via PostLinkSettings / ModuleSplitterSettings.

In current implementation, the new flag a silent no-op on the library path. With --offload-new-driver -no-use-sycl-post-link-tool, clang-linker-wrapper runs sycl_post_link::performPostLinkProcessing in-process (ClangLinkerWrapper.cpp:872) using settings built from an ArgList in getSYCLPostLinkSettings (line 645);

--sycl-post-link-options= values are only forwarded to the tool (line 807).

So, in case of library usage the user passes -Wno-..., and still sees the warning.

Please follow the existing pattern instead:

  1. cl::opt<bool> SuppressUndefinedFuncWarnings in llvm/tools/sycl-post-link/sycl-post-link.cpp, next to AllowDeviceImageDependencies.
  2. New field in ModuleSplitterSettings (and PostLinkSettings so it survives the pipeline).
  3. Pass it as a parameter to checkForCallsToUndefinedFunctions / extractCallGraph, exactly like AllowDeviceImageDependencies.
  4. Set it in getSYCLPostLinkSettings from the linker-wrapper's arg list, so the new-offload library path honours it too.

@@ -0,0 +1,58 @@
/// Verify that -W[no-]sycl-undefined-func-in-image is forwarded correctly to

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.

All RUN lines exercise only the legacy offload path. Please add --offload-new-driver test, where the option is serialized differently:

// RUN: %clang -### -fsycl --offload-new-driver -fsycl-targets=spir64 -Wno-sycl-undefined-func-in-image %s 2>&1 \
// RUN:   | FileCheck --check-prefix=WNO-NEW %s
// WNO-NEW: clang-linker-wrapper{{.*}} "--sycl-post-link-options=-suppress-undefined-func-warnings"

and a matching negative case.

/// sycl-post-link under both the default clang driver and the clang-cl
/// driver. The clang-cl coverage exists because the underlying Options.td
/// defs need Visibility<[ClangOption, CLOption]> for the driver's
/// getLastArg(OPT_Wsycl_..., OPT_Wno_sycl_...) to see the arg under

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.

This is stale after the switch to hasFlag. If possible, could you update the comment with focusing on behavior and avoiding implementation details. Otherwise, the comment might stale again in the future.
Same for other comments in this code, where makes sense.

Comment thread clang/lib/Driver/ToolChains/Clang.cpp Outdated
@@ -11506,6 +11492,16 @@ static void getNonTripleBasedSYCLPostLinkOpts(const ToolChain &TC,
if (allowDeviceImageDependencies(TCArgs))
addArgs(PostLinkArgs, TCArgs, {"-allow-device-image-dependencies"});

// Forward -Wno-sycl-undefined-func-in-image to sycl-post-link. Users pass
// this to silence sycl-post-link's "Undefined function ... found in ..."
// warning for device-code symbols resolved by the driver/JIT (e.g. Intel

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.

Here and in the rest of the code/comments/docs changed in this PR:
An unqualified "driver" may be read as the clang driver, but here it means the GPU driver.
Please disambiguate: ... for device-code symbols resolved by the GPU runtime or JIT.

Comment thread clang/include/clang/Basic/DiagnosticGroups.td

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.

Appending [-Wsycl-undefined-func-in-image] signals full clang warning semantics, but only the two literal spellings are honoured. -w, -Wno-everything, and -Werror=sycl-undefined-func-in-image all parse cleanly and have no effect.
Maybe we need to be more explicit here: Use -Wno-sycl-undefined-func-in-image to suppress the warning.

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.

Fixed.

Comment thread sycl/doc/UsersManual.md

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.

This takes the test from 2 to 5 full -fsycl -fsycl-link compiles of <sycl/sycl.hpp>.
I suggest keeping the one that adds real end-to-end value (-Wno-... actually suppresses the warning)

Can we drop CHECK-WARNING-REENABLED / CHECK-WARNING-LAST-WNO?

last --W-wins is driver argument handling, already covered by LAST-W/LAST-WNO in clang/test/Driver/sycl-suppress-undefined-func-warnings.cpp.

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.

Fixed.

/// getLastArg(OPT_Wsycl_..., OPT_Wno_sycl_...) to see the arg under
/// --driver-mode=cl.

// RUN: %clang -### -fsycl -fsycl-targets=spir64 %s 2>&1 \

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.

%clang and %clangxx are redundant for -### forwarding checks since -fsycl implies C++, right?
%clangxx + %clang_cl should be sufficient.

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.

Fixed.

@bviyer
bviyer requested a review from YuriPlyakhin August 28, 2026 16:24

@KseniyaTikhomirova KseniyaTikhomirova 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.

SYCL RT part LGTM

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.

6 participants