[clang] 620d2bf - [clang] Allow using BareMetal toolchain with LLVM_ENABLE_PER_TARGET_RUNTIME_DIR compiler-rt
Michael Platings via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 12 07:37:06 PST 2022
Author: Michael Platings
Date: 2022-12-12T15:36:06Z
New Revision: 620d2bfdadeb7f4936775422a0e965e7fcdcd204
URL: https://github.com/llvm/llvm-project/commit/620d2bfdadeb7f4936775422a0e965e7fcdcd204
DIFF: https://github.com/llvm/llvm-project/commit/620d2bfdadeb7f4936775422a0e965e7fcdcd204.diff
LOG: [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
Added:
Modified:
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/test/Driver/baremetal.cpp
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/BareMetal.cpp b/clang/lib/Driver/ToolChains/BareMetal.cpp
index 135843463b00b..ac9c7036ad6ef 100644
--- a/clang/lib/Driver/ToolChains/BareMetal.cpp
+++ b/clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -103,6 +103,7 @@ BareMetal::BareMetal(const Driver &D, const llvm::Triple &Triple,
if (!SysRoot.empty()) {
llvm::sys::path::append(SysRoot, "lib");
getFilePaths().push_back(std::string(SysRoot));
+ getLibraryPaths().push_back(std::string(SysRoot));
}
}
diff --git a/clang/test/Driver/baremetal.cpp b/clang/test/Driver/baremetal.cpp
index b5fc45586908d..24890e87c313c 100644
--- a/clang/test/Driver/baremetal.cpp
+++ b/clang/test/Driver/baremetal.cpp
@@ -340,3 +340,27 @@
// CHECK-RV32IMAFC-NEXT: ld{{(.exe)?}}" "{{.*}}.o" "-Bstatic"
// CHECK-RV32IMAFC-SAME: "-L[[SYSROOT:[^"]+]]{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f{{[/\\]+}}lib"
// CHECK-RV32IMAFC-SAME: "-L[[RESOURCE_DIR:[^"]+]]{{[/\\]+}}lib{{[/\\]+}}baremetal{{[/\\]+}}rv32imafc{{[/\\]+}}ilp32f"
+
+// Check that compiler-rt library without the arch filename suffix will
+// be used if present.
+// RUN: rm -rf %T/baremetal_clang_rt_noarch
+// RUN: mkdir -p %T/baremetal_clang_rt_noarch/lib
+// RUN: touch %T/baremetal_clang_rt_noarch/lib/libclang_rt.builtins.a
+// RUN: %clang %s -### 2>&1 \
+// RUN: --target=armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_clang_rt_noarch \
+// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-NOARCH %s
+// CHECK-CLANGRT-NOARCH: "-lclang_rt.builtins"
+// CHECK-CLANGRT-NOARCH-NOT: "-lclang_rt.builtins-armv6m"
+
+// Check that compiler-rt library with the arch filename suffix will be
+// used if present.
+// RUN: rm -rf %T/baremetal_clang_rt_arch
+// RUN: mkdir -p %T/baremetal_clang_rt_arch/lib
+// RUN: touch %T/baremetal_clang_rt_arch/lib/libclang_rt.builtins-armv6m.a
+// RUN: %clang %s -### 2>&1 \
+// RUN: --target=armv6m-none-eabi \
+// RUN: --sysroot=%T/baremetal_clang_rt_arch \
+// RUN: | FileCheck --check-prefix=CHECK-CLANGRT-ARCH %s
+// CHECK-CLANGRT-ARCH: "-lclang_rt.builtins-armv6m"
+// CHECK-CLANGRT-ARCH-NOT: "-lclang_rt.builtins"
More information about the cfe-commits
mailing list