From: Rafael Espindola Date: Tue, 14 Jun 2016 12:47:24 +0000 (+0000) Subject: Start adding support for Musl. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=264ccbe6d72941d86080efcaf4795c12803386d8;p=clang 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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272662 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index eec4174d75..fcc6dfe35d 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -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; diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c index 15e500a3ae..871065517a 100644 --- a/test/Driver/linux-ld.c +++ b/test/Driver/linux-ld.c @@ -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"