Author: mstorsjo Date: Mon Oct 22 23:33:26 2018 New Revision: 345004 URL: http://llvm.org/viewvc/llvm-project?rev=345004&view=rev Log: [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 Modified: cfe/trunk/lib/Driver/ToolChain.cpp Modified: cfe/trunk/lib/Driver/ToolChain.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChain.cpp?rev=345004&r1=345003&r2=345004&view=diff ============================================================================== --- cfe/trunk/lib/Driver/ToolChain.cpp (original) +++ cfe/trunk/lib/Driver/ToolChain.cpp Mon Oct 22 23:33:26 2018 @@ -378,7 +378,7 @@ std::string ToolChain::getCompilerRT(con 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(con 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 JobAct } 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(cons 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, _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits