forked from OSchip/llvm-project
[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 llvm-svn: 345004
This commit is contained in:
parent
bf6f82a10d
commit
965a361f57
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue