diff options
author | Jonas Hahnfeld <hahnjo@hahnjo.de> | 2018-09-27 16:12:32 +0000 |
---|---|---|
committer | Jonas Hahnfeld <hahnjo@hahnjo.de> | 2018-09-27 16:12:32 +0000 |
commit | 7a37247afe63f58953d8e3293f454c56095e010e (patch) | |
tree | f0d81e772590656a7d1d0d18131f05b542503527 /lib/Driver/ToolChains/Cuda.cpp | |
parent | c104c07a624f422cb229a8cc94c9433f144029dc (diff) |
[OpenMP] Improve search for libomptarget-nvptx
When looking for the bclib Clang considered the default library
path first while it preferred directories in LIBRARY_PATH when
constructing the invocation of nvlink. The latter actually makes
more sense because during development it allows using a non-default
runtime library. So change the search for the bclib to start
looking in directories given by LIBRARY_PATH.
Additionally add a new option --libomptarget-nvptx-path= which
will be searched first. This will be handy for testing purposes.
Differential Revision: https://reviews.llvm.org/D51686
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@343230 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ToolChains/Cuda.cpp')
-rw-r--r-- | lib/Driver/ToolChains/Cuda.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/lib/Driver/ToolChains/Cuda.cpp b/lib/Driver/ToolChains/Cuda.cpp index a446c4d9d4..08e49fa6a5 100644 --- a/lib/Driver/ToolChains/Cuda.cpp +++ b/lib/Driver/ToolChains/Cuda.cpp @@ -511,6 +511,11 @@ void NVPTX::OpenMPLinker::ConstructJob(Compilation &C, const JobAction &JA, CmdArgs.push_back("-arch"); CmdArgs.push_back(Args.MakeArgString(GPUArch)); + // Assume that the directory specified with --libomptarget_nvptx_path + // contains the static library libomptarget-nvptx.a. + if (const Arg *A = Args.getLastArg(options::OPT_libomptarget_nvptx_path_EQ)) + CmdArgs.push_back(Args.MakeArgString(Twine("-L") + A->getValue())); + // Add paths specified in LIBRARY_PATH environment variable as -L options. addDirectoryList(Args, CmdArgs, "-L", "LIBRARY_PATH"); @@ -647,12 +652,9 @@ void CudaToolChain::addClangTargetOptions( if (DeviceOffloadingKind == Action::OFK_OpenMP) { SmallVector<StringRef, 8> LibraryPaths; - // Add path to lib and/or lib64 folders. - SmallString<256> DefaultLibPath = - llvm::sys::path::parent_path(getDriver().Dir); - llvm::sys::path::append(DefaultLibPath, - Twine("lib") + CLANG_LIBDIR_SUFFIX); - LibraryPaths.emplace_back(DefaultLibPath.c_str()); + + if (const Arg *A = DriverArgs.getLastArg(options::OPT_libomptarget_nvptx_path_EQ)) + LibraryPaths.push_back(A->getValue()); // Add user defined library paths from LIBRARY_PATH. llvm::Optional<std::string> LibPath = @@ -665,6 +667,12 @@ void CudaToolChain::addClangTargetOptions( LibraryPaths.emplace_back(Path.trim()); } + // Add path to lib / lib64 folder. + SmallString<256> DefaultLibPath = + llvm::sys::path::parent_path(getDriver().Dir); + llvm::sys::path::append(DefaultLibPath, Twine("lib") + CLANG_LIBDIR_SUFFIX); + LibraryPaths.emplace_back(DefaultLibPath.c_str()); + std::string LibOmpTargetName = "libomptarget-nvptx-" + GpuArch.str() + ".bc"; bool FoundBCLibrary = false; |