]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
MIPS: fix building on multiarch platform
authorYunQiang Su <yunqiang.su@cipunited.com>
Wed, 21 Sep 2022 11:13:03 +0000 (11:13 +0000)
committerYunQiang Su <yunqiang.su@cipunited.com>
Tue, 25 Oct 2022 08:06:20 +0000 (16:06 +0800)
On platforms that support multiarch, such as Debian,
the filesystem hierarchy doesn't fellow the old Irix style:
lib & lib/<multiarch> for native
lib64 for N64 on N32/O32 systems
lib32 for N32 on N64/O32 systems
libo32 for O32 on N64/N32 systems

Thus we cannot
 #define STANDARD_STARTFILE_PREFIX_1
 #define STANDARD_STARTFILE_PREFIX_2
on N32 or N64 systems, else collect2 won't look for libraries
on /lib/<multiarch>.

gcc/ChangeLog:
* configure.ac: AC_DEFINE(ENABLE_MULTIARCH, 1)
* configure: Regenerated.
* config.in: Regenerated.
* config/mips/mips.h: don't define STANDARD_STARTFILE_PREFIX_1
  if ENABLE_MULTIARCH is defined.
* config/mips/t-linux64: define correct multiarch path when
  multiarch is enabled.

gcc/config.in
gcc/config/mips/mips.h
gcc/config/mips/t-linux64
gcc/configure
gcc/configure.ac

index 5e41748a35422ed99d0308131e91a956e42c3867..38ef792bd67123a99eb13bef6e374e5d67d40966 100644 (file)
 #endif
 
 
+/* Specify if mutliarch is enabled. */
+#ifndef USED_FOR_TARGET
+#undef ENABLE_MULTIARCH
+#endif
+
+
 /* The size of `dev_t', as computed by sizeof. */
 #ifndef USED_FOR_TARGET
 #undef SIZEOF_DEV_T
index 74b6e11aabb1814323497a6acd3f1f6591bf0ac9..fe7f5b274b972d5dcf844b43af8a6c98f3b8cb95 100644 (file)
@@ -3427,6 +3427,7 @@ struct GTY(())  machine_function {
 
 /* If we are *not* using multilibs and the default ABI is not ABI_32 we
    need to change these from /lib and /usr/lib.  */
+#ifndef ENABLE_MULTIARCH
 #if MIPS_ABI_DEFAULT == ABI_N32
 #define STANDARD_STARTFILE_PREFIX_1 "/lib32/"
 #define STANDARD_STARTFILE_PREFIX_2 "/usr/lib32/"
@@ -3434,6 +3435,7 @@ struct GTY(())  machine_function {
 #define STANDARD_STARTFILE_PREFIX_1 "/lib64/"
 #define STANDARD_STARTFILE_PREFIX_2 "/usr/lib64/"
 #endif
+#endif
 
 /* Load store bonding is not supported by micromips and fix_24k.  The
    performance can be degraded for those targets.  Hence, do not bond for
index 2fdd8e0040772ee48782d79f1a2c3e8f0289ce56..37d176ea30943ac8e9a11964565fc99366173d7d 100644 (file)
@@ -20,7 +20,26 @@ MULTILIB_OPTIONS = mabi=n32/mabi=32/mabi=64
 MULTILIB_DIRNAMES = n32 32 64
 MIPS_EL = $(if $(filter %el, $(firstword $(subst -, ,$(target)))),el)
 MIPS_SOFT = $(if $(strip $(filter MASK_SOFT_FLOAT_ABI, $(target_cpu_default)) $(filter soft, $(with_float))),soft)
-MULTILIB_OSDIRNAMES = \
+ifeq (yes,$(enable_multiarch))
+  ifneq (,$(findstring gnuabi64,$(target)))
+    MULTILIB_OSDIRNAMES = \
+       ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+       ../libo32$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+       ../lib$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
+  else ifneq (,$(findstring gnuabin32,$(target)))
+    MULTILIB_OSDIRNAMES = \
+       ../lib$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+       ../libo32$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+       ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
+  else
+    MULTILIB_OSDIRNAMES = \
+       ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
+       ../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
+       ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
+  endif
+else
+  MULTILIB_OSDIRNAMES = \
        ../lib32$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabin32$(MIPS_SOFT)) \
        ../lib$(call if_multiarch,:mips$(MIPS_EL)-linux-gnu$(MIPS_SOFT)) \
        ../lib64$(call if_multiarch,:mips64$(MIPS_EL)-linux-gnuabi64$(MIPS_SOFT))
+endif
index c6def4c88e5fe7c24299a9c92f81cb9865816370..8e3c89b609e535bc3335ab69c42bdaab564dfa6c 100755 (executable)
@@ -7842,6 +7842,10 @@ if test x${enable_multiarch} = xauto; then
     enable_multiarch=no
   fi
 fi
+if test x${enable_multiarch} = xyes; then
+  $as_echo "#define ENABLE_MULTIARCH 1" >>confdefs.h
+
+fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for multiarch configuration" >&5
 $as_echo_n "checking for multiarch configuration... " >&6; }
 
index 45bf7560e6ffc79860beb4bfc50cb048efd168cd..eb92a37cd4653e36262f5a5c09ea86a29bae5bbc 100644 (file)
@@ -887,6 +887,9 @@ if test x${enable_multiarch} = xauto; then
     enable_multiarch=no
   fi
 fi
+if test x${enable_multiarch} = xyes; then
+  AC_DEFINE(ENABLE_MULTIARCH, 1)
+fi
 AC_MSG_CHECKING(for multiarch configuration)
 AC_SUBST(enable_multiarch)
 AC_MSG_RESULT($enable_multiarch$ma_msg_suffix)