[PATCH] D44447: Treat libclang_rt.* as normal library if the user uses --sysroot=
Tom Rix via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 13 14:11:34 PDT 2018
trixirt created this revision.
trixirt added reviewers: rsmith, atanasyan, vkalintiris.
trixirt added a project: clang.
Herald added a subscriber: cfe-commits.
In cross compiling, one normally assumes that the user supplied sysroot contains all of the libraries needed in the link. And so the linker adjusts the -L paths to look in the sysroot.
However because libclang_rt.* is supplied at link time as a full path, the link can not find it in the sysroot.
This change will churn the user's current experience and the unit tests.
I will take take of the tests, if folks are ok with the change.
Repository:
rC Clang
https://reviews.llvm.org/D44447
Files:
lib/Driver/ToolChain.cpp
Index: lib/Driver/ToolChain.cpp
===================================================================
--- lib/Driver/ToolChain.cpp
+++ lib/Driver/ToolChain.cpp
@@ -356,11 +356,17 @@
TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment();
StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
- const char *Prefix = IsITANMSVCWindows ? "" : "lib";
- const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
+ const char *Prefix = "-l";
+ const char *Suffix = "";
+ SmallString<128> Path;
+
+ if (getDriver().SysRoot.empty()) {
+ Prefix = IsITANMSVCWindows ? "" : "lib";
+ Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so")
: (IsITANMSVCWindows ? ".lib" : ".a");
+ Path = getCompilerRTPath();
+ }
- SmallString<128> Path(getCompilerRTPath());
llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" +
Arch + Env + Suffix);
return Path.str();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44447.138256.patch
Type: text/x-patch
Size: 999 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180313/b5881928/attachment-0001.bin>
More information about the cfe-commits
mailing list