From 4d85444b317a00a3e15da63cdb693d272c99a0cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Storsj=C3=B6?= Date: Sun, 20 Sep 2020 23:19:12 +0300 Subject: [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 --- llvm/lib/Support/Process.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'llvm/lib/Support/Process.cpp') 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 Process::FindInEnvPath(StringRef EnvName, - StringRef FileName) { - return FindInEnvPath(EnvName, FileName, {}); +Optional +Process::FindInEnvPath(StringRef EnvName, StringRef FileName, char Separator) { + return FindInEnvPath(EnvName, FileName, {}, Separator); } Optional Process::FindInEnvPath(StringRef EnvName, StringRef FileName, - ArrayRef IgnoreList) { + ArrayRef IgnoreList, + char Separator) { assert(!path::is_absolute(FileName)); Optional FoundPath; Optional OptPath = Process::GetEnv(EnvName); if (!OptPath.hasValue()) return FoundPath; - const char EnvPathSeparatorStr[] = {EnvPathSeparator, '\0'}; + const char EnvPathSeparatorStr[] = {Separator, '\0'}; SmallVector Dirs; SplitString(OptPath.getValue(), Dirs, EnvPathSeparatorStr); -- cgit v1.1