Skip to content

Commit 9a88ff0

Browse files
author
Kostiantyn Lazukin
committed
[Driver] Search for compiler-rt libraries in sysroot/lib if not found in the resource directory
This patch improves support for embedded Linux toolchains with multiple sysroots, each containing different built-in libraries. If compiler-rt libraries are not found in the resource directory, the Clang driver will fallback to searching in the sysroot/lib directory. This change preserves the standard behavior for regular Linux toolchains while allowing greater flexibility in toolchains with multiple sysroots.
1 parent 4dd7fea commit 9a88ff0

File tree

9 files changed

+13
-0
lines changed

9 files changed

+13
-0
lines changed

clang/lib/Driver/ToolChains/Linux.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,8 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
354354

355355
addPathIfExists(D, concat(SysRoot, "/lib"), Paths);
356356
addPathIfExists(D, concat(SysRoot, "/usr/lib"), Paths);
357+
358+
addPathIfExists(D, concat(SysRoot, "/lib"), getLibraryPaths());
357359
}
358360

359361
ToolChain::RuntimeLibType Linux::GetDefaultRuntimeLibType() const {

clang/test/Driver/Inputs/musl_sysroot_with_builtins/lib/Scrt1.o

Whitespace-only changes.

clang/test/Driver/Inputs/musl_sysroot_with_builtins/lib/clang_rt.crtbegin.o

Whitespace-only changes.

clang/test/Driver/Inputs/musl_sysroot_with_builtins/lib/clang_rt.crtend.o

Whitespace-only changes.

clang/test/Driver/Inputs/musl_sysroot_with_builtins/lib/crti.o

Whitespace-only changes.

clang/test/Driver/Inputs/musl_sysroot_with_builtins/lib/crtn.o

Whitespace-only changes.

clang/test/Driver/Inputs/musl_sysroot_with_builtins/lib/libclang_rt.builtins.a

Whitespace-only changes.

clang/test/Driver/Inputs/resource_dir_empty/keep

Whitespace-only changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %clang -### %s 2>&1 \
2+
// RUN: --target=aarch64-unknown-linux-musl \
3+
// RUN: -ccc-install-dir %S/Inputs/basic_linux_tree/usr/bin \
4+
// RUN: -resource-dir=%S/Inputs/resource_dir_empty \
5+
// RUN: --sysroot=%S/Inputs/musl_sysroot_with_builtins \
6+
// RUN: -static \
7+
// RUN: -rtlib=compiler-rt \
8+
// RUN: | FileCheck %s
9+
10+
// CHECK-DAG: "--sysroot={{[^"]+}}/Inputs/musl_sysroot_with_builtins"
11+
// CHECK-DAG: "{{[^"]+}}/Inputs/musl_sysroot_with_builtins/lib/libclang_rt.builtins.a"

0 commit comments

Comments
 (0)