r373649 - [HIP] Use option -nogpulib to disable linking device lib
Yaxun Liu via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 3 11:59:56 PDT 2019
Author: yaxunl
Date: Thu Oct 3 11:59:56 2019
New Revision: 373649
URL: http://llvm.org/viewvc/llvm-project?rev=373649&view=rev
Log:
[HIP] Use option -nogpulib to disable linking device lib
Differential Revision: https://reviews.llvm.org/D68300
Added:
cfe/trunk/test/Driver/hip-no-device-libs.hip
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/lib/Driver/ToolChains/HIP.cpp
Modified: cfe/trunk/include/clang/Driver/Options.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=373649&r1=373648&r2=373649&view=diff
==============================================================================
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Thu Oct 3 11:59:56 2019
@@ -2556,7 +2556,9 @@ def no__dead__strip__inits__and__terms :
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">;
Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=373649&r1=373648&r2=373649&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Thu Oct 3 11:59:56 2019
@@ -121,7 +121,7 @@ CudaInstallationDetector::CudaInstallati
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::addClangTargetOption
CC1Args.push_back("-fgpu-rdc");
}
- if (DriverArgs.hasArg(options::OPT_nocudalib))
+ if (DriverArgs.hasArg(options::OPT_nogpulib))
return;
std::string LibDeviceFile = CudaInstallation.getLibDeviceFile(GpuArch);
Modified: cfe/trunk/lib/Driver/ToolChains/HIP.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/HIP.cpp?rev=373649&r1=373648&r2=373649&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/HIP.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/HIP.cpp Thu Oct 3 11:59:56 2019
@@ -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.
Added: cfe/trunk/test/Driver/hip-no-device-libs.hip
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/hip-no-device-libs.hip?rev=373649&view=auto
==============================================================================
--- cfe/trunk/test/Driver/hip-no-device-libs.hip (added)
+++ cfe/trunk/test/Driver/hip-no-device-libs.hip Thu Oct 3 11:59:56 2019
@@ -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"
+
More information about the cfe-commits
mailing list