summaryrefslogtreecommitdiff
path: root/lib/Driver/ToolChain.cpp
diff options
context:
space:
mode:
authorMartin Storsjo <martin@martin.st>2018-10-23 06:33:26 +0000
committerMartin Storsjo <martin@martin.st>2018-10-23 06:33:26 +0000
commitef9bc57167714be5e87c7d9520e3d915f5d3fd28 (patch)
treea9ef5e5c869039251ed0914e69e6d93c1baf6b8c /lib/Driver/ToolChain.cpp
parentf60f72ff15c424d1751a2246fae30c3a1b2ef07c (diff)
downloadclang-ef9bc57167714be5e87c7d9520e3d915f5d3fd28.tar.gz
[Driver] Use forward slashes in most linker arguments
libtool inspects the output of $CC -v to detect what object files and libraries are linked in by default. When clang is built as a native windows executable, all paths are formatted with backslashes, and the backslashes cause each argument to be enclosed in quotes. The backslashes and quotes break further processing within libtool (which is implemented in shell script, running in e.g. msys) pretty badly. Between unix style pathes (that only work in tools that are linked to the msys runtime, essentially the same as cygwin) and proper windows style paths (with backslashes, that can easily break shell scripts and msys environments), the best compromise is to use windows style paths (starting with e.g. c:) but with forward slashes, which both msys based tools, shell scripts and native windows executables can cope with. This incidentally turns out to be the form of paths that GCC prints out when run with -v on windows as well. This change potentially makes the output from clang -v a bit more inconsistent, but it is isn't necessarily very consistent to begin with. Differential Revision: https://reviews.llvm.org/D53066 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@345004 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Driver/ToolChain.cpp')
-rw-r--r--lib/Driver/ToolChain.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/lib/Driver/ToolChain.cpp b/lib/Driver/ToolChain.cpp
index 1667536c56..2b76dead57 100644
--- a/lib/Driver/ToolChain.cpp
+++ b/lib/Driver/ToolChain.cpp
@@ -378,7 +378,7 @@ std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
SmallString<128> P(LibPath);
llvm::sys::path::append(P, Prefix + Twine("clang_rt.") + Component + Suffix);
if (getVFS().exists(P))
- return P.str();
+ return llvm::sys::path::convert_to_slash(P);
}
StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
@@ -386,7 +386,7 @@ std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
SmallString<128> Path(getCompilerRTPath());
llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
Arch + Env + Suffix);
- return Path.str();
+ return llvm::sys::path::convert_to_slash(Path);
}
const char *ToolChain::getCompilerRTArgString(const llvm::opt::ArgList &Args,
@@ -425,7 +425,7 @@ Tool *ToolChain::SelectTool(const JobAction &JA) const {
}
std::string ToolChain::GetFilePath(const char *Name) const {
- return D.GetFilePath(Name, *this);
+ return llvm::sys::path::convert_to_slash(D.GetFilePath(Name, *this));
}
std::string ToolChain::GetProgramPath(const char *Name) const {
@@ -774,12 +774,14 @@ void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args,
void ToolChain::AddFilePathLibArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
for (const auto &LibPath : getLibraryPaths())
- if(LibPath.length() > 0)
- CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+ if (LibPath.length() > 0)
+ CmdArgs.push_back(Args.MakeArgString(
+ StringRef("-L") + llvm::sys::path::convert_to_slash(LibPath)));
for (const auto &LibPath : getFilePaths())
- if(LibPath.length() > 0)
- CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
+ if (LibPath.length() > 0)
+ CmdArgs.push_back(Args.MakeArgString(
+ StringRef("-L") + llvm::sys::path::convert_to_slash(LibPath)));
}
void ToolChain::AddCCKextLibArgs(const ArgList &Args,