From ff104a12d61d34af67f12a7a966847c821d7afa8 Mon Sep 17 00:00:00 2001 From: Jiangning Liu Date: Tue, 31 Jul 2012 08:06:29 +0000 Subject: [PATCH] Support ARM hard float (arm-linux-gnueabihf). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161038 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Driver/ToolChains.cpp | 29 +++++++++++++--- lib/Driver/Tools.cpp | 12 +++---- .../ubuntu_12.04_LTS_multiarch_tree/lib/.keep | 0 .../usr/include/.keep | 0 .../usr/lib/.keep | 0 .../usr/lib/arm-linux-gnueabi/crt1.o | 0 .../usr/lib/arm-linux-gnueabi/crti.o | 0 .../usr/lib/arm-linux-gnueabi/crtn.o | 0 .../usr/lib/arm-linux-gnueabihf/crt1.o | 0 .../usr/lib/arm-linux-gnueabihf/crti.o | 0 .../usr/lib/arm-linux-gnueabihf/crtn.o | 0 .../gcc/arm-linux-gnueabi/4.6.1/crtbegin.o | 0 .../lib/gcc/arm-linux-gnueabi/4.6.1/crtend.o | 0 .../gcc/arm-linux-gnueabihf/4.6.3/crtbegin.o | 0 .../gcc/arm-linux-gnueabihf/4.6.3/crtend.o | 0 test/Driver/linux-ld.c | 33 +++++++++++++++++++ 16 files changed, 61 insertions(+), 13 deletions(-) create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/.keep create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/.keep create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/.keep create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crt1.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crti.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crtn.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crt1.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crti.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crtn.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtbegin.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtend.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtbegin.o create mode 100644 test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtend.o diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 4f3d33e901..45b46df651 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -1103,6 +1103,9 @@ Generic_GCC::GCCInstallationDetector::GCCInstallationDetector( "arm-linux-gnueabi", "arm-linux-androideabi" }; + static const char *const ARMHFTriples[] = { + "arm-linux-gnueabihf", + }; static const char *const X86_64LibDirs[] = { "/lib64", "/lib" }; static const char *const X86_64Triples[] = { @@ -1159,8 +1162,13 @@ Generic_GCC::GCCInstallationDetector::GCCInstallationDetector( case llvm::Triple::arm: case llvm::Triple::thumb: LibDirs.append(ARMLibDirs, ARMLibDirs + llvm::array_lengthof(ARMLibDirs)); - TripleAliases.append( - ARMTriples, ARMTriples + llvm::array_lengthof(ARMTriples)); + if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) { + TripleAliases.append( + ARMHFTriples, ARMHFTriples + llvm::array_lengthof(ARMHFTriples)); + } else { + TripleAliases.append( + ARMTriples, ARMTriples + llvm::array_lengthof(ARMTriples)); + } break; case llvm::Triple::x86_64: LibDirs.append( @@ -1912,8 +1920,13 @@ static std::string getMultiarchTriple(const llvm::Triple TargetTriple, // regardless of what the actual target triple is. case llvm::Triple::arm: case llvm::Triple::thumb: - if (llvm::sys::fs::exists(SysRoot + "/lib/arm-linux-gnueabi")) - return "arm-linux-gnueabi"; + if (TargetTriple.getEnvironment() == llvm::Triple::GNUEABIHF) { + if (llvm::sys::fs::exists(SysRoot + "/lib/arm-linux-gnueabihf")) + return "arm-linux-gnueabihf"; + } else { + if (llvm::sys::fs::exists(SysRoot + "/lib/arm-linux-gnueabi")) + return "arm-linux-gnueabi"; + } return TargetTriple.str(); case llvm::Triple::x86: if (llvm::sys::fs::exists(SysRoot + "/lib/i386-linux-gnu")) @@ -2161,6 +2174,9 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs, const StringRef ARMMultiarchIncludeDirs[] = { "/usr/include/arm-linux-gnueabi" }; + const StringRef ARMHFMultiarchIncludeDirs[] = { + "/usr/include/arm-linux-gnueabihf" + }; const StringRef MIPSMultiarchIncludeDirs[] = { "/usr/include/mips-linux-gnu" }; @@ -2179,7 +2195,10 @@ void Linux::AddClangSystemIncludeArgs(const ArgList &DriverArgs, } else if (getTriple().getArch() == llvm::Triple::x86) { MultiarchIncludeDirs = X86MultiarchIncludeDirs; } else if (getTriple().getArch() == llvm::Triple::arm) { - MultiarchIncludeDirs = ARMMultiarchIncludeDirs; + if (getTriple().getEnvironment() == llvm::Triple::GNUEABIHF) + MultiarchIncludeDirs = ARMHFMultiarchIncludeDirs; + else + MultiarchIncludeDirs = ARMMultiarchIncludeDirs; } else if (getTriple().getArch() == llvm::Triple::mips) { MultiarchIncludeDirs = MIPSMultiarchIncludeDirs; } else if (getTriple().getArch() == llvm::Triple::mipsel) { diff --git a/lib/Driver/Tools.cpp b/lib/Driver/Tools.cpp index 189ff5954a..a096382400 100644 --- a/lib/Driver/Tools.cpp +++ b/lib/Driver/Tools.cpp @@ -629,16 +629,11 @@ static StringRef getARMFloatABI(const Driver &D, break; } - case llvm::Triple::Linux: { - if (Triple.getEnvironment() == llvm::Triple::GNUEABI) { - FloatABI = "softfp"; - break; - } - } - // fall through - default: switch(Triple.getEnvironment()) { + case llvm::Triple::GNUEABIHF: + FloatABI = "hard"; + break; case llvm::Triple::GNUEABI: FloatABI = "softfp"; break; @@ -685,6 +680,7 @@ void Clang::AddARMTargetArgs(const ArgList &Args, switch(Triple.getEnvironment()) { case llvm::Triple::ANDROIDEABI: case llvm::Triple::GNUEABI: + case llvm::Triple::GNUEABIHF: ABIName = "aapcs-linux"; break; case llvm::Triple::EABI: diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/.keep b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/lib/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/.keep b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/include/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/.keep b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crt1.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crt1.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crti.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crti.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crtn.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabi/crtn.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crt1.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crt1.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crti.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crti.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crtn.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-gnueabihf/crtn.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtbegin.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtbegin.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtend.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtend.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtbegin.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtbegin.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtend.o b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtend.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c index cf219105d2..a6831b62a9 100644 --- a/test/Driver/linux-ld.c +++ b/test/Driver/linux-ld.c @@ -174,6 +174,39 @@ // CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/lib" // CHECK-UBUNTU-11-04: "-L[[SYSROOT]]/usr/lib" // +// Check multi arch support on Ubuntu 12.04 LTS. +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-unknown-linux-gnueabihf \ +// RUN: --sysroot=%S/Inputs/ubuntu_12.04_LTS_multiarch_tree \ +// RUN: | FileCheck --check-prefix=CHECK-UBUNTU-12-04-ARM-HF %s +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../arm-linux-gnueabihf/crt1.o" +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../arm-linux-gnueabihf/crti.o" +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtbegin.o" +// CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabihf/4.6.3" +// CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../arm-linux-gnueabihf" +// CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/lib/arm-linux-gnueabihf" +// CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/usr/lib/arm-linux-gnueabihf" +// CHECK-UBUNTU-12-04-ARM-HF: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../.." +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtend.o" +// CHECK-UBUNTU-12-04-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../arm-linux-gnueabihf/crtn.o" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -target arm-unknown-linux-gnueabi \ +// RUN: --sysroot=%S/Inputs/ubuntu_12.04_LTS_multiarch_tree \ +// RUN: | FileCheck --check-prefix=CHECK-UBUNTU-12-04-ARM %s +// CHECK-UBUNTU-12-04-ARM: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../arm-linux-gnueabi/crt1.o" +// CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../arm-linux-gnueabi/crti.o" +// CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtbegin.o" +// CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabi/4.6.1" +// CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../arm-linux-gnueabi" +// CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/lib/arm-linux-gnueabi" +// CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/usr/lib/arm-linux-gnueabi" +// CHECK-UBUNTU-12-04-ARM: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../.." +// CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/crtend.o" +// CHECK-UBUNTU-12-04-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.1/../../../arm-linux-gnueabi/crtn.o" +// // Test the setup that shipped in SUSE 10.3 on ppc64. // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: -target powerpc64-suse-linux \ -- 2.40.0