[PATCH] Fix ARM cross compile crt*.o search path.
Anton Korobeynikov
anton at korobeynikov.info
Sun Oct 27 05:18:08 PDT 2013
Hi Logan,
Given that there is similar check to MIPS, should we do the opposite
thing and return something non-empty for x86 only?
On Sun, Oct 27, 2013 at 1:34 PM, Logan Chien <tzuhsiang.chien at gmail.com> wrote:
> 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 \
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
--
With best regards, Anton Korobeynikov
Faculty of Mathematics and Mechanics, Saint Petersburg State University
More information about the cfe-commits
mailing list