diff options
author | zero9178 <markus.boeck02@gmail.com> | 2021-02-23 22:34:27 +0100 |
---|---|---|
committer | zero9178 <markus.boeck02@gmail.com> | 2021-02-23 22:35:19 +0100 |
commit | 7f9d5d6e444c91ce6f2e377b312ac573dfc6779a (patch) | |
tree | 46db51e921677ecbd3f39d190ea57464e6730855 /clang/lib/Driver/ToolChain.cpp | |
parent | 979ca1c05f83114483caec3e6d1b75daae86da79 (diff) | |
download | llvm-7f9d5d6e444c91ce6f2e377b312ac573dfc6779a.zip llvm-7f9d5d6e444c91ce6f2e377b312ac573dfc6779a.tar.gz llvm-7f9d5d6e444c91ce6f2e377b312ac573dfc6779a.tar.bz2 |
[Driver][Windows] Support per-target runtimes dir layout for profile instr generate
When targeting a MSVC triple, --dependant-libs with the name of the clang runtime library for profiling is added to the command line args. In it's current implementations clang_rt.profile-<ARCH> is chosen as the name. When building a distribution using LLVM_ENABLE_PER_TARGET_RUNTIME_DIR this fails, due to the runtime file names not having an architecture suffix in the filename.
This patch refactors getCompilerRT and getCompilerRTBasename to always consider per-target runtime directories. getCompilerRTBasename now simply returns the filename component of the path found by getCompilerRT
Differential Revision: https://reviews.llvm.org/D96638
Diffstat (limited to 'clang/lib/Driver/ToolChain.cpp')
-rw-r--r-- | clang/lib/Driver/ToolChain.cpp | 28 |
1 files changed, 19 insertions, 9 deletions
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 372be61..2c8dc0e 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -413,10 +413,12 @@ std::string ToolChain::getCompilerRTPath() const { return std::string(Path.str()); } -std::string ToolChain::getCompilerRTBasename(const ArgList &Args, - StringRef Component, FileType Type, - bool AddArch) const { - const llvm::Triple &TT = getTriple(); +static std::string buildCompilerRTBasename(const ToolChain &toolchain, + const ArgList &Args, + StringRef Component, + ToolChain::FileType Type, + bool AddArch) { + const llvm::Triple &TT = toolchain.getTriple(); bool IsITANMSVCWindows = TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment(); @@ -431,26 +433,33 @@ std::string ToolChain::getCompilerRTBasename(const ArgList &Args, Suffix = IsITANMSVCWindows ? ".lib" : ".a"; break; case ToolChain::FT_Shared: - Suffix = Triple.isOSWindows() - ? (Triple.isWindowsGNUEnvironment() ? ".dll.a" : ".lib") + Suffix = TT.isOSWindows() + ? (TT.isWindowsGNUEnvironment() ? ".dll.a" : ".lib") : ".so"; break; } std::string ArchAndEnv; if (AddArch) { - StringRef Arch = getArchNameForCompilerRTLib(*this, Args); + StringRef Arch = getArchNameForCompilerRTLib(toolchain, Args); const char *Env = TT.isAndroid() ? "-android" : ""; ArchAndEnv = ("-" + Arch + Env).str(); } return (Prefix + Twine("clang_rt.") + Component + ArchAndEnv + Suffix).str(); } +std::string ToolChain::getCompilerRTBasename(const ArgList &Args, + StringRef Component, + FileType Type) const { + std::string absolutePath = getCompilerRT(Args, Component, Type); + return llvm::sys::path::filename(absolutePath).str(); +} + std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component, FileType Type) const { // Check for runtime files in the new layout without the architecture first. std::string CRTBasename = - getCompilerRTBasename(Args, Component, Type, /*AddArch=*/false); + buildCompilerRTBasename(*this, Args, Component, Type, /*AddArch=*/false); for (const auto &LibPath : getLibraryPaths()) { SmallString<128> P(LibPath); llvm::sys::path::append(P, CRTBasename); @@ -460,7 +469,8 @@ std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component, // Fall back to the old expected compiler-rt name if the new one does not // exist. - CRTBasename = getCompilerRTBasename(Args, Component, Type, /*AddArch=*/true); + CRTBasename = + buildCompilerRTBasename(*this, Args, Component, Type, /*AddArch=*/true); SmallString<128> Path(getCompilerRTPath()); llvm::sys::path::append(Path, CRTBasename); return std::string(Path.str()); |