[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 17:49:37 PST 2020
yaxunl updated this revision to Diff 240074.
yaxunl edited the summary of this revision.
yaxunl added a comment.
Revised by Artem's comments.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D73299/new/
https://reviews.llvm.org/D73299
Files:
clang/lib/Driver/ToolChains/CommonArgs.cpp
clang/lib/Driver/ToolChains/CommonArgs.h
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
@@ -327,7 +327,7 @@
DriverArgs.getAllArgValues(options::OPT_hip_device_lib_path_EQ))
LibraryPaths.push_back(DriverArgs.MakeArgString(Path));
- addDirectoryList(DriverArgs, LibraryPaths, "-L", "HIP_DEVICE_LIB_PATH");
+ addDirectoryList(DriverArgs, LibraryPaths, "", "HIP_DEVICE_LIB_PATH");
llvm::SmallVector<std::string, 10> BCLibs;
Index: clang/lib/Driver/ToolChains/CommonArgs.h
===================================================================
--- clang/lib/Driver/ToolChains/CommonArgs.h
+++ clang/lib/Driver/ToolChains/CommonArgs.h
@@ -94,6 +94,11 @@
bool isUseSeparateSections(const llvm::Triple &Triple);
+/// \p EnvVar is split by system delimiter for environment variables.
+/// If \p ArgName is "-I", "-L", or an empty string, each entry from \p EnvVar
+/// is prefixed by \p ArgName then added to \p Args. Otherwise, for each
+/// entry of \p EnvVar, \p ArgName is added to \p Args first, then the entry
+/// itself is added.
void addDirectoryList(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs, const char *ArgName,
const char *EnvVar);
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -91,7 +91,7 @@
return; // Nothing to do.
StringRef Name(ArgName);
- if (Name.equals("-I") || Name.equals("-L"))
+ if (Name.equals("-I") || Name.equals("-L") || Name.empty())
CombinedArg = true;
StringRef Dirs(DirList);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73299.240074.patch
Type: text/x-patch
Size: 2509 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200124/272e1f39/attachment.bin>
More information about the cfe-commits
mailing list