diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp --- a/clang/lib/Driver/ToolChains/Gnu.cpp +++ b/clang/lib/Driver/ToolChains/Gnu.cpp @@ -1081,7 +1081,8 @@ .flag("-m32") .flag("-mabi=n32"); - Multilib M32 = Multilib().flag("-m64").flag("+m32").flag("-mabi=n32"); + Multilib M32 = + Multilib().gccSuffix("/32").flag("-m64").flag("+m32").flag("-mabi=n32"); DebianMipsMultilibs = MultilibSet().Either(M32, M64, MAbiN32).FilterOut(NonExistent); @@ -2120,11 +2121,11 @@ static const char *const M68kTriples[] = { "m68k-linux-gnu", "m68k-unknown-linux-gnu", "m68k-suse-linux"}; - static const char *const MIPSLibDirs[] = {"/lib"}; + static const char *const MIPSLibDirs[] = {"/libo32", "/lib"}; static const char *const MIPSTriples[] = { "mips-linux-gnu", "mips-mti-linux", "mips-mti-linux-gnu", "mips-img-linux-gnu", "mipsisa32r6-linux-gnu"}; - static const char *const MIPSELLibDirs[] = {"/lib"}; + static const char *const MIPSELLibDirs[] = {"/libo32", "/lib"}; static const char *const MIPSELTriples[] = { "mipsel-linux-gnu", "mips-img-linux-gnu", "mipsisa32r6el-linux-gnu"}; diff --git a/clang/lib/Driver/ToolChains/Linux.cpp b/clang/lib/Driver/ToolChains/Linux.cpp --- a/clang/lib/Driver/ToolChains/Linux.cpp +++ b/clang/lib/Driver/ToolChains/Linux.cpp @@ -261,6 +261,13 @@ const std::string OSLibDir = std::string(getOSLibDir(Triple, Args)); const std::string MultiarchTriple = getMultiarchTriple(D, Triple, SysRoot); + // mips32: Debian multilib, we use /libo32, while in other case, /lib is + // used. We need add both libo32 and /lib. + if (Arch == llvm::Triple::mips || Arch == llvm::Triple::mipsel) { + Generic_GCC::AddMultilibPaths(D, SysRoot, "libo32", MultiarchTriple, Paths); + addPathIfExists(D, SysRoot + "/libo32", Paths); + addPathIfExists(D, SysRoot + "/usr/libo32", Paths); + } Generic_GCC::AddMultilibPaths(D, SysRoot, OSLibDir, MultiarchTriple, Paths); addPathIfExists(D, SysRoot + "/lib/" + MultiarchTriple, Paths); diff --git a/clang/test/Driver/Inputs/debian_6_mips64_tree/libo32/.keep b/clang/test/Driver/Inputs/debian_6_mips64_tree/libo32/.keep new file mode 100644 diff --git a/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/32/crtbegin.o b/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/32/crtbegin.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/32/crtend.o b/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/32/crtend.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/n32/crtbegin.o b/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/n32/crtbegin.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/n32/crtend.o b/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/n32/crtend.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32/crtbegin.o b/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32/crtbegin.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32/crtend.o b/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32/crtend.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/n32/crtbegin.o b/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/n32/crtbegin.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/n32/crtend.o b/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/n32/crtend.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crt1.o b/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crt1.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crti.o b/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crti.o new file mode 100644 diff --git a/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crtn.o b/clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crtn.o new file mode 100644 diff --git a/clang/test/Driver/linux-ld.c b/clang/test/Driver/linux-ld.c --- a/clang/test/Driver/linux-ld.c +++ b/clang/test/Driver/linux-ld.c @@ -1039,7 +1039,6 @@ // CHECK-SPARCV9: "-m" "elf64_sparc" // CHECK-SPARCV9: "-dynamic-linker" "{{(/usr/sparcv9-unknown-linux-gnu)?}}/lib{{(64)?}}/ld-linux.so.2" - // Test linker invocation on Android. // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: --target=arm-linux-androideabi -rtlib=platform --unwindlib=platform \ @@ -1455,6 +1454,22 @@ // CHECK-DEBIAN-ML-MIPS64EL-N32: "-L[[SYSROOT]]/usr/lib" // // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ +// RUN: --target=mips64el-linux-gnuabi64 -rtlib=platform -mabi=32 \ +// RUN: --gcc-toolchain="" \ +// RUN: --sysroot=%S/Inputs/debian_6_mips64_tree \ +// RUN: | FileCheck --check-prefix=CHECK-DEBIAN-ML-MIPS64EL-O32 %s +// CHECK-DEBIAN-ML-MIPS64EL-O32: "{{.*}}ld{{(.exe)?}}" "--sysroot=[[SYSROOT:[^"]+]]" +// CHECK-DEBIAN-ML-MIPS64EL-O32: "{{.*}}/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/../../../../libo32{{/|\\\\}}crt1.o" +// CHECK-DEBIAN-ML-MIPS64EL-O32: "{{.*}}/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/../../../../libo32{{/|\\\\}}crti.o" +// CHECK-DEBIAN-ML-MIPS64EL-O32: "{{.*}}/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32{{/|\\\\}}crtbegin.o" +// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32" +// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/../../../../libo32" +// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/libo32" +// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/usr/libo32" +// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/lib" +// CHECK-DEBIAN-ML-MIPS64EL-O32: "-L[[SYSROOT]]/usr/lib" +// +// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \ // RUN: --target=mips64-unknown-linux-gnu --rtlib=platform \ // RUN: --gcc-toolchain="" \ // RUN: --sysroot=%S/Inputs/debian_6_mips64_tree \