]> granicus.if.org Git - clang/commitdiff
[HIP] Use option -nogpulib to disable linking device lib
authorYaxun Liu <Yaxun.Liu@amd.com>
Thu, 3 Oct 2019 18:59:56 +0000 (18:59 +0000)
committerYaxun Liu <Yaxun.Liu@amd.com>
Thu, 3 Oct 2019 18:59:56 +0000 (18:59 +0000)
Differential Revision: https://reviews.llvm.org/D68300

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@373649 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Driver/Options.td
lib/Driver/ToolChains/Cuda.cpp
lib/Driver/ToolChains/HIP.cpp
test/Driver/hip-no-device-libs.hip [new file with mode: 0644]

index d31c4f46e6b4b97c1e8276d15fa5cf21a4bc7c88..1c4794d1ac7452df39ce1b42bd1607cc6524cff2 100644 (file)
@@ -2556,7 +2556,9 @@ def no__dead__strip__inits__and__terms : Flag<["-"], "no_dead_strip_inits_and_te
 def nobuiltininc : Flag<["-"], "nobuiltininc">, Flags<[CC1Option, CoreOption]>,
   HelpText<"Disable builtin #include directories">;
 def nocudainc : Flag<["-"], "nocudainc">;
-def nocudalib : Flag<["-"], "nocudalib">;
+def nogpulib : Flag<["-"], "nogpulib">,
+  HelpText<"Do not link device library for CUDA/HIP device compilation">;
+def : Flag<["-"], "nocudalib">, Alias<nogpulib>;
 def nodefaultlibs : Flag<["-"], "nodefaultlibs">;
 def nofixprebinding : Flag<["-"], "nofixprebinding">;
 def nolibc : Flag<["-"], "nolibc">;
index 9ea410a79700d1acddb89e95df9ed82c1bda834b..4cada743b88596192f8101b6fb40f71eb87882c3 100644 (file)
@@ -121,7 +121,7 @@ CudaInstallationDetector::CudaInstallationDetector(
       Candidates.emplace_back(D.SysRoot + "/usr/lib/cuda");
   }
 
-  bool NoCudaLib = Args.hasArg(options::OPT_nocudalib);
+  bool NoCudaLib = Args.hasArg(options::OPT_nogpulib);
 
   for (const auto &Candidate : Candidates) {
     InstallPath = Candidate.Path;
@@ -628,7 +628,7 @@ void CudaToolChain::addClangTargetOptions(
       CC1Args.push_back("-fgpu-rdc");
   }
 
-  if (DriverArgs.hasArg(options::OPT_nocudalib))
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
     return;
 
   std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
index 9fbe4dd089b1dcf4fc6030fe33d7e360ff411463..f3e58cbeb4d7673784964662b2eb0b54361b946d 100644 (file)
@@ -286,6 +286,9 @@ void HIPToolChain::addClangTargetOptions(
     CC1Args.append({"-fvisibility", "hidden"});
     CC1Args.push_back("-fapply-global-visibility-to-externs");
   }
+
+  if (DriverArgs.hasArg(options::OPT_nogpulib))
+    return;
   ArgStringList LibraryPaths;
 
   // Find in --hip-device-lib-path and HIP_LIBRARY_PATH.
diff --git a/test/Driver/hip-no-device-libs.hip b/test/Driver/hip-no-device-libs.hip
new file mode 100644 (file)
index 0000000..9fc7369
--- /dev/null
@@ -0,0 +1,11 @@
+// REQUIRES: clang-driver
+// REQUIRES: x86-registered-target
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang -### -nogpulib -target x86_64-linux-gnu \
+// RUN:   -x hip --cuda-gpu-arch=gfx900 \
+// RUN:   %S/Inputs/hip_multiple_inputs/b.hip \
+// RUN: 2>&1 | FileCheck %s
+
+// CHECK-NOT: "-mlink-builtin-bitcode"
+