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();
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();
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits