Skip to content

[Clang][NFC] Introduce --offloadlib positive flag for nogpulib and alias to --no-offloadlib #126567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 13, 2025

Conversation

jhuber6
Copy link
Contributor

@jhuber6 jhuber6 commented Feb 10, 2025

Summary:
We support nogpulib to disable implicit libraries. In the future we
will want to change the default linking of these libraries based on the
user language. This patch just introduces a positive variant so now we
can do -nogpulib -gpulib to disable it.

Later patch will make the default a variable in the ROCmToolChain
depending on the target languages.

@llvmbot llvmbot added clang Clang issues not falling into any other category backend:AMDGPU clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang:openmp OpenMP related changes to Clang labels Feb 10, 2025
@llvmbot
Copy link
Member

llvmbot commented Feb 10, 2025

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-driver

Author: Joseph Huber (jhuber6)

Changes

Summary:
We support nogpulib to disable implicit libraries. In the future we
will want to change the default linking of these libraries based on the
user language. This patch just introduces a positive variant so now we
can do -nogpulib -gpulib to disable it.

Later patch will make the default a variable in the ROCmToolChain
depending on the target languages.


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

11 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+3)
  • (modified) clang/lib/Driver/ToolChains/AMDGPU.cpp (+1-1)
  • (modified) clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp (+2-2)
  • (modified) clang/lib/Driver/ToolChains/Clang.cpp (+3-2)
  • (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+2-1)
  • (modified) clang/lib/Driver/ToolChains/Cuda.cpp (+3-2)
  • (modified) clang/lib/Driver/ToolChains/Flang.cpp (+1-1)
  • (modified) clang/lib/Driver/ToolChains/HIPAMD.cpp (+1-1)
  • (modified) clang/lib/Driver/ToolChains/HIPSPV.cpp (+1-1)
  • (modified) clang/lib/Driver/ToolChains/SPIRVOpenMP.cpp (+1-1)
  • (modified) clang/test/Driver/amdgpu-openmp-toolchain.c (+3-3)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index c9d192a20ff1f8a..868e231a642879e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5621,6 +5621,9 @@ def : Flag<["-"], "nocudainc">, Alias<nogpuinc>;
 def nogpulib : Flag<["-"], "nogpulib">, MarshallingInfoFlag<LangOpts<"NoGPULib">>,
   Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   HelpText<"Do not link device library for CUDA/HIP device compilation">;
+def gpulib : Flag<["-"], "gpulib">,
+             Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
+             HelpText<"Link device libraries for GPU device compilation">;
 def : Flag<["-"], "nocudalib">, Alias<nogpulib>;
 def gpulibc : Flag<["-"], "gpulibc">, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   HelpText<"Link the LLVM C Library for GPUs">;
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index e66e5a32e58acdc..aff509b02704a38 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -936,7 +936,7 @@ void ROCMToolChain::addClangTargetOptions(
       DriverArgs.hasArg(options::OPT_nostdlib))
     return;
 
