From: Chandler Carruth Date: Mon, 3 Oct 2011 09:00:50 +0000 (+0000) Subject: Enable generic multilib support on 32bit hosts. Previously this was only X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=38ec546a56a267320f8f6c86141a7b0f7d6493c4;p=clang Enable generic multilib support on 32bit hosts. Previously this was only enabled for debian hosts, which is quite odd. I think all restriction on when Clang attempts to use a multilib installation should go away. Clang is fundamentally a cross compiler. It behaves more like GCC when built as a cross compiler, and so it should just use multilib installs when they are present on the system. However, there is a very specific exemption for Exherbo, which I can't test on, so I'm leaving that in place. With this, check in a generic test tree for multilib on a 32-bit host. This stubs out many directories that most distributions don't use but that uptsream GCC supports. This is intended to be an agnostic test that the driver behaves properly compared with the GCC driver it aims for compatibility with. Also, fix a bug in the driver that this testing exposed (see!) where it was incorrectly testing the target architecture rather than the host architecture. If anyone is having trouble with the tree-structure stubs I'm creating to test this, let me know and I can revisit the design. I chose this over (for example) a tar-ball in order to make tests run faster at the small, hopefully amortized VCS cost. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@140999 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index c6adbc04a8..51dd4c8c49 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -1378,25 +1378,17 @@ static bool IsUbuntu(enum LinuxDistro Distro) { Distro == UbuntuNatty || Distro == UbuntuOneiric; } -static bool IsDebianBased(enum LinuxDistro Distro) { - return IsDebian(Distro) || IsUbuntu(Distro); -} - +// FIXME: This should be deleted. We should assume a multilib environment, and +// fallback gracefully if any parts of it are absent. static bool HasMultilib(llvm::Triple::ArchType Arch, enum LinuxDistro Distro) { if (Arch == llvm::Triple::x86_64) { bool Exists; if (Distro == Exherbo && (llvm::sys::fs::exists("/usr/lib32/libc.so", Exists) || !Exists)) return false; - - return true; } - if (Arch == llvm::Triple::ppc64) - return true; - if ((Arch == llvm::Triple::x86 || Arch == llvm::Triple::ppc) && - IsDebianBased(Distro)) - return true; - return false; + + return true; } static LinuxDistro DetectLinuxDistro(llvm::Triple::ArchType Arch) { @@ -1690,7 +1682,7 @@ Linux::Linux(const HostInfo &Host, const llvm::Triple &Triple) getArch() == llvm::Triple::ppc); const std::string Suffix32 = Arch == llvm::Triple::x86_64 ? "/32" : ""; - const std::string Suffix64 = Is32Bits ? "/64" : ""; + const std::string Suffix64 = Arch == llvm::Triple::x86_64 ? "" : "/64"; const std::string Suffix = Is32Bits ? Suffix32 : Suffix64; const std::string Multilib = Is32Bits ? "lib32" : "lib64"; diff --git a/test/Driver/Inputs/multilib_32bit_linux_tree/lib/.keep b/test/Driver/Inputs/multilib_32bit_linux_tree/lib/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/multilib_32bit_linux_tree/lib32/.keep b/test/Driver/Inputs/multilib_32bit_linux_tree/lib32/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/multilib_32bit_linux_tree/lib64/.keep b/test/Driver/Inputs/multilib_32bit_linux_tree/lib64/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib/.keep b/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib32/.keep b/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib32/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib64/.keep b/test/Driver/Inputs/multilib_32bit_linux_tree/usr/i386-unknown-linux/lib64/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/.keep b/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/64/crtbegin.o b/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/64/crtbegin.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o b/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib32/.keep b/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib32/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib64/.keep b/test/Driver/Inputs/multilib_32bit_linux_tree/usr/lib64/.keep new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/Driver/linux-ld.c b/test/Driver/linux-ld.c index 15f890f0cb..cb448b8751 100644 --- a/test/Driver/linux-ld.c +++ b/test/Driver/linux-ld.c @@ -24,3 +24,36 @@ // CHECK-LD-64: "-L[[SYSROOT]]/usr/lib/gcc/x86_64-unknown-linux/4.6.0/../../.." // CHECK-LD-64: "-L[[SYSROOT]]/lib" // CHECK-LD-64: "-L[[SYSROOT]]/usr/lib" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -ccc-host-triple i386-unknown-linux -m32 \ +// RUN: --sysroot=%S/Inputs/multilib_32bit_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-32-TO-32 %s +// CHECK-32-TO-32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-32-TO-32: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0/crtbegin.o" +// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0" +// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib/../lib32" +// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../lib32" +// CHECK-32-TO-32: "-L[[SYSROOT]]/lib/../lib32" +// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/../lib32" +// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib" +// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.." +// CHECK-32-TO-32: "-L[[SYSROOT]]/lib" +// CHECK-32-TO-32: "-L[[SYSROOT]]/usr/lib" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: -ccc-host-triple i386-unknown-linux -m64 \ +// RUN: --sysroot=%S/Inputs/multilib_32bit_linux_tree \ +// RUN: | FileCheck --check-prefix=CHECK-32-TO-64 %s +// CHECK-32-TO-64: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-32-TO-64: "{{.*}}/usr/lib/gcc/i386-unknown-linux/4.6.0/64/crtbegin.o" +// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/64" +// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib/../lib64" +// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../lib64" +// CHECK-32-TO-64: "-L[[SYSROOT]]/lib/../lib64" +// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/../lib64" +// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0" +// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../../../i386-unknown-linux/lib" +// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib/gcc/i386-unknown-linux/4.6.0/../../.." +// CHECK-32-TO-64: "-L[[SYSROOT]]/lib" +// CHECK-32-TO-64: "-L[[SYSROOT]]/usr/lib"