r272662 - Start adding support for Musl.
Rafael Espindola via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 14 05:47:25 PDT 2016
Author: rafael
Date: Tue Jun 14 07:47:24 2016
New Revision: 272662
URL: http://llvm.org/viewvc/llvm-project?rev=272662&view=rev
Log:
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.
Modified:
cfe/trunk/lib/Driver/ToolChains.cpp
cfe/trunk/test/Driver/linux-ld.c
Modified: cfe/trunk/lib/Driver/ToolChains.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains.cpp?rev=272662&r1=272661&r2=272662&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains.cpp Tue Jun 14 07:47:24 2016
@@ -4152,6 +4152,8 @@ std::string Linux::getDynamicLinker(cons
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;
Modified: cfe/trunk/test/Driver/linux-ld.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-ld.c?rev=272662&r1=272661&r2=272662&view=diff
==============================================================================
--- cfe/trunk/test/Driver/linux-ld.c (original)
+++ cfe/trunk/test/Driver/linux-ld.c Tue Jun 14 07:47:24 2016
@@ -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"
More information about the cfe-commits
mailing list