[PATCH] Fix ARM cross compile crt*.o search path.
Logan Chien
tzuhsiang.chien at gmail.com
Sun Oct 27 02:34:21 PDT 2013
In the cross compilation situation (e.g. x86-64 to arm),
Ubuntu 12.04 puts crt1.o, crti.o, and crtn.o in the
following directory.
/usr/arm-linux-gnueabi/lib
/usr/arm-linux-gnueabihf/lib
However, currently Clang can't find these crt*.o because
an additional multilib argument "lib32" has been appended
to the search path. This commit fix this issue by returning
empty string for ARM/Thumb architecture.
http://llvm-reviews.chandlerc.com/D2030
Files:
lib/Driver/ToolChains.cpp
test/Driver/Inputs/ubuntu_12.04_LTS_cross_tree/usr/arm-linux-gnueabi/lib/crt1.o
test/Driver/Inputs/ubuntu_12.04_LTS_cross_tree/usr/arm-linux-gnueabi/lib/crti.o
test/Driver/Inputs/ubuntu_12.04_LTS_cross_tree/usr/arm-linux-gnueabi/lib/crtn.o
test/Driver/Inputs/ubuntu_12.04_LTS_cross_tree/usr/arm-linux-gnueabihf/lib/crt1.o
test/Driver/Inputs/ubuntu_12.04_LTS_cross_tree/usr/arm-linux-gnueabihf/lib/crti.o
test/Driver/Inputs/ubuntu_12.04_LTS_cross_tree/usr/arm-linux-gnueabihf/lib/crtn.o
test/Driver/Inputs/ubuntu_12.04_LTS_cross_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.3/crtbegin.o
test/Driver/Inputs/ubuntu_12.04_LTS_cross_tree/usr/lib/gcc/arm-linux-gnueabi/4.6.3/crtend.o
test/Driver/Inputs/ubuntu_12.04_LTS_cross_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtbegin.o
test/Driver/Inputs/ubuntu_12.04_LTS_cross_tree/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/crtend.o
test/Driver/linux-ld.c
Index: lib/Driver/ToolChains.cpp
===================================================================
--- lib/Driver/ToolChains.cpp
+++ lib/Driver/ToolChains.cpp
@@ -2266,6 +2266,10 @@
static StringRef getMultilibDir(const llvm::Triple &Triple,
const ArgList &Args) {
+ if (Triple.getArch() == llvm::Triple::arm ||
+ Triple.getArch() == llvm::Triple::thumb)
+ return "";
+
if (!isMipsArch(Triple.getArch()))
return Triple.isArch32Bit() ? "lib32" : "lib64";
Index: test/Driver/linux-ld.c
===================================================================
--- test/Driver/linux-ld.c
+++ test/Driver/linux-ld.c
@@ -245,6 +245,44 @@
// 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"
//
+// Check arm-linux-gnueabi cross compilation support on Ubuntu 12.04 LTS.
+// 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_cross_tree \
+// RUN: | FileCheck --check-prefix=CHECK-UBUNTU-12-04-CROSS-ARM %s
+// CHECK-UBUNTU-12-04-CROSS-ARM: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-UBUNTU-12-04-CROSS-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.3/../../../../arm-linux-gnueabi/lib/crt1.o"
+// CHECK-UBUNTU-12-04-CROSS-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.3/../../../../arm-linux-gnueabi/lib/crti.o"
+// CHECK-UBUNTU-12-04-CROSS-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.3{{/|\\\\}}crtbegin.o"
+// CHECK-UBUNTU-12-04-CROSS-ARM: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabi/4.6.3"
+// CHECK-UBUNTU-12-04-CROSS-ARM: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabi/4.6.3/../../../../arm-linux-gnueabi/lib/../"
+// CHECK-UBUNTU-12-04-CROSS-ARM: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabi/4.6.3/../../../../"
+// CHECK-UBUNTU-12-04-CROSS-ARM: "-L[[SYSROOT]]/usr/lib/../"
+// CHECK-UBUNTU-12-04-CROSS-ARM: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabi/4.6.3/../../../../arm-linux-gnueabi/lib"
+// CHECK-UBUNTU-12-04-CROSS-ARM: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabi/4.6.3/../../.."
+// CHECK-UBUNTU-12-04-CROSS-ARM: "-L[[SYSROOT]]/usr/lib"
+// CHECK-UBUNTU-12-04-CROSS-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.3{{/|\\\\}}crtend.o"
+// CHECK-UBUNTU-12-04-CROSS-ARM: "{{.*}}/usr/lib/gcc/arm-linux-gnueabi/4.6.3/../../../../arm-linux-gnueabi/lib/crtn.o"
+//
+// Check arm-linux-gnueabihf cross compilation 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_cross_tree \
+// RUN: | FileCheck --check-prefix=CHECK-UBUNTU-12-04-CROSS-ARM-HF %s
+// CHECK-UBUNTU-12-04-CROSS-ARM-HF: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]"
+// CHECK-UBUNTU-12-04-CROSS-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../../arm-linux-gnueabihf/lib/crt1.o"
+// CHECK-UBUNTU-12-04-CROSS-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../../arm-linux-gnueabihf/lib/crti.o"
+// CHECK-UBUNTU-12-04-CROSS-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3{{/|\\\\}}crtbegin.o"
+// CHECK-UBUNTU-12-04-CROSS-ARM-HF: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabihf/4.6.3"
+// CHECK-UBUNTU-12-04-CROSS-ARM-HF: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../../arm-linux-gnueabihf/lib/../"
+// CHECK-UBUNTU-12-04-CROSS-ARM-HF: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../../"
+// CHECK-UBUNTU-12-04-CROSS-ARM-HF: "-L[[SYSROOT]]/usr/lib/../"
+// CHECK-UBUNTU-12-04-CROSS-ARM-HF: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../../arm-linux-gnueabihf/lib"
+// CHECK-UBUNTU-12-04-CROSS-ARM-HF: "-L[[SYSROOT]]/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../.."
+// CHECK-UBUNTU-12-04-CROSS-ARM-HF: "-L[[SYSROOT]]/usr/lib"
+// CHECK-UBUNTU-12-04-CROSS-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3{{/|\\\\}}crtend.o"
+// CHECK-UBUNTU-12-04-CROSS-ARM-HF: "{{.*}}/usr/lib/gcc/arm-linux-gnueabihf/4.6.3/../../../../arm-linux-gnueabihf/lib/crtn.o"
+//
// Check fedora 18 on arm.
// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
// RUN: --target=armv7-unknown-linux-gnueabihf \
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D2030.1.patch
Type: text/x-patch
Size: 4347 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20131027/dd622d8a/attachment.bin>
More information about the cfe-commits
mailing list