Start adding support for Musl.

The two patches together enable clang to support targets like
"x86_64-pc-linux-musl" and build binaries against musl-libc instead of
glibc. This make it easy for clang to work on some musl-based systems
like Alpine Linux and certain flavors of Gentoo.

Patch by Lei Zhang.

llvm-svn: 272662
This commit is contained in:
Rafael Espindola 2016-06-14 12:47:24 +00:00
parent 66a9d07a86
commit 164fe34e98
2 changed files with 12 additions and 0 deletions

View File

@ -4152,6 +4152,8 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const {
if (Triple.isAndroid())
return Triple.isArch64Bit() ? "/system/bin/linker64" : "/system/bin/linker";
else if (Triple.getEnvironment() == llvm::Triple::Musl)
return "/lib/ld-musl-" + Triple.getArchName().str() + ".so.1";
std::string LibDir;
std::string Loader;

View File

@ -1571,3 +1571,13 @@
// CHECK-ARMV7EB: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
// CHECK-ARMV7EB: "--be8"
// CHECK-ARMV7EB: "-m" "armelfb_linux_eabi"
// Check dynamic-linker for musl-libc
// RUN: %clang %s -### -o %t.o 2>&1 \
// RUN: --target=i386-pc-linux-musl \
// RUN: | FileCheck --check-prefix=CHECK-MUSL32 %s
// RUN: %clang %s -### -o %t.o 2>&1 \
// RUN: --target=x86_64-pc-linux-musl \
// RUN: | FileCheck --check-prefix=CHECK-MUSL64 %s
// CHECK-MUSL32: "-dynamic-linker" "/lib/ld-musl-i386.so.1"
// CHECK-MUSL64: "-dynamic-linker" "/lib/ld-musl-x86_64.so.1"