[PATCH] D89327: fixes compiler-rt bug when printing libgcc for baremetal
Manoj Gupta via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 14 10:36:28 PDT 2020
This revision was automatically updated to reflect the committed changes.
Closed by commit rG18432bea7648: [Driver]: fix compiler-rt path when printing libgcc for baremetal (authored by cjdb, committed by manojgupta).
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Changed prior to commit:
https://reviews.llvm.org/D89327?vs=297924&id=298180#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D89327/new/
https://reviews.llvm.org/D89327
Files:
clang/include/clang/Driver/ToolChain.h
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/lib/Driver/ToolChains/BareMetal.h
clang/test/Driver/print-libgcc-file-name-clangrt.c
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
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/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<std::string> getRuntimePath() const;
@@ -435,7 +435,7 @@
std::string getArchSpecificLibPath() const;
// Returns <OSname> 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);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89327.298180.patch
Type: text/x-patch
Size: 4181 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20201014/6fa7ad44/attachment-0001.bin>
More information about the cfe-commits
mailing list