phosek created this revision. Herald added a subscriber: dberris. This makes it possible to print the name of compiler-rt libraries by using simply clang -print-file-name=libclang_rt.${runtime}-${arch}.so same as other libraries, without having to know the details of the resource directory organization.
Repository: rL LLVM https://reviews.llvm.org/D35820 Files: include/clang/Driver/ToolChain.h lib/Driver/Driver.cpp lib/Driver/ToolChain.cpp Index: lib/Driver/ToolChain.cpp =================================================================== --- lib/Driver/ToolChain.cpp +++ lib/Driver/ToolChain.cpp @@ -308,6 +308,13 @@ return TC.getArchName(); } +std::string ToolChain::getCompilerRTPath() const { + SmallString<128> Path(getDriver().ResourceDir); + StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS(); + llvm::sys::path::append(Path, "lib", OSLibName); + return Path.str(); +} + std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component, bool Shared) const { const llvm::Triple &TT = getTriple(); @@ -320,9 +327,7 @@ const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so") : (IsITANMSVCWindows ? ".lib" : ".a"); - SmallString<128> Path(getDriver().ResourceDir); - StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS(); - llvm::sys::path::append(Path, "lib", OSLibName); + SmallString<128> Path(getCompilerRTPath()); llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" + Arch + Env + Suffix); return Path.str(); Index: lib/Driver/Driver.cpp =================================================================== --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -3684,6 +3684,11 @@ if (llvm::sys::fs::exists(Twine(P))) return P.str(); + P = TC.getCompilerRTPath(); + llvm::sys::path::append(P, Name); + if (llvm::sys::fs::exists(Twine(P))) + return P.str(); + for (const std::string &Dir : TC.getFilePaths()) { if (Dir.empty()) continue; Index: include/clang/Driver/ToolChain.h =================================================================== --- include/clang/Driver/ToolChain.h +++ include/clang/Driver/ToolChain.h @@ -298,6 +298,8 @@ return ToolChain::CST_Libstdcxx; } + virtual std::string getCompilerRTPath() const; + virtual std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component, bool Shared = false) const;
Index: lib/Driver/ToolChain.cpp =================================================================== --- lib/Driver/ToolChain.cpp +++ lib/Driver/ToolChain.cpp @@ -308,6 +308,13 @@ return TC.getArchName(); } +std::string ToolChain::getCompilerRTPath() const { + SmallString<128> Path(getDriver().ResourceDir); + StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS(); + llvm::sys::path::append(Path, "lib", OSLibName); + return Path.str(); +} + std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component, bool Shared) const { const llvm::Triple &TT = getTriple(); @@ -320,9 +327,7 @@ const char *Suffix = Shared ? (Triple.isOSWindows() ? ".dll" : ".so") : (IsITANMSVCWindows ? ".lib" : ".a"); - SmallString<128> Path(getDriver().ResourceDir); - StringRef OSLibName = Triple.isOSFreeBSD() ? "freebsd" : getOS(); - llvm::sys::path::append(Path, "lib", OSLibName); + SmallString<128> Path(getCompilerRTPath()); llvm::sys::path::append(Path, Prefix + Twine("clang_rt.") + Component + "-" + Arch + Env + Suffix); return Path.str(); Index: lib/Driver/Driver.cpp =================================================================== --- lib/Driver/Driver.cpp +++ lib/Driver/Driver.cpp @@ -3684,6 +3684,11 @@ if (llvm::sys::fs::exists(Twine(P))) return P.str(); + P = TC.getCompilerRTPath(); + llvm::sys::path::append(P, Name); + if (llvm::sys::fs::exists(Twine(P))) + return P.str(); + for (const std::string &Dir : TC.getFilePaths()) { if (Dir.empty()) continue; Index: include/clang/Driver/ToolChain.h =================================================================== --- include/clang/Driver/ToolChain.h +++ include/clang/Driver/ToolChain.h @@ -298,6 +298,8 @@ return ToolChain::CST_Libstdcxx; } + virtual std::string getCompilerRTPath() const; + virtual std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component, bool Shared = false) const;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits