[PATCH] D73299: [HIP] Fix environment variable HIP_DEVICE_LIB_PATH
Yaxun Liu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 23 14:40:32 PST 2020
yaxunl created this revision.
yaxunl added a reviewer: tra.
If user sets HIP_DEVICE_LIB_PATH, this line in HIP.cpp
addDirectoryList(DriverArgs, LibraryPaths, "-L", "HIP_DEVICE_LIB_PATH");
adds `-L<value of env var HIP_DEVICE_LIB_PATH>` to LibraryPaths. `-L` is
needed since otherwise addDirectoryList will insert an extra empty string.
However, the `-L` must be stripped before checking for existence in addBCLib.
Patch by Greg Rodgers.
https://reviews.llvm.org/D73299
Files:
clang/lib/Driver/ToolChains/HIP.cpp
clang/test/Driver/hip-device-libs.hip
Index: clang/test/Driver/hip-device-libs.hip
===================================================================
--- clang/test/Driver/hip-device-libs.hip
+++ clang/test/Driver/hip-device-libs.hip
@@ -19,6 +19,13 @@
// RUN: %S/Inputs/hip_multiple_inputs/b.hip \
// RUN: 2>&1 | FileCheck %s --check-prefixes=COM,NOFLUSHD
+// Test environment variable HIP_DEVICE_LIB_PATH
+
+// RUN: HIP_DEVICE_LIB_PATH=%S/Inputs/hip_dev_lib \
+// RUN: %clang -### -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-prefixes=COM
// COM: {{"[^"]*clang[^"]*"}}
// COM-SAME: "-mlink-builtin-bitcode" "{{.*}}hip.amdgcn.bc"
Index: clang/lib/Driver/ToolChains/HIP.cpp
===================================================================
--- clang/lib/Driver/ToolChains/HIP.cpp
+++ clang/lib/Driver/ToolChains/HIP.cpp
@@ -39,6 +39,8 @@
SmallString<128> Path(LibraryPath);
llvm::sys::path::append(Path, BCName);
FullName = Path;
+ if (FullName.startswith("-L"))
+ FullName = FullName.substr(2);
if (llvm::sys::fs::exists(FullName)) {
CmdArgs.push_back("-mlink-builtin-bitcode");
CmdArgs.push_back(Args.MakeArgString(FullName));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73299.240015.patch
Type: text/x-patch
Size: 1259 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200123/6a1bd76c/attachment-0001.bin>
More information about the cfe-commits
mailing list