]> granicus.if.org Git - clang/commitdiff
Start adding support for Musl.
authorRafael Espindola <rafael.espindola@gmail.com>
Tue, 14 Jun 2016 12:47:24 +0000 (12:47 +0000)
committerRafael Espindola <rafael.espindola@gmail.com>
Tue, 14 Jun 2016 12:47:24 +0000 (12:47 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272662 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains.cpp
test/Driver/linux-ld.c

index eec4174d75318cdbf30c405dfca693d20651e746..fcc6dfe35d59cb2eb21b955ec0089940bb00ba29 100644 (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;
index 15e500a3aeaa82a3e2c6ca1f6161694c19eb8f76..871065517abf1b31f1162a329ecad60663d3105c 100644 (file)
 // 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"