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();