From 1812aa02dec992389e1567803b4a18149877bc36 Mon Sep 17 00:00:00 2001 From: Diana Picus Date: Mon, 8 Aug 2016 08:27:36 +0000 Subject: [PATCH] Fix two bugs for musl-libc on ARM Bug 1: triples like armv7-pc-linux-musl use the wrong linker name ld-musl-armv7.so.1; the right name should be ld-musl-arm.so.1, disregarding the subarch field. Bug 2: when compiler option -mhard-float is used, we should use the "hardfloat" linker, no matter whether the triple itself mentions "hardfloat". Patch by Lei Zhang! Differential Revision: https://reviews.llvm.org/D22904 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@277985 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChains.cpp | 13 +++++++++++-- test/Driver/linux-ld.c | 12 ++++++++++++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index d0477f7..175acd8 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -4274,19 +4274,28 @@ std::string Linux::getDynamicLinker(const ArgList &Args) const { if (Triple.isAndroid()) return Triple.isArch64Bit() ? "/system/bin/linker64" : "/system/bin/linker"; - else if (Triple.isMusl()) { + + if (Triple.isMusl()) { std::string ArchName; + bool IsArm = false; + switch (Arch) { + case llvm::Triple::arm: case llvm::Triple::thumb: ArchName = "arm"; + IsArm = true; break; + case llvm::Triple::armeb: case llvm::Triple::thumbeb: ArchName = "armeb"; + IsArm = true; break; default: ArchName = Triple.getArchName().str(); } - if (Triple.getEnvironment() == llvm::Triple::MuslEABIHF) + if (IsArm && + (Triple.getEnvironment() == llvm::Triple::MuslEABIHF || + tools::arm::getARMFloatABI(*this, Args) == tools::arm::FloatABI::Hard)) ArchName += "hf"; return "/lib/ld-musl-" + ArchName + ".so.1"; diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c index 87bd55f..60b30dd 100644 --- a/test/Driver/linux-ld.c +++ b/test/Driver/linux-ld.c @@ -1613,24 +1613,36 @@ // RUN: --target=thumb-pc-linux-musleabihf \ // RUN: | FileCheck --check-prefix=CHECK-MUSL-ARMHF %s // RUN: %clang %s -### -o %t.o 2>&1 \ +// RUN: --target=thumbv7-pc-linux-musleabi -mhard-float \ +// RUN: | FileCheck --check-prefix=CHECK-MUSL-ARMHF %s +// RUN: %clang %s -### -o %t.o 2>&1 \ // RUN: --target=thumbeb-pc-linux-musleabi \ // RUN: | FileCheck --check-prefix=CHECK-MUSL-ARMEB %s // RUN: %clang %s -### -o %t.o 2>&1 \ // RUN: --target=thumbeb-pc-linux-musleabihf \ // RUN: | FileCheck --check-prefix=CHECK-MUSL-ARMEBHF %s // RUN: %clang %s -### -o %t.o 2>&1 \ +// RUN: --target=thumbv7eb-pc-linux-musleabi -mhard-float \ +// RUN: | FileCheck --check-prefix=CHECK-MUSL-ARMEBHF %s +// RUN: %clang %s -### -o %t.o 2>&1 \ // RUN: --target=arm-pc-linux-musleabi \ // RUN: | FileCheck --check-prefix=CHECK-MUSL-ARM %s // RUN: %clang %s -### -o %t.o 2>&1 \ // RUN: --target=arm-pc-linux-musleabihf \ // RUN: | FileCheck --check-prefix=CHECK-MUSL-ARMHF %s // RUN: %clang %s -### -o %t.o 2>&1 \ +// RUN: --target=armv7-pc-linux-musleabi -mhard-float \ +// RUN: | FileCheck --check-prefix=CHECK-MUSL-ARMHF %s +// RUN: %clang %s -### -o %t.o 2>&1 \ // RUN: --target=armeb-pc-linux-musleabi \ // RUN: | FileCheck --check-prefix=CHECK-MUSL-ARMEB %s // RUN: %clang %s -### -o %t.o 2>&1 \ // RUN: --target=armeb-pc-linux-musleabihf \ // RUN: | FileCheck --check-prefix=CHECK-MUSL-ARMEBHF %s // RUN: %clang %s -### -o %t.o 2>&1 \ +// RUN: --target=armv7eb-pc-linux-musleabi -mhard-float \ +// RUN: | FileCheck --check-prefix=CHECK-MUSL-ARMEBHF %s +// RUN: %clang %s -### -o %t.o 2>&1 \ // RUN: --target=aarch64-pc-linux-musleabi \ // RUN: | FileCheck --check-prefix=CHECK-MUSL-AARCH64 %s // RUN: %clang %s -### -o %t.o 2>&1 \