[cfe-commits] [PATCH] Support ARM hard float (arm-linux-gnueabihf) in clang driver
Jiangning Liu
liujiangning1 at gmail.com
Fri Jul 27 08:05:22 PDT 2012
Yes. It is changed like this on purpose. One is for ARM native build, and the other is for cross build.
Thanks,
-Jiangning
在 2012-7-27,下午9:49,Rafael Espíndola <rafael.espindola at gmail.com> 写道:
> The patch also changes non hf bits:
>
> const StringRef ARMMultiarchIncludeDirs[] = {
> - "/usr/include/arm-linux-gnueabi"
> + "/usr/include/arm-linux-gnueabi",
> + "/usr/arm-linux-gnueabi/include"
> + };
>
> Is that intentional?
>
> On 26 July 2012 04:33, Jiangning Liu <jiangning.liu at arm.com> wrote:
>> PING... Who can help to review this piece of code change?
>>
>> Thanks,
>> -Jiangning
>>
>>> -----Original Message-----
>>> From: cfe-commits-bounces at cs.uiuc.edu [mailto:cfe-commits-
>>> bounces at cs.uiuc.edu] On Behalf Of Jiangning Liu
>>> Sent: Friday, July 13, 2012 4:07 PM
>>> To: cfe-commits at cs.uiuc.edu
>>> Subject: [cfe-commits] [PATCH] Support ARM hard float (arm-linux-
>>> gnueabihf) in clang driver
>>>
>>> Hi,
>>>
>>> Clang driver doesn't support folder structure for ARM hard float
>>> architecture yet, so this patch intends to add this support. With this
>>> patch, Clang driver will be able to find correct library paths for
>>> target arm-linux-gnueabihf. A new test input folder is added for
>>> ubuntu_12.04_LTS_multiarch_tree accordingly.
>>>
>>> Thanks,
>>> -Jiangning
>>>
>>> diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index
>>> b858c3e..ecaab40 100644
>>> --- a/lib/Driver/ToolChains.cpp
>>> +++ b/lib/Driver/ToolChains.cpp
>>> @@ -1098,6 +1098,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[] = { @@ -1154,8 +1157,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(
>>> @@ -1907,8 +1915,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")) @@ -
>>> 2154,7 +2167,12 @@ void Linux::AddClangSystemIncludeArgs(const ArgList
>>> &DriverArgs,
>>> "/usr/include/i486-linux-gnu"
>>> };
>>> const StringRef ARMMultiarchIncludeDirs[] = {
>>> - "/usr/include/arm-linux-gnueabi"
>>> + "/usr/include/arm-linux-gnueabi",
>>> + "/usr/arm-linux-gnueabi/include"
>>> + };
>>> + const StringRef ARMHFMultiarchIncludeDirs[] = {
>>> + "/usr/include/arm-linux-gnueabihf",
>>> + "/usr/arm-linux-gnueabihf/include"
>>> };
>>> const StringRef MIPSMultiarchIncludeDirs[] = {
>>> "/usr/include/mips-linux-gnu"
>>> @@ -2174,7 +2192,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 old mode 100644 new
>>> mode 100755 index 66d792f..7a365c0
>>> --- 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 0000000..e69de29
>>> 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 0000000..e69de29
>>> 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 0000000..e69de29
>>> diff --git
>>> a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-
>>> gnuea
>>> bi/crt1.o
>>> b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-
>>> gnuea
>>> bi/crt1.o
>>> new file mode 100644
>>> index 0000000..e69de29
>>> diff --git
>>> a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-
>>> gnuea
>>> bi/crti.o
>>> b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-
>>> gnuea
>>> bi/crti.o
>>> new file mode 100644
>>> index 0000000..e69de29
>>> diff --git
>>> a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-
>>> gnuea
>>> bi/crtn.o
>>> b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-
>>> gnuea
>>> bi/crtn.o
>>> new file mode 100644
>>> index 0000000..e69de29
>>> diff --git
>>> a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-
>>> gnuea
>>> bihf/crt1.o
>>> b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-
>>> gnuea
>>> bihf/crt1.o
>>> new file mode 100644
>>> index 0000000..e69de29
>>> diff --git
>>> a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-
>>> gnuea
>>> bihf/crti.o
>>> b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-
>>> gnuea
>>> bihf/crti.o
>>> new file mode 100644
>>> index 0000000..e69de29
>>> diff --git
>>> a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-
>>> gnuea
>>> bihf/crtn.o
>>> b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/arm-linux-
>>> gnuea
>>> bihf/crtn.o
>>> new file mode 100644
>>> index 0000000..e69de29
>>> diff --git
>>> a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-
>>> linux-g
>>> nueabi/4.6.1/crtbegin.o
>>> b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-
>>> linux-g
>>> nueabi/4.6.1/crtbegin.o
>>> new file mode 100644
>>> index 0000000..e69de29
>>> diff --git
>>> a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-
>>> linux-g
>>> nueabi/4.6.1/crtend.o
>>> b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-
>>> linux-g
>>> nueabi/4.6.1/crtend.o
>>> new file mode 100644
>>> index 0000000..e69de29
>>> diff --git
>>> a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-
>>> linux-g
>>> nueabihf/4.6.3/crtbegin.o
>>> b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-
>>> linux-g
>>> nueabihf/4.6.3/crtbegin.o
>>> new file mode 100644
>>> index 0000000..e69de29
>>> diff --git
>>> a/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-
>>> linux-g
>>> nueabihf/4.6.3/crtend.o
>>> b/test/Driver/Inputs/ubuntu_12.04_LTS_multiarch_tree/usr/lib/gcc/arm-
>>> linux-g
>>> nueabihf/4.6.3/crtend.o
>>> new file mode 100644
>>> index 0000000..e69de29
>>> diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c index
>>> a9decfd..89f3bc3 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/c
>>> rt1.o"
>>> +// CHECK-UBUNTU-12-04-ARM-HF:
>>> "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../arm-linux-
>>> gnueabihf/c
>>> rti.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-
>>> gnue
>>> abihf"
>>> +// 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/c
>>> rtn.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-
>>> gnueab
>>> i"
>>> +// 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 \
>>
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list