[PATCH] D139822: Allow using BareMetal toolchain with LLVM_ENABLE_PER_TARGET_RUNTIME_DIR compiler-rt
Michael Platings via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 12 02:24:30 PST 2022
michaelplatings created this revision.
michaelplatings added reviewers: abidh, jroelofs.
michaelplatings added a project: clang.
Herald added subscribers: dberris, ki.stfu.
Herald added a project: All.
michaelplatings requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
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.
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D139822
Files:
clang/lib/Driver/ToolChains/BareMetal.cpp
clang/test/Driver/baremetal.cpp
Index: clang/test/Driver/baremetal.cpp
===================================================================
--- clang/test/Driver/baremetal.cpp
+++ 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"
Index: clang/lib/Driver/ToolChains/BareMetal.cpp
===================================================================
--- clang/lib/Driver/ToolChains/BareMetal.cpp
+++ clang/lib/Driver/ToolChains/BareMetal.cpp
@@ -103,6 +103,7 @@
if (!SysRoot.empty()) {
llvm::sys::path::append(SysRoot, "lib");
getFilePaths().push_back(std::string(SysRoot));
+ getLibraryPaths().push_back(std::string(SysRoot));
}
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139822.482040.patch
Type: text/x-patch
Size: 2012 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20221212/c275d84b/attachment.bin>
More information about the cfe-commits
mailing list