[PATCH] D112158: mips: fix search path for multilib o32
YunQiang Su via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Oct 24 20:21:22 PDT 2021
wzssyqa updated this revision to Diff 381826.
Herald added subscribers: ormris, jrtc27.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D112158/new/
https://reviews.llvm.org/D112158
Files:
clang/lib/Driver/ToolChains/Gnu.cpp
clang/lib/Driver/ToolChains/Linux.cpp
clang/test/Driver/Inputs/debian_6_mips64_tree/libo32/.keep
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/32/crtbegin.o
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/32/crtend.o
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/n32/crtbegin.o
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64-linux-gnuabi64/4.9/n32/crtend.o
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32/crtbegin.o
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/32/crtend.o
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/n32/crtbegin.o
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/lib/gcc/mips64el-linux-gnuabi64/4.9/n32/crtend.o
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crt1.o
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crti.o
clang/test/Driver/Inputs/debian_6_mips64_tree/usr/libo32/crtn.o
clang/test/Driver/linux-ld.c
Index: clang/test/Driver/linux-ld.c
===================================================================
--- clang/test/Driver/linux-ld.c
+++ 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 \
Index: clang/lib/Driver/ToolChains/Linux.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Linux.cpp
+++ 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);
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ 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"};
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112158.381826.patch
Type: text/x-patch
Size: 4147 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20211025/b1626b9f/attachment-0001.bin>
More information about the cfe-commits
mailing list