[Openmp-commits] [PATCH] D109061: [openmp] No longer use LIBRARY_PATH to find devicertl
Jon Chesterfield via Phabricator via Openmp-commits
openmp-commits at lists.llvm.org
Wed Sep 1 06:29:17 PDT 2021
JonChesterfield created this revision.
JonChesterfield added reviewers: jdoerfert, grokos, tianshilei1992.
Herald added subscribers: guansong, yaxunl.
JonChesterfield requested review of this revision.
Herald added subscribers: openmp-commits, cfe-commits, sstefan1.
Herald added projects: clang, OpenMP.
Given D109057 <https://reviews.llvm.org/D109057>, change test runner to use the libomptarget-x-bc-path
argument instead of the LIBRARY_PATH environment variable to find the device
library.
Also drop the use of LIBRARY_PATH environment variable as it is far
too easy to pull in the device library from an unrelated toolchain by accident
with the current setup. No loss in flexibility to developers as the clang
commandline used here is still available.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D109061
Files:
clang/lib/Driver/ToolChains/CommonArgs.cpp
openmp/libomptarget/test/lit.cfg
Index: openmp/libomptarget/test/lit.cfg
===================================================================
--- openmp/libomptarget/test/lit.cfg
+++ openmp/libomptarget/test/lit.cfg
@@ -93,6 +93,10 @@
append_dynamic_library_path('LIBRARY_PATH', config.library_dir, ":")
append_dynamic_library_path('LIBRARY_PATH', \
config.omp_host_rtl_directory, ":")
+ if config.libomptarget_current_target.startswith('amdgcn'):
+ config.test_flags += " --libomptarget-amdgcn-bc-path=" + config.library_dir
+ if config.libomptarget_current_target.startswith('nvptx'):
+ config.test_flags += " --libomptarget-nvptx-bc-path=" + config.library_dir
# substitutions
# - for targets that exist in the system create the actual command.
Index: clang/lib/Driver/ToolChains/CommonArgs.cpp
===================================================================
--- clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -1688,18 +1688,8 @@
StringRef BitcodeSuffix,
const llvm::Triple &Triple) {
SmallVector<StringRef, 8> LibraryPaths;
- // Add user defined library paths from LIBRARY_PATH.
- llvm::Optional<std::string> LibPath =
- llvm::sys::Process::GetEnv("LIBRARY_PATH");
- if (LibPath) {
- SmallVector<StringRef, 8> Frags;
- const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'};
- llvm::SplitString(*LibPath, Frags, EnvPathSeparatorStr);
- for (StringRef Path : Frags)
- LibraryPaths.emplace_back(Path.trim());
- }
-
- // Add path to lib / lib64 folder.
+
+ // Add path to clang lib / lib64 folder.
SmallString<256> DefaultLibPath = llvm::sys::path::parent_path(D.Dir);
llvm::sys::path::append(DefaultLibPath, Twine("lib") + CLANG_LIBDIR_SUFFIX);
LibraryPaths.emplace_back(DefaultLibPath.c_str());
@@ -1709,22 +1699,26 @@
: options::OPT_libomptarget_nvptx_bc_path_EQ;
StringRef ArchPrefix = Triple.isAMDGCN() ? "amdgcn" : "nvptx";
+ std::string LibOmpTargetName = "libomptarget-" + BitcodeSuffix.str() + ".bc";
+
// First check whether user specifies bc library
if (const Arg *A = DriverArgs.getLastArg(LibomptargetBCPathOpt)) {
- std::string LibOmpTargetName(A->getValue());
- if (llvm::sys::fs::exists(LibOmpTargetName)) {
+ SmallString<128> LibOmpTargetFile(A->getValue());
+ if (llvm::sys::fs::exists(LibOmpTargetFile) &&
+ llvm::sys::fs::is_directory(LibOmpTargetFile)) {
+ llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
+ }
+
+ if (llvm::sys::fs::exists(LibOmpTargetFile)) {
CC1Args.push_back("-mlink-builtin-bitcode");
- CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetName));
+ CC1Args.push_back(DriverArgs.MakeArgString(LibOmpTargetFile));
} else {
D.Diag(diag::err_drv_omp_offload_target_bcruntime_not_found)
- << LibOmpTargetName;
+ << LibOmpTargetFile;
}
} else {
bool FoundBCLibrary = false;
- std::string LibOmpTargetName =
- "libomptarget-" + BitcodeSuffix.str() + ".bc";
-
for (StringRef LibraryPath : LibraryPaths) {
SmallString<128> LibOmpTargetFile(LibraryPath);
llvm::sys::path::append(LibOmpTargetFile, LibOmpTargetName);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D109061.369917.patch
Type: text/x-patch
Size: 3301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210901/1f96343a/attachment.bin>
More information about the Openmp-commits
mailing list