diff options
author | Martin Storsjö <martin@martin.st> | 2020-09-20 23:19:12 +0300 |
---|---|---|
committer | Martin Storsjö <martin@martin.st> | 2020-09-21 23:42:59 +0300 |
commit | 4d85444b317a00a3e15da63cdb693d272c99a0cc (patch) | |
tree | 1b3b853d2de5e7c820b8a115253415b2a68a5abc /llvm/lib/Support/Process.cpp | |
parent | ead7c3cdc34c63d8df78d8e333b7cc64d03236ea (diff) | |
download | llvm-4d85444b317a00a3e15da63cdb693d272c99a0cc.zip llvm-4d85444b317a00a3e15da63cdb693d272c99a0cc.tar.gz llvm-4d85444b317a00a3e15da63cdb693d272c99a0cc.tar.bz2 |
[clang-cl] Always interpret the LIB env var as separated with semicolons
When cross compiling with clang-cl, clang splits the INCLUDE env
variable around semicolons (clang/lib/Driver/ToolChains/MSVC.cpp,
MSVCToolChain::AddClangSystemIncludeArgs) and lld splits the
LIB variable similarly (lld/COFF/Driver.cpp,
LinkerDriver::addLibSearchPaths). Therefore, the consensus for
cross compilation with clang-cl and lld-link seems to be to use
semicolons, despite path lists normally being separated by colons
on unix and EnvPathSeparator being set to that.
Therefore, handle the LIB variable similarly in Clang, when
handling lib file arguments when driving linking via Clang.
This fixes commands like "clang-cl test.c -Fetest.exe kernel32.lib" in
a cross compilation setting. Normally, most users call (lld-)link
directly, but meson happens to use this command syntax for
has_function() tests.
Differential Revision: https://reviews.llvm.org/D88002
Diffstat (limited to 'llvm/lib/Support/Process.cpp')
-rw-r--r-- | llvm/lib/Support/Process.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/llvm/lib/Support/Process.cpp b/llvm/lib/Support/Process.cpp index 9e6e233..9f0b689 100644 --- a/llvm/lib/Support/Process.cpp +++ b/llvm/lib/Support/Process.cpp @@ -28,21 +28,22 @@ using namespace sys; //=== independent code. //===----------------------------------------------------------------------===// -Optional<std::string> Process::FindInEnvPath(StringRef EnvName, - StringRef FileName) { - return FindInEnvPath(EnvName, FileName, {}); +Optional<std::string> +Process::FindInEnvPath(StringRef EnvName, StringRef FileName, char Separator) { + return FindInEnvPath(EnvName, FileName, {}, Separator); } Optional<std::string> Process::FindInEnvPath(StringRef EnvName, StringRef FileName, - ArrayRef<std::string> IgnoreList) { + ArrayRef<std::string> IgnoreList, + char Separator) { assert(!path::is_absolute(FileName)); Optional<std::string> FoundPath; Optional<std::string> OptPath = Process::GetEnv(EnvName); if (!OptPath.hasValue()) return FoundPath; - const char EnvPathSeparatorStr[] = {EnvPathSeparator, '\0'}; + const char EnvPathSeparatorStr[] = {Separator, '\0'}; SmallVector<StringRef, 8> Dirs; SplitString(OptPath.getValue(), Dirs, EnvPathSeparatorStr); |