Skip to content

Commit 620d2bf

Browse files
committed
[clang] Allow using BareMetal toolchain with LLVM_ENABLE_PER_TARGET_RUNTIME_DIR compiler-rt
If you build compiler-rt with LLVM_ENABLE_PER_TARGET_RUNTIME_DIR then the library filename will be "libclang_rt.builtins.a" instead of "libclang_rt.builtins-<ARCH>.a" The ToolChain::getCompilerRT method uses the "libclang_rt.builtins.a" name if it can find the file in the library directories. If it can't then it falls back to using "libclang_rt.builtins-<ARCH>.a". This change adds the library directory such that "libclang_rt.builtins.a" can be found. Differential Revision: https://reviews.llvm.org/D139822
1 parent f6a96be commit 620d2bf

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

clang/lib/Driver/ToolChains/BareMetal.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ BareMetal::BareMetal(const Driver &D, const llvm::Triple &Triple,
103103
if (!SysRoot.empty()) {
104104
llvm::sys::path::append(SysRoot, "lib");
105105
getFilePaths().push_back(std::string(SysRoot));
106+
getLibraryPaths().push_back(std::string(SysRoot));
106107
}
107108
}
108109

clang/test/Driver/baremetal.cpp

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,3 +340,27 @@
340340
// CHECK-RV32IMAFC-NEXT: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic"
341341
// CHECK-RV32IMAFC-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f{{[/\\]+}}lib"
342342
// CHECK-RV32IMAFC-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f"
343+
344+
// Check that compiler-rt library without the arch filename suffix will
345+
// be used if present.
346+
// RUN: rm -rf %T/baremetal_clang_rt_noarch
347+
// RUN: mkdir -p %T/baremetal_clang_rt_noarch/lib
348+
// RUN: touch %T/baremetal_clang_rt_noarch/lib/libclang_rt.builtins.a
349+
// RUN: %clang %s -### 2>&1 \
350+
// RUN: --target=armv6m-none-eabi \
351+
// RUN: --sysroot=%T/baremetal_clang_rt_noarch \
352+
// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-NOARCH %s
353+
// CHECK-CLANGRT-NOARCH: "-lclang_rt.builtins"
354+
// CHECK-CLANGRT-NOARCH-NOT: "-lclang_rt.builtins-armv6m"
355+
356+
// Check that compiler-rt library with the arch filename suffix will be
357+
// used if present.
358+
// RUN: rm -rf %T/baremetal_clang_rt_arch
359+
// RUN: mkdir -p %T/baremetal_clang_rt_arch/lib
360+
// RUN: touch %T/baremetal_clang_rt_arch/lib/libclang_rt.builtins-armv6m.a
361+
// RUN: %clang %s -### 2>&1 \
362+
// RUN: --target=armv6m-none-eabi \
363+
// RUN: --sysroot=%T/baremetal_clang_rt_arch \
364+
// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-ARCH %s
365+
// CHECK-CLANGRT-ARCH: "-lclang_rt.builtins-armv6m"
366+
// CHECK-CLANGRT-ARCH-NOT: "-lclang_rt.builtins"

0 commit comments

Comments
 (0)