[PATCH] D17952: [Clang] Accept absolute paths in the -fuse-ld option
whitequark via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 7 19:32:52 PST 2016
whitequark updated this revision to Diff 50021.
whitequark added a comment.
Windows compatibility
Repository:
rL LLVM
http://reviews.llvm.org/D17952
Files:
cfe/trunk/lib/Driver/ToolChain.cpp
Index: cfe/trunk/lib/Driver/ToolChain.cpp
===================================================================
--- cfe/trunk/lib/Driver/ToolChain.cpp
+++ cfe/trunk/lib/Driver/ToolChain.cpp
@@ -342,19 +342,26 @@
std::string ToolChain::GetLinkerPath() const {
if (Arg *A = Args.getLastArg(options::OPT_fuse_ld_EQ)) {
- StringRef Suffix = A->getValue();
-
- // If we're passed -fuse-ld= with no argument, or with the argument ld,
- // then use whatever the default system linker is.
- if (Suffix.empty() || Suffix == "ld")
- return GetProgramPath("ld");
-
- llvm::SmallString<8> LinkerName("ld.");
- LinkerName.append(Suffix);
-
- std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
- if (llvm::sys::fs::exists(LinkerPath))
- return LinkerPath;
+ StringRef UseLinker = A->getValue();
+
+ if (llvm::sys::path::is_absolute(UseLinker)) {
+ // If we're passed -fuse-ld= with what looks like an absolute path,
+ // don't attempt to second-guess that.
+ if (llvm::sys::fs::exists(UseLinker))
+ return UseLinker;
+ } else {
+ // If we're passed -fuse-ld= with no argument, or with the argument ld,
+ // then use whatever the default system linker is.
+ if (UseLinker.empty() || UseLinker == "ld")
+ return GetProgramPath("ld");
+
+ llvm::SmallString<8> LinkerName("ld.");
+ LinkerName.append(UseLinker);
+
+ std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
+ if (llvm::sys::fs::exists(LinkerPath))
+ return LinkerPath;
+ }
getDriver().Diag(diag::err_drv_invalid_linker_name) << A->getAsString(Args);
return "";
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17952.50021.patch
Type: text/x-patch
Size: 1654 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160308/a0251938/attachment-0001.bin>
More information about the cfe-commits
mailing list