Skip to content

Commit 51c5add

Browse files
committed
Extending Baremetal toolchain's support for the rtlib option.
Differential Revision: https://reviews.llvm.org/D87164 Patch by Manuel Carrasco!
1 parent 3c2e2df commit 51c5add

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

clang/lib/Driver/ToolChains/BareMetal.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,17 @@ void BareMetal::AddCXXStdlibLibArgs(const ArgList &Args,
156156

157157
void BareMetal::AddLinkRuntimeLib(const ArgList &Args,
158158
ArgStringList &CmdArgs) const {
159-
CmdArgs.push_back(Args.MakeArgString("-lclang_rt.builtins-" +
160-
getTriple().getArchName()));
159+
ToolChain::RuntimeLibType RLT = GetRuntimeLibType(Args);
160+
switch (RLT) {
161+
case ToolChain::RLT_CompilerRT:
162+
CmdArgs.push_back(
163+
Args.MakeArgString("-lclang_rt.builtins-" + getTriple().getArchName()));
164+
return;
165+
case ToolChain::RLT_Libgcc:
166+
CmdArgs.push_back("-lgcc");
167+
return;
168+
}
169+
llvm_unreachable("Unhandled RuntimeLibType.");
161170
}
162171

163172
void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,

clang/test/Driver/baremetal.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,7 @@
8383
// RUN: %clangxx -target arm-none-eabi -mthread-model posix -v 2>&1 \
8484
// RUN: | FileCheck %s --check-prefix=CHECK-THREAD-MODEL-POSIX
8585
// CHECK-THREAD-MODEL-POSIX: Thread model: posix
86+
87+
// RUN: %clang -### -target arm-none-eabi -rtlib=libgcc -v %s 2>&1 \
88+
// RUN: | FileCheck %s --check-prefix=CHECK-RTLIB-GCC
89+
// CHECK-RTLIB-GCC: -lgcc

0 commit comments

Comments
 (0)