-  if (DriverArgs.hasArg(options::OPT_nogpulib))
+  if (!DriverArgs.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
     return;
 
   // Get the device name and canonicalize it
diff --git a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
index 00bf9c7338edd11..90ef5863accc486 100644
--- a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -49,7 +49,7 @@ void AMDGPUOpenMPToolChain::addClangTargetOptions(
   assert(DeviceOffloadingKind == Action::OFK_OpenMP &&
          "Only OpenMP offloading kinds are supported.");
 
-  if (DriverArgs.hasArg(options::OPT_nogpulib))
+  if (!DriverArgs.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
     return;
 
   for (auto BCFile : getDeviceLibs(DriverArgs)) {
@@ -134,7 +134,7 @@ AMDGPUOpenMPToolChain::computeMSVCVersion(const Driver *D,
 
 llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12>
 AMDGPUOpenMPToolChain::getDeviceLibs(const llvm::opt::ArgList &Args) const {
-  if (Args.hasArg(options::OPT_nogpulib))
+  if (!Args.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
     return {};
 
   StringRef GpuArch = getProcessorFromTargetID(
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 821407687ffa1dc..48833ae362cf06f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7085,7 +7085,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   }
 
   // Forward -nogpulib to -cc1.
-  if (Args.hasArg(options::OPT_nogpulib))
+  if (!Args.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
     CmdArgs.push_back("-nogpulib");
 
   if (Arg *A = Args.getLastArg(options::OPT_fcf_protection_EQ)) {
@@ -9297,7 +9297,8 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
     CmdArgs.push_back("--save-temps");
 
   // Pass in the C library for GPUs if present and not disabled.
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_r, options::OPT_nogpulib,
+  if (Args.hasFlag(options::OPT_gpulib, OPT_nogpulib, true) &&
+      !Args.hasArg(options::OPT_nostdlib, options::OPT_r,
                    options::OPT_nodefaultlibs, options::OPT_nolibc,
                    options::OPT_nogpulibc)) {
     forAllAssociatedToolChains(C, JA, getToolChain(), [&](const ToolChain &TC) {
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 61917db4d780d50..fc6660324e7fc8a 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1289,7 +1289,8 @@ bool tools::addOpenMPRuntime(const Compilation &C, ArgStringList &CmdArgs,
   if (IsOffloadingHost)
     CmdArgs.push_back("-lomptarget");
 
-  if (IsOffloadingHost && !Args.hasArg(options::OPT_nogpulib))
+  if (IsOffloadingHost &&
+      Args.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
     CmdArgs.push_back("-lomptarget.devicertl");
 
   addArchSpecificRPath(TC, Args, CmdArgs);
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp
index c7d5893085080fb..0113c7d40779761 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -196,7 +196,8 @@ CudaInstallationDetector::CudaInstallationDetector(
       Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");
   }
 
-  bool NoCudaLib = Args.hasArg(options::OPT_nogpulib);
+  bool NoCudaLib =
+      !Args.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true);
 
   for (const auto &Candidate : Candidates) {
     InstallPath = Candidate.Path;
@@ -876,7 +877,7 @@ void CudaToolChain::addClangTargetOptions(
                          options::OPT_fno_cuda_short_ptr, false))
     CC1Args.append({"-mllvm", "--nvptx-short-ptr"});
 
-  if (DriverArgs.hasArg(options::OPT_nogpulib))
+  if (!DriverArgs.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
     return;
 
   if (DeviceOffloadingKind == Action::OFK_OpenMP &&
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 591003f56e8bbb9..848944c2d98b17c 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -557,7 +557,7 @@ void Flang::addOffloadOptions(Compilation &C, const InputInfoList &Inputs,
       CmdArgs.push_back("-fopenmp-assume-no-thread-state");
     if (Args.hasArg(options::OPT_fopenmp_assume_no_nested_parallelism))
       CmdArgs.push_back("-fopenmp-assume-no-nested-parallelism");
-    if (Args.hasArg(options::OPT_nogpulib))
+    if (!Args.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
       CmdArgs.push_back("-nogpulib");
   }
 
diff --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp b/clang/lib/Driver/ToolChains/HIPAMD.cpp
index 0e50eddd6b3d293..d781a7ffd2ce56e 100644
--- a/clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -352,7 +352,7 @@ VersionTuple HIPAMDToolChain::computeMSVCVersion(const Driver *D,
 llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12>
 HIPAMDToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
   llvm::SmallVector<BitCodeLibraryInfo, 12> BCLibs;
-  if (DriverArgs.hasArg(options::OPT_nogpulib) ||
+  if (!DriverArgs.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true) ||
       getGPUArch(DriverArgs) == "amdgcnspirv")
     return {};
   ArgStringList LibraryPaths;
diff --git a/clang/lib/Driver/ToolChains/HIPSPV.cpp b/clang/lib/Driver/ToolChains/HIPSPV.cpp
index bdbcf9109129dd2..c45f027b095e88e 100644
--- a/clang/lib/Driver/ToolChains/HIPSPV.cpp
+++ b/clang/lib/Driver/ToolChains/HIPSPV.cpp
@@ -204,7 +204,7 @@ void HIPSPVToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs,
 llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12>
 HIPSPVToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
   llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12> BCLibs;
-  if (DriverArgs.hasArg(options::OPT_nogpulib))
+  if (!DriverArgs.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
     return {};
 
   ArgStringList LibraryPaths;
diff --git a/clang/lib/Driver/ToolChains/SPIRVOpenMP.cpp b/clang/lib/Driver/ToolChains/SPIRVOpenMP.cpp
index 1f27245e2839cd5..27672714655e8f5 100644
--- a/clang/lib/Driver/ToolChains/SPIRVOpenMP.cpp
+++ b/clang/lib/Driver/ToolChains/SPIRVOpenMP.cpp
@@ -27,7 +27,7 @@ void SPIRVOpenMPToolChain::addClangTargetOptions(
   if (DeviceOffloadingKind != Action::OFK_OpenMP)
     return;
 
-  if (DriverArgs.hasArg(options::OPT_nogpulib))
+  if (!DriverArgs.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
     return;
   addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, "", getTriple(), HostTC);
 }
diff --git a/clang/test/Driver/amdgpu-openmp-toolchain.c b/clang/test/Driver/amdgpu-openmp-toolchain.c
index b3784537cb8367b..6ca9f88cf4e16ae 100644
--- a/clang/test/Driver/amdgpu-openmp-toolchain.c
+++ b/clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -52,14 +52,14 @@
 // CHECK-EMIT-LLVM-IR: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm"
 
 // RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx803 \
-// RUN:   --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode -fopenmp-new-driver %s  2>&1 | \
+// RUN:   -nogpulib -gpulib --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode %s  2>&1 | \
 // RUN: FileCheck %s --check-prefix=CHECK-LIB-DEVICE
 // CHECK-LIB-DEVICE: "-cc1" {{.*}}ocml.bc"{{.*}}oclc_daz_opt_on.bc"{{.*}}oclc_unsafe_math_off.bc"{{.*}}oclc_finite_only_off.bc"{{.*}}oclc_correctly_rounded_sqrt_on.bc"{{.*}}oclc_wavefrontsize64_on.bc"{{.*}}oclc_isa_version_803.bc"
 
 // RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx803 -nogpulib \
-// RUN:   --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode -fopenmp-new-driver %s  2>&1 | \
+// RUN:   -gpulib -nogpulib --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode %s  2>&1 | \
 // RUN: FileCheck %s --check-prefix=CHECK-LIB-DEVICE-NOGPULIB
-// CHECK-LIB-DEVICE-NOGPULIB-NOT: "-cc1" {{.*}}ocml.bc"{{.*}}ockl.bc"{{.*}}oclc_daz_opt_on.bc"{{.*}}oclc_unsafe_math_off.bc"{{.*}}oclc_finite_only_off.bc"{{.*}}oclc_correctly_rounded_sqrt_on.bc"{{.*}}oclc_wavefrontsize64_on.bc"{{.*}}oclc_isa_version_803.bc"
+// CHECK-LIB-DEVICE-NOGPULIB-NOT: "-cc1" {{.*}}ocml.bc"{{.*}}oclc_daz_opt_on.bc"{{.*}}oclc_unsafe_math_off.bc"{{.*}}oclc_finite_only_off.bc"{{.*}}oclc_correctly_rounded_sqrt_on.bc"{{.*}}oclc_wavefrontsize64_on.bc"{{.*}}oclc_isa_version_803.bc"
 
 // RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx90a:sramecc-:xnack+ \
 // RUN:   -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-ID

@llvmbot
Copy link
Member

llvmbot commented Feb 10, 2025

@llvm/pr-subscribers-backend-amdgpu

Author: Joseph Huber (jhuber6)

Changes

Summary:
We support nogpulib to disable implicit libraries. In the future we
will want to change the default linking of these libraries based on the
user language. This patch just introduces a positive variant so now we
can do -nogpulib -gpulib to disable it.

Later patch will make the default a variable in the ROCmToolChain
depending on the target languages.


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

11 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+3)
  • (modified) clang/lib/Driver/ToolChains/AMDGPU.cpp (+1-1)
  • (modified) clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp (+2-2)
  • (modified) clang/lib/Driver/ToolChains/Clang.cpp (+3-2)
  • (modified) clang/lib/Driver/ToolChains/CommonArgs.cpp (+2-1)
  • (modified) clang/lib/Driver/ToolChains/Cuda.cpp (+3-2)
  • (modified) clang/lib/Driver/ToolChains/Flang.cpp (+1-1)
  • (modified) clang/lib/Driver/ToolChains/HIPAMD.cpp (+1-1)
  • (modified) clang/lib/Driver/ToolChains/HIPSPV.cpp (+1-1)
  • (modified) clang/lib/Driver/ToolChains/SPIRVOpenMP.cpp (+1-1)
  • (modified) clang/test/Driver/amdgpu-openmp-toolchain.c (+3-3)
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index c9d192a20ff1f8a..868e231a642879e 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -5621,6 +5621,9 @@ def : Flag<["-"], "nocudainc">, Alias<nogpuinc>;
 def nogpulib : Flag<["-"], "nogpulib">, MarshallingInfoFlag<LangOpts<"NoGPULib">>,
   Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   HelpText<"Do not link device library for CUDA/HIP device compilation">;
+def gpulib : Flag<["-"], "gpulib">,
+             Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
+             HelpText<"Link device libraries for GPU device compilation">;
 def : Flag<["-"], "nocudalib">, Alias<nogpulib>;
 def gpulibc : Flag<["-"], "gpulibc">, Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
   HelpText<"Link the LLVM C Library for GPUs">;
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index e66e5a32e58acdc..aff509b02704a38 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -936,7 +936,7 @@ void ROCMToolChain::addClangTargetOptions(
       DriverArgs.hasArg(options::OPT_nostdlib))
     return;
 
-  if (DriverArgs.hasArg(options::OPT_nogpulib))
+  if (!DriverArgs.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
     return;
 
   // Get the device name and canonicalize it
diff --git a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
index 00bf9c7338edd11..90ef5863accc486 100644
--- a/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp
@@ -49,7 +49,7 @@ void AMDGPUOpenMPToolChain::addClangTargetOptions(
   assert(DeviceOffloadingKind == Action::OFK_OpenMP &&
          "Only OpenMP offloading kinds are supported.");
 
-  if (DriverArgs.hasArg(options::OPT_nogpulib))
+  if (!DriverArgs.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
     return;
 
   for (auto BCFile : getDeviceLibs(DriverArgs)) {
@@ -134,7 +134,7 @@ AMDGPUOpenMPToolChain::computeMSVCVersion(const Driver *D,
 
 llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12>
 AMDGPUOpenMPToolChain::getDeviceLibs(const llvm::opt::ArgList &Args) const {
-  if (Args.hasArg(options::OPT_nogpulib))
+  if (!Args.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
     return {};
 
   StringRef GpuArch = getProcessorFromTargetID(
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 821407687ffa1dc..48833ae362cf06f 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -7085,7 +7085,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
   }
 
   // Forward -nogpulib to -cc1.
-  if (Args.hasArg(options::OPT_nogpulib))
+  if (!Args.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
     CmdArgs.push_back("-nogpulib");
 
   if (Arg *A = Args.getLastArg(options::OPT_fcf_protection_EQ)) {
@@ -9297,7 +9297,8 @@ void LinkerWrapper::ConstructJob(Compilation &C, const JobAction &JA,
     CmdArgs.push_back("--save-temps");
 
   // Pass in the C library for GPUs if present and not disabled.
-  if (!Args.hasArg(options::OPT_nostdlib, options::OPT_r, options::OPT_nogpulib,
+  if (Args.hasFlag(options::OPT_gpulib, OPT_nogpulib, true) &&
+      !Args.hasArg(options::OPT_nostdlib, options::OPT_r,
                    options::OPT_nodefaultlibs, options::OPT_nolibc,
                    options::OPT_nogpulibc)) {
     forAllAssociatedToolChains(C, JA, getToolChain(), [&](const ToolChain &TC) {
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 61917db4d780d50..fc6660324e7fc8a 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1289,7 +1289,8 @@ bool tools::addOpenMPRuntime(const Compilation &C, ArgStringList &CmdArgs,
   if (IsOffloadingHost)
     CmdArgs.push_back("-lomptarget");
 
-  if (IsOffloadingHost && !Args.hasArg(options::OPT_nogpulib))
+  if (IsOffloadingHost &&
+      Args.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
     CmdArgs.push_back("-lomptarget.devicertl");
 
   addArchSpecificRPath(TC, Args, CmdArgs);
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp
index c7d5893085080fb..0113c7d40779761 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -196,7 +196,8 @@ CudaInstallationDetector::CudaInstallationDetector(
       Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");
   }
 
-  bool NoCudaLib = Args.hasArg(options::OPT_nogpulib);
+  bool NoCudaLib =
+      !Args.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true);
 
   for (const auto &Candidate : Candidates) {
     InstallPath = Candidate.Path;
@@ -876,7 +877,7 @@ void CudaToolChain::addClangTargetOptions(
                          options::OPT_fno_cuda_short_ptr, false))
     CC1Args.append({"-mllvm", "--nvptx-short-ptr"});
 
-  if (DriverArgs.hasArg(options::OPT_nogpulib))
+  if (!DriverArgs.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
     return;
 
   if (DeviceOffloadingKind == Action::OFK_OpenMP &&
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 591003f56e8bbb9..848944c2d98b17c 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -557,7 +557,7 @@ void Flang::addOffloadOptions(Compilation &C, const InputInfoList &Inputs,
       CmdArgs.push_back("-fopenmp-assume-no-thread-state");
     if (Args.hasArg(options::OPT_fopenmp_assume_no_nested_parallelism))
       CmdArgs.push_back("-fopenmp-assume-no-nested-parallelism");
-    if (Args.hasArg(options::OPT_nogpulib))
+    if (!Args.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
       CmdArgs.push_back("-nogpulib");
   }
 
diff --git a/clang/lib/Driver/ToolChains/HIPAMD.cpp b/clang/lib/Driver/ToolChains/HIPAMD.cpp
index 0e50eddd6b3d293..d781a7ffd2ce56e 100644
--- a/clang/lib/Driver/ToolChains/HIPAMD.cpp
+++ b/clang/lib/Driver/ToolChains/HIPAMD.cpp
@@ -352,7 +352,7 @@ VersionTuple HIPAMDToolChain::computeMSVCVersion(const Driver *D,
 llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12>
 HIPAMDToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
   llvm::SmallVector<BitCodeLibraryInfo, 12> BCLibs;
-  if (DriverArgs.hasArg(options::OPT_nogpulib) ||
+  if (!DriverArgs.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true) ||
       getGPUArch(DriverArgs) == "amdgcnspirv")
     return {};
   ArgStringList LibraryPaths;
diff --git a/clang/lib/Driver/ToolChains/HIPSPV.cpp b/clang/lib/Driver/ToolChains/HIPSPV.cpp
index bdbcf9109129dd2..c45f027b095e88e 100644
--- a/clang/lib/Driver/ToolChains/HIPSPV.cpp
+++ b/clang/lib/Driver/ToolChains/HIPSPV.cpp
@@ -204,7 +204,7 @@ void HIPSPVToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs,
 llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12>
 HIPSPVToolChain::getDeviceLibs(const llvm::opt::ArgList &DriverArgs) const {
   llvm::SmallVector<ToolChain::BitCodeLibraryInfo, 12> BCLibs;
-  if (DriverArgs.hasArg(options::OPT_nogpulib))
+  if (!DriverArgs.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
     return {};
 
   ArgStringList LibraryPaths;
diff --git a/clang/lib/Driver/ToolChains/SPIRVOpenMP.cpp b/clang/lib/Driver/ToolChains/SPIRVOpenMP.cpp
index 1f27245e2839cd5..27672714655e8f5 100644
--- a/clang/lib/Driver/ToolChains/SPIRVOpenMP.cpp
+++ b/clang/lib/Driver/ToolChains/SPIRVOpenMP.cpp
@@ -27,7 +27,7 @@ void SPIRVOpenMPToolChain::addClangTargetOptions(
   if (DeviceOffloadingKind != Action::OFK_OpenMP)
     return;
 
-  if (DriverArgs.hasArg(options::OPT_nogpulib))
+  if (!DriverArgs.hasFlag(options::OPT_gpulib, options::OPT_nogpulib, true))
     return;
   addOpenMPDeviceRTL(getDriver(), DriverArgs, CC1Args, "", getTriple(), HostTC);
 }
diff --git a/clang/test/Driver/amdgpu-openmp-toolchain.c b/clang/test/Driver/amdgpu-openmp-toolchain.c
index b3784537cb8367b..6ca9f88cf4e16ae 100644
--- a/clang/test/Driver/amdgpu-openmp-toolchain.c
+++ b/clang/test/Driver/amdgpu-openmp-toolchain.c
@@ -52,14 +52,14 @@
 // CHECK-EMIT-LLVM-IR: "-cc1" "-triple" "amdgcn-amd-amdhsa"{{.*}}"-emit-llvm"
 
 // RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx803 \
-// RUN:   --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode -fopenmp-new-driver %s  2>&1 | \
+// RUN:   -nogpulib -gpulib --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode %s  2>&1 | \
 // RUN: FileCheck %s --check-prefix=CHECK-LIB-DEVICE
 // CHECK-LIB-DEVICE: "-cc1" {{.*}}ocml.bc"{{.*}}oclc_daz_opt_on.bc"{{.*}}oclc_unsafe_math_off.bc"{{.*}}oclc_finite_only_off.bc"{{.*}}oclc_correctly_rounded_sqrt_on.bc"{{.*}}oclc_wavefrontsize64_on.bc"{{.*}}oclc_isa_version_803.bc"
 
 // RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx803 -nogpulib \
-// RUN:   --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode -fopenmp-new-driver %s  2>&1 | \
+// RUN:   -gpulib -nogpulib --rocm-device-lib-path=%S/Inputs/rocm/amdgcn/bitcode %s  2>&1 | \
 // RUN: FileCheck %s --check-prefix=CHECK-LIB-DEVICE-NOGPULIB
-// CHECK-LIB-DEVICE-NOGPULIB-NOT: "-cc1" {{.*}}ocml.bc"{{.*}}ockl.bc"{{.*}}oclc_daz_opt_on.bc"{{.*}}oclc_unsafe_math_off.bc"{{.*}}oclc_finite_only_off.bc"{{.*}}oclc_correctly_rounded_sqrt_on.bc"{{.*}}oclc_wavefrontsize64_on.bc"{{.*}}oclc_isa_version_803.bc"
+// CHECK-LIB-DEVICE-NOGPULIB-NOT: "-cc1" {{.*}}ocml.bc"{{.*}}oclc_daz_opt_on.bc"{{.*}}oclc_unsafe_math_off.bc"{{.*}}oclc_finite_only_off.bc"{{.*}}oclc_correctly_rounded_sqrt_on.bc"{{.*}}oclc_wavefrontsize64_on.bc"{{.*}}oclc_isa_version_803.bc"
 
 // RUN: %clang -### -target x86_64-pc-linux-gnu -fopenmp --offload-arch=gfx90a:sramecc-:xnack+ \
 // RUN:   -nogpulib %s 2>&1 | FileCheck %s --check-prefix=CHECK-TARGET-ID

Copy link
Member

@Artem-B Artem-B left a comment

Choose a reason for hiding this comment

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

I agree that we should be able to negate the option (and, perhaps --nocudainc, as well, while we're at that)

That said, perhaps we should reconsider how we implement it.

Originally -nogpulib was modeled after -nostdlib. So we've got a single-dash option, and no way to undo it.

Now that we do want to undo it, perhaps we should make it a normal double-dash offloading option. and alias -nogpulib to the negative variant of it? WDYT?

@jhuber6
Copy link
Contributor Author

jhuber6 commented Feb 10, 2025

I agree that we should be able to negate the option (and, perhaps --nocudainc, as well, while we're at that)

That said, perhaps we should reconsider how we implement it.

Originally -nogpulib was modeled after -nostdlib. So we've got a single-dash option, and no way to undo it.

Now that we do want to undo it, perhaps we should make it a normal double-dash offloading option. and alias -nogpulib to the negative variant of it? WDYT?

The inc flags aren't as problematic since they're only ever present on the frontend job. I'm ambivalent on changing the spelling, can do that without changing much.

@Artem-B
Copy link
Member

Artem-B commented Feb 10, 2025

If we're adding new options, I'd prefer those to be the standard double-dash options, rather than adding a special case to the legacy-style option.

Also, we still have the original -nocudalib being aliased to -nogpulib. We should probably take care of that, too.

@jhuber6
Copy link
Contributor Author

jhuber6 commented Feb 10, 2025

If we're adding new options, I'd prefer those to be the standard double-dash options, rather than adding a special case to the legacy-style option.

Also, we still have the original -nocudalib being aliased to -nogpulib. We should probably take care of that, too.

Should be done, I just kept the same name inside the source though.

@jhuber6 jhuber6 changed the title [Clang][NFC] Introduce gpulib positive flag for nogpulib [Clang][NFC] Introduce --offloadlib positive flag for nogpulib and alias to --no-offloadlib Feb 10, 2025
Copy link

github-actions bot commented Feb 11, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
HelpText<"Do not link device library for CUDA/HIP device compilation">;
def : Flag<["-"], "nocudalib">, Alias<nogpulib>;
def no_offloadlib
Copy link
Collaborator

Choose a reason for hiding this comment

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

can we use defm offloadlib: BoolFOption to make it simpler?

@@ -7088,7 +7088,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
}

// Forward -nogpulib to -cc1.
if (Args.hasArg(options::OPT_nogpulib))
if (!Args.hasFlag(options::OPT_offloadlib, options::OPT_no_offloadlib, true))
CmdArgs.push_back("-nogpulib");
Copy link
Collaborator

Choose a reason for hiding this comment

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

better use the new option

Summary:
We support `nogpulib` to disable implicit libraries. In the future we
will want to change the default linking of these libraries based on the
user language. This patch just introduces a positive variant so now we
can do `-nogpulib -gpulib` to disable it.

Later patch will make the default a variable in the ROCmToolChain
depending on the target languages.

Offload flags
@jhuber6 jhuber6 merged commit f6e3d33 into llvm:main Feb 13, 2025
8 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 13, 2025

LLVM Buildbot has detected a new failure on builder ppc64le-flang-rhel-clang running on ppc64le-flang-rhel-test while building clang at step 5 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/157/builds/19921

Here is the relevant piece of the build log for the reference
Step 5 (build-unified-tree) failure: build (failure)
...
87.723 [103/9/6601] Creating library symlink lib/libclang.so.21.0git lib/libclang.so
87.877 [102/9/6602] Linking CXX executable bin/clang-check
88.050 [102/8/6603] Linking CXX executable bin/clang-import-test
88.151 [102/7/6604] Linking CXX executable bin/clang-21
88.157 [101/7/6605] Linking CXX executable bin/c-index-test
88.169 [101/6/6606] Creating executable symlink bin/clang
88.458 [101/5/6607] Linking CXX shared library lib/libclang-cpp.so.21.0git
88.468 [100/5/6608] Creating library symlink lib/libclang-cpp.so
88.803 [100/4/6609] Linking CXX executable bin/clang-repl
94.063 [100/3/6610] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/CompilerInvocation.cpp.o
FAILED: tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/CompilerInvocation.cpp.o 
ccache /home/buildbots/llvm-external-buildbots/clang.19.1.7/bin/clang++ -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/flang/lib/Frontend -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/lib/Frontend -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/flang/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/include -I/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/llvm/include -isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/../mlir/include -isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/mlir/include -isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/clang/include -isystem /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/llvm/../clang/include -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Werror -Wno-deprecated-copy -Wno-string-conversion -Wno-ctad-maybe-unsupported -Wno-unused-command-line-argument -Wstring-conversion           -Wcovered-switch-default -Wno-nested-anon-types -O3 -DNDEBUG -std=c++17  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -MD -MT tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/CompilerInvocation.cpp.o -MF tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/CompilerInvocation.cpp.o.d -o tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/CompilerInvocation.cpp.o -c /home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/lib/Frontend/CompilerInvocation.cpp
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/flang/lib/Frontend/CompilerInvocation.cpp:1095:45: error: no member named 'OPT_nogpulib' in namespace 'clang::driver::options'; did you mean 'OPT_nogpulibc'?
 1095 |     if (args.hasArg(clang::driver::options::OPT_nogpulib))
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
      |                                             OPT_nogpulibc
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/build/tools/clang/include/clang/Driver/Options.inc:8270:1: note: 'OPT_nogpulibc' declared here
 8270 | OPTION(1, 54025 /* -nogpulibc */, nogpulibc, Flag, INVALID, INVALID, nullptr, 0, DefaultVis | CC1Option | FlangOption | FC1Option, 0, nullptr, (std::array<std::pair<std::array<unsigned, 2>, const char*>, 1>{{ {std::array<unsigned, 2>{{0, 0}}, nullptr} }}), nullptr, nullptr)
      | ^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/llvm/../clang/include/clang/Driver/Options.h:46:21: note: expanded from macro 'OPTION'
   46 | #define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
      |                     ^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/llvm/include/llvm/Option/OptTable.h:460:3: note: expanded from macro 'LLVM_MAKE_OPT_ID'
  460 |   LLVM_MAKE_OPT_ID_WITH_ID_PREFIX(OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, \
      |   ^
/home/buildbots/llvm-external-buildbots/workers/ppc64le-flang-rhel-test/ppc64le-flang-rhel-clang-build/llvm-project/llvm/include/llvm/Option/OptTable.h:455:3: note: expanded from macro 'LLVM_MAKE_OPT_ID_WITH_ID_PREFIX'
  455 |   ID_PREFIX##ID
      |   ^
<scratch space>:44:1: note: expanded from here
   44 | OPT_nogpulibc
      | ^
1 error generated.
95.205 [100/2/6611] Building CXX object tools/flang/tools/flang-driver/CMakeFiles/flang.dir/driver.cpp.o
99.181 [100/1/6612] Building CXX object tools/flang/lib/FrontendTool/CMakeFiles/flangFrontendTool.dir/ExecuteCompilerInvocation.cpp.o
ninja: build stopped: subcommand failed.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Feb 13, 2025

LLVM Buildbot has detected a new failure on builder premerge-monolithic-linux running on premerge-linux-1 while building clang at step 6 "build-unified-tree".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/153/builds/22778

Here is the relevant piece of the build log for the reference
Step 6 (build-unified-tree) failure: build (failure)
...
47.486 [2457/58/1257] Generating obj.libclc.dir/clspv64--/generic/lib/math/erfc.cl.bc
47.563 [2456/58/1258] Generating obj.libclc.dir/clspv64--/generic/lib/math/cos.cl.bc
47.566 [2455/58/1259] Generating obj.libclc.dir/clspv64--/generic/lib/math/exp.cl.bc
47.567 [2454/58/1260] Generating obj.libclc.dir/nvptx--/generic/lib/shared/vstore.cl.bc
47.571 [2453/58/1261] Generating obj.libclc.dir/tahiti-amdgcn--/generic/lib/math/lgamma_r.cl.bc
47.583 [2452/58/1262] Generating obj.libclc.dir/clspv64--/generic/lib/math/clc_powr.cl.bc
47.629 [2451/58/1263] Generating obj.libclc.dir/clspv64--/generic/lib/math/expm1.cl.bc
47.636 [2450/58/1264] Generating obj.libclc.dir/clspv64--/generic/lib/math/fdim.cl.bc
47.642 [2449/58/1265] Generating obj.libclc.dir/clspv64--/generic/lib/math/clc_tanpi.cl.bc
47.644 [2448/58/1266] Building CXX object tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/CompilerInvocation.cpp.o
FAILED: tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/CompilerInvocation.cpp.o 
CCACHE_CPP2=yes CCACHE_HASHDIR=yes /usr/bin/ccache /usr/bin/clang++ -DFLANG_INCLUDE_TESTS=1 -DFLANG_LITTLE_ENDIAN=1 -DGTEST_HAS_RTTI=0 -D_DEBUG -D_GLIBCXX_ASSERTIONS -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -I/build/buildbot/premerge-monolithic-linux/build/tools/flang/lib/Frontend -I/build/buildbot/premerge-monolithic-linux/llvm-project/flang/lib/Frontend -I/build/buildbot/premerge-monolithic-linux/llvm-project/flang/include -I/build/buildbot/premerge-monolithic-linux/build/tools/flang/include -I/build/buildbot/premerge-monolithic-linux/build/include -I/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/include -isystem /build/buildbot/premerge-monolithic-linux/llvm-project/flang/../mlir/include -isystem /build/buildbot/premerge-monolithic-linux/build/tools/mlir/include -isystem /build/buildbot/premerge-monolithic-linux/build/tools/clang/include -isystem /build/buildbot/premerge-monolithic-linux/llvm-project/llvm/../clang/include -gmlt -fPIC -fno-semantic-interposition -fvisibility-inlines-hidden -Werror=date-time -Werror=unguarded-availability-new -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual -Wmissing-field-initializers -pedantic -Wno-long-long -Wc++98-compat-extra-semi -Wimplicit-fallthrough -Wcovered-switch-default -Wno-noexcept-type -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wsuggest-override -Wstring-conversion -Wmisleading-indentation -Wctad-maybe-unsupported -fdiagnostics-color -ffunction-sections -fdata-sections -Wno-deprecated-copy -Wno-string-conversion -Wno-ctad-maybe-unsupported -Wno-unused-command-line-argument -Wstring-conversion           -Wcovered-switch-default -Wno-nested-anon-types -O3 -DNDEBUG  -fno-exceptions -funwind-tables -fno-rtti -UNDEBUG -std=c++17 -MD -MT tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/CompilerInvocation.cpp.o -MF tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/CompilerInvocation.cpp.o.d -o tools/flang/lib/Frontend/CMakeFiles/flangFrontend.dir/CompilerInvocation.cpp.o -c /build/buildbot/premerge-monolithic-linux/llvm-project/flang/lib/Frontend/CompilerInvocation.cpp
/build/buildbot/premerge-monolithic-linux/llvm-project/flang/lib/Frontend/CompilerInvocation.cpp:1095:45: error: no member named 'OPT_nogpulib' in namespace 'clang::driver::options'; did you mean 'OPT_nogpulibc'?
    if (args.hasArg(clang::driver::options::OPT_nogpulib))
                    ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
                                            OPT_nogpulibc
/build/buildbot/premerge-monolithic-linux/build/tools/clang/include/clang/Driver/Options.inc:8270:1: note: 'OPT_nogpulibc' declared here
OPTION(1, 54025 /* -nogpulibc */, nogpulibc, Flag, INVALID, INVALID, nullptr, 0, DefaultVis | CC1Option | FlangOption | FC1Option, 0, nullptr, (std::array<std::pair<std::array<unsigned, 2>, const char*>, 1>{{ {std::array<unsigned, 2>{{0, 0}}, nullptr} }}), nullptr, nullptr)
^
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/../clang/include/clang/Driver/Options.h:46:21: note: expanded from macro 'OPTION'
#define OPTION(...) LLVM_MAKE_OPT_ID(__VA_ARGS__),
                    ^
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/include/llvm/Option/OptTable.h:460:3: note: expanded from macro 'LLVM_MAKE_OPT_ID'
  LLVM_MAKE_OPT_ID_WITH_ID_PREFIX(OPT_, PREFIXES_OFFSET, PREFIXED_NAME_OFFSET, \
  ^
/build/buildbot/premerge-monolithic-linux/llvm-project/llvm/include/llvm/Option/OptTable.h:455:3: note: expanded from macro 'LLVM_MAKE_OPT_ID_WITH_ID_PREFIX'
  ID_PREFIX##ID
  ^
<scratch space>:114:1: note: expanded from here
OPT_nogpulibc
^
1 error generated.
47.654 [2448/57/1267] Generating obj.libclc.dir/clspv64--/generic/lib/math/half_tan.cl.bc
47.666 [2448/56/1268] Generating obj.libclc.dir/clspv64--/generic/lib/math/fmod.cl.bc
47.686 [2448/55/1269] Generating obj.libclc.dir/nvptx64--nvidiacl/generic/lib/relational/all.cl.bc
47.726 [2448/54/1270] Generating obj.libclc.dir/clspv64--/generic/lib/math/fract.cl.bc
47.733 [2448/53/1271] Generating obj.libclc.dir/nvptx64--nvidiacl/generic/lib/math/acosh.cl.bc
47.760 [2448/52/1272] Generating obj.libclc.dir/nvptx64--nvidiacl/generic/lib/relational/any.cl.bc
47.763 [2448/51/1273] Generating obj.libclc.dir/clspv64--/generic/lib/math/exp2.cl.bc
47.773 [2448/50/1274] Generating obj.libclc.dir/nvptx64--nvidiacl/generic/lib/math/clc_ldexp.cl.bc
47.773 [2448/49/1275] Generating obj.libclc.dir/clspv64--/generic/lib/math/half_exp10.cl.bc
47.786 [2448/48/1276] Generating obj.libclc.dir/nvptx64--nvidiacl/generic/lib/math/half_exp10.cl.bc
47.839 [2448/47/1277] Generating obj.libclc.dir/clspv64--/generic/lib/math/half_exp2.cl.bc
47.840 [2448/46/1278] Generating obj.libclc.dir/nvptx64--nvidiacl/generic/lib/math/atanh.cl.bc
47.858 [2448/45/1279] Generating obj.libclc.dir/clspv64--/generic/lib/math/tables.cl.bc
47.881 [2448/44/1280] Generating obj.libclc.dir/clspv64--/generic/lib/math/half_exp.cl.bc
47.882 [2448/43/1281] Generating obj.libclc.dir/clspv64--/generic/lib/math/half_log.cl.bc
47.936 [2448/42/1282] Generating obj.libclc.dir/clspv64--/generic/lib/math/half_recip.cl.bc
47.936 [2448/41/1283] Generating obj.libclc.dir/clspv64--/generic/lib/math/half_powr.cl.bc

joaosaffran pushed a commit to joaosaffran/llvm-project that referenced this pull request Feb 14, 2025
…d alias to `--no-offloadlib` (llvm#126567)

Summary:
We support `nogpulib` to disable implicit libraries. In the future we
will want to change the default linking of these libraries based on the
user language. This patch just introduces a positive variant so now we
can do `-nogpulib -gpulib` to disable it.

Later patch will make the default a variable in the ROCmToolChain
depending on the target languages.
sivan-shani pushed a commit to sivan-shani/llvm-project that referenced this pull request Feb 24, 2025
…d alias to `--no-offloadlib` (llvm#126567)

Summary:
We support `nogpulib` to disable implicit libraries. In the future we
will want to change the default linking of these libraries based on the
user language. This patch just introduces a positive variant so now we
can do `-nogpulib -gpulib` to disable it.

Later patch will make the default a variable in the ROCmToolChain
depending on the target languages.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AMDGPU clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang:openmp OpenMP related changes to Clang clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants