Skip to content

Conversation

jinge90
Copy link
Contributor

@jinge90 jinge90 commented Oct 11, 2025

--[no-]offloadlib option is used by rocm and cuda toolchain to enable/disable device libraries in linking phase for device code. It makes sense to re-use this option in SYCL for similar purpose and since clang driver supports SYCL in CL compatibility mode, we also need to enable this option in CL compatibility mode.

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Oct 11, 2025
@jinge90 jinge90 requested a review from bader October 11, 2025 06:54
@llvmbot
Copy link
Member

llvmbot commented Oct 11, 2025

@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: None (jinge90)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/162980.diff

1 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+3-3)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index ec38231f906eb..4479aadf6949b 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5970,10 +5970,10 @@ def : Flag<["-"], "nocudainc">, Alias<no_offload_inc>;
 def no_offloadlib
     : Flag<["--"], "no-offloadlib">,
       MarshallingInfoFlag<LangOpts<"NoGPULib">>,
-      Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
-      HelpText<"Do not link device library for CUDA/HIP device compilation">;
+      Visibility<[ClangOption, CC1Option, CLOption, FlangOption, FC1Option]>,
+      HelpText<"Do not link device library for CUDA/HIP/SYCL device compilation">;
 def offloadlib : Flag<["--"], "offloadlib">,
-                 Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
+                 Visibility<[ClangOption, CC1Option, CLOption, FlangOption, FC1Option]>,
                  HelpText<"Link device libraries for GPU device compilation">;
 def : Flag<["-"], "nogpulib">,
       Alias<no_offloadlib>,

Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

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

@jinge90, I don't think the title accurately describes what the patch does.

I see that you enabled --[no-]offloadlib flags for MSVC compatible driver. The only SYCL related change is the help message. Did you intend to put more changes in this PR?

Please, add a test for using --[no-]offloadlib in CL compatibility mode.

@srividya-sundaram
Copy link

Please update the PR description to provide essential context and details about the changes proposed in this PR. Thanks!

@llvmbot llvmbot added the clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' label Oct 15, 2025
@jinge90 jinge90 changed the title Enable offloadlib option in compilation for SYCL Enable offloadlib option in SYCL and CL mode Oct 15, 2025
@jinge90
Copy link
Contributor Author

jinge90 commented Oct 15, 2025

@jinge90, I don't think the title accurately describes what the patch does.

I see that you enabled --[no-]offloadlib flags for MSVC compatible driver. The only SYCL related change is the help message. Did you intend to put more changes in this PR?

Please, add a test for using --[no-]offloadlib in CL compatibility mode.

Hi, @bader
I don't have more changes in this PR. The sycl toolchain can be invoked via CL compatibility mode in driver, so I enable this option in CL compatibility mode.

Thanks very much.

@jinge90
Copy link
Contributor Author

jinge90 commented Oct 15, 2025

Please update the PR description to provide essential context and details about the changes proposed in this PR. Thanks!

Hi, @srividya-sundaram
Description is added.
Thanks very much.

@bader
Copy link
Contributor

bader commented Oct 15, 2025

I don't have more changes in this PR. The sycl toolchain can be invoked via CL compatibility mode in driver, so I enable this option in CL compatibility mode.

If I get it right, --[no-]offloadlib option can be used in SYCL even w/o this patch, so the title is misleading. The change has no functional changes for SYCL. Please, remove SYCL and add tags to the PR title. E.g. [Clang][Driver] Enable offloadlib option for clang-cl.

--[no-]offloadlib option is used by rocm and cuda toolchain to enable/disable device libraries in linking phase for device code. It makes sense to re-use this option in sycl for similar purpose and since clang driver support sycl in CL compatibility mode as well, we also need to enable this option in CL compatibility mode.

Please, capitalize SYCL in the description: sycl -> SYCL.

@jinge90 jinge90 changed the title Enable offloadlib option in SYCL and CL mode [Clang][Driver] Enable offloadlib option for clang-cl Oct 17, 2025
@jinge90
Copy link
Contributor Author

jinge90 commented Oct 17, 2025

I don't have more changes in this PR. The sycl toolchain can be invoked via CL compatibility mode in driver, so I enable this option in CL compatibility mode.

If I get it right, --[no-]offloadlib option can be used in SYCL even w/o this patch, so the title is misleading. The change has no functional changes for SYCL. Please, remove SYCL and add tags to the PR title. E.g. [Clang][Driver] Enable offloadlib option for clang-cl.

--[no-]offloadlib option is used by rocm and cuda toolchain to enable/disable device libraries in linking phase for device code. It makes sense to re-use this option in sycl for similar purpose and since clang driver support sycl in CL compatibility mode as well, we also need to enable this option in CL compatibility mode.

Please, capitalize SYCL in the description: sycl -> SYCL.

Hi, @bader
Done.
Thanks very much.

Copy link
Contributor

@bader bader left a comment

Choose a reason for hiding this comment

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

Thanks.

@bader
Copy link
Contributor

bader commented Oct 17, 2025

@srividya-sundaram, are you okay with this PR?

@srividya-sundaram
Copy link

@srividya-sundaram, are you okay with this PR?

Yes, the changes look good to me.
Just 1 clarifying question.

// DEFAULT: "-sycl-std=2020"

// RUN: %clang_cl -### -fsycl -sycl-std=2017 --no-offloadlib -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-NO-OFFLOADLIB
// CHECK-NO-OFFLOADLIB-NOT: warning: unknown argument ignored in clang-cl: '--no-offloadlib'

Choose a reason for hiding this comment

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

I probably missed, but is there a corresponding test for clang driver as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi, @srividya-sundaram
clang and clangxx driver supports this option even without this PR, I add corresponding test to cover clang/clangxx driver to align with other tests in clang/test/Driver/sycl.c.
Thanks very much.

@srividya-sundaram
Copy link

Also, just FYI, I don't seem to have approval permission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants