Index: clang/include/clang/Driver/ToolChain.h =================================================================== --- clang/include/clang/Driver/ToolChain.h +++ clang/include/clang/Driver/ToolChain.h @@ -419,10 +419,10 @@ getCompilerRTArgString(const llvm::opt::ArgList &Args, StringRef Component, FileType Type = ToolChain::FT_Static) const; - std::string getCompilerRTBasename(const llvm::opt::ArgList &Args, - StringRef Component, - FileType Type = ToolChain::FT_Static, - bool AddArch = true) const; + virtual std::string + getCompilerRTBasename(const llvm::opt::ArgList &Args, StringRef Component, + FileType Type = ToolChain::FT_Static, + bool AddArch = true) const; // Returns target specific runtime path if it exists. virtual Optional getRuntimePath() const; @@ -435,7 +435,7 @@ std::string getArchSpecificLibPath() const; // Returns part of above. - StringRef getOSLibName() const; + virtual StringRef getOSLibName() const; /// needsProfileRT - returns true if instrumentation profile is on. static bool needsProfileRT(const llvm::opt::ArgList &Args); Index: clang/lib/Driver/ToolChains/BareMetal.h =================================================================== --- clang/lib/Driver/ToolChains/BareMetal.h +++ clang/lib/Driver/ToolChains/BareMetal.h @@ -23,7 +23,7 @@ public: BareMetal(const Driver &D, const llvm::Triple &Triple, const llvm::opt::ArgList &Args); - ~BareMetal() override; + ~BareMetal() override = default; static bool handlesTarget(const llvm::Triple &Triple); protected: @@ -37,6 +37,14 @@ bool isPICDefaultForced() const override { return false; } bool SupportsProfiling() const override { return false; } + StringRef getOSLibName() const override { return "baremetal"; } + + std::string getCompilerRTPath() const override; + std::string getCompilerRTBasename(const llvm::opt::ArgList &Args, + StringRef Component, + FileType Type = ToolChain::FT_Static, + bool AddArch = true) const override; + RuntimeLibType GetDefaultRuntimeLibType() const override { return ToolChain::RLT_CompilerRT; } Index: clang/lib/Driver/ToolChains/BareMetal.cpp =================================================================== --- clang/lib/Driver/ToolChains/BareMetal.cpp +++ clang/lib/Driver/ToolChains/BareMetal.cpp @@ -35,8 +35,6 @@ getProgramPaths().push_back(getDriver().Dir); } -BareMetal::~BareMetal() {} - /// Is the triple {arm,thumb}-none-none-{eabi,eabihf} ? static bool isARMBareMetal(const llvm::Triple &Triple) { if (Triple.getArch() != llvm::Triple::arm && @@ -64,6 +62,13 @@ return new tools::baremetal::Linker(*this); } +std::string BareMetal::getCompilerRTPath() const { return getRuntimesDir(); } + +std::string BareMetal::getCompilerRTBasename(const llvm::opt::ArgList &, + StringRef, FileType, bool) const { + return ("libclang_rt.builtins-" + getTriple().getArchName() + ".a").str(); +} + std::string BareMetal::getRuntimesDir() const { SmallString<128> Dir(getDriver().ResourceDir); llvm::sys::path::append(Dir, "lib", "baremetal"); Index: clang/test/Driver/print-libgcc-file-name-clangrt.c =================================================================== --- clang/test/Driver/print-libgcc-file-name-clangrt.c +++ clang/test/Driver/print-libgcc-file-name-clangrt.c @@ -42,3 +42,9 @@ // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ // RUN: | FileCheck --check-prefix=CHECK-CLANGRT-ARM-ABI %s // CHECK-CLANGRT-ARM-ABI: libclang_rt.builtins-armhf.a + +// RUN: %clang -rtlib=compiler-rt -print-libgcc-file-name 2>&1 \ +// RUN: --target=armv7m-none-eabi \ +// RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \ +// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-ARM-BAREMETAL %s +// CHECK-CLANGRT-ARM-BAREMETAL: libclang_rt.builtins-armv7m.a