This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[Patch] MIPS configuration patch to enable --with-[arch,endian,abi]
- From: "Steve Ellcey " <sellcey at imgtec dot com>
- To: <gcc-patches at gcc dot gnu dot org>
- Cc: <matthew dot fortune at imgtec dot com>, <clm at codesourcery dot com>
- Date: Fri, 31 Oct 2014 14:08:37 -0700
- Subject: [Patch] MIPS configuration patch to enable --with-[arch,endian,abi]
- Authentication-results: sourceware.org; auth=none
Here is another MIPS configuration patch, this one allows the mips
configuration to handle the --with-endian, --with-arch, and --with-abi
configure options. Basically instead of having targets set MIPS_ABI_DEFAULT
and MIPS_ISA_DEFAULT directly in tm_defines based on their triplet names
I have them set default_mips_arch and default_mips_abi. Then, later
in config.gcc, these can be overridden using the values from --with-arch
and --with-abi and after that they are used to set MIPS_ABI_DEFAULT and
MIPS_ISA_DEFAULT in tm_defines. --with-endian is also handled this way.
While testing these changes I found that building a non-multilib target with
a default ABI other then the (old) 32 ABI was not working. If I built
using '--with-arch=mips64r2 --with-abi=64 --disable-multilib' for example
there was a mismatch in where the glibc configuration/build wanted
to put system libraries and where the GCC build was looking for them.
If MIPS were built as above it would not use the multilib make fragment
(t-linux64) and would look in /lib and /usr/lib for the system libraries.
The glibc configuration on the other hand would always put 64 bit ABI
libraries in /lib64 and /usr/lib64.
So the question is: should /lib and /usr/lib always be for the default GCC
ABI (whatever that may be) or should /lib and /usr/lib always be for the
MIPS (old) 32 ABI (with /lib32 and /usr/lib32 always being for the MIPS N32
ABI and /lib64 and /usr/lib64 always being for the 64 MIPS ABI. I chose the
latter as it seemed clearer and more consistent and that is why I also
needed to change mips.h to add the overrides of STANDARD_STARTFILE_PREFIX_1
and STANDARD_STARTFILE_PREFIX_2. These overrides are not needed if building
a multilib GCC because then MULTILIB_OSDIRNAMES in t-linux64 takes care
of everything, but they are needed if building a non-multilib GCC with a
default ABI other than the old 32 bit ABI.
Tested with many builds of mips*-*-linux-gnu targets and various combinations
of --with-arch, --with-abi, --with-endian, --disable-multilib, and
--enable-targets=all.
OK to checkin?
Steve Ellcey
2014-10-31 Steve Ellcey <sellcey@imgtec.com>
* config.gcc (mips*-mti-linux*): Remove gnu_ld and gas assignments.
Set default_mips_arch and default_mips_abi instead of tm_defines.
(mips*-*-linux*): Set default_mips_arch and default_mips_abi instead
of tm_defines.
(mips*-*-*): Check with_endian, with_arch, with_abi. Set tm_defines.
* config/mips/mips.h (STANDARD_STARTFILE_PREFIX_1): Set default
based on MIPS_ABI_DEFAULT.
(STANDARD_STARTFILE_PREFIX_2): Ditto.
diff --git a/gcc/config.gcc b/gcc/config.gcc
index 10b0a6e..4a62588 100644
--- a/gcc/config.gcc
+++ b/gcc/config.gcc
@@ -1943,39 +1943,38 @@ mips*-mti-linux*)
tm_file="dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h ${tm_file} mips/gnu-user.h mips/linux.h mips/linux-common.h mips/mti-linux.h"
extra_options="${extra_options} linux-android.opt"
tmake_file="${tmake_file} mips/t-mti-linux"
- tm_defines="${tm_defines} MIPS_ISA_DEFAULT=33 MIPS_ABI_DEFAULT=ABI_32"
- gnu_ld=yes
- gas=yes
+ default_mips_arch=mips32r2
+ default_mips_abi=32
;;
mips*-*-linux*) # Linux MIPS, either endian.
tm_file="dbxelf.h elfos.h gnu-user.h linux.h linux-android.h glibc-stdint.h ${tm_file} mips/gnu-user.h mips/linux.h mips/linux-common.h"
extra_options="${extra_options} linux-android.opt"
case ${target} in
mipsisa32r2*)
- tm_defines="${tm_defines} MIPS_ISA_DEFAULT=33"
+ default_mips_arch=mips32r2
;;
mipsisa32*)
- tm_defines="${tm_defines} MIPS_ISA_DEFAULT=32"
+ default_mips_arch=mips32
;;
mips64el-st-linux-gnu)
- tm_defines="${tm_defines} MIPS_ABI_DEFAULT=ABI_N32"
+ default_mips_abi=n32
tm_file="${tm_file} mips/st.h"
tmake_file="${tmake_file} mips/t-st"
enable_mips_multilibs="yes"
;;
mips64octeon*-*-linux*)
- tm_defines="${tm_defines} MIPS_ABI_DEFAULT=ABI_N32"
+ default_mips_abi=n32
tm_defines="${tm_defines} MIPS_CPU_STRING_DEFAULT=\\\"octeon\\\""
target_cpu_default=MASK_SOFT_FLOAT_ABI
enable_mips_multilibs="yes"
;;
mipsisa64r2*-*-linux*)
- tm_defines="${tm_defines} MIPS_ABI_DEFAULT=ABI_N32"
- tm_defines="${tm_defines} MIPS_ISA_DEFAULT=65"
+ default_mips_abi=n32
+ default_mips_arch=mips64r2
enable_mips_multilibs="yes"
;;
mips64*-*-linux* | mipsisa64*-*-linux*)
- tm_defines="${tm_defines} MIPS_ABI_DEFAULT=ABI_N32"
+ default_mips_abi=n32
enable_mips_multilibs="yes"
;;
esac
@@ -4117,9 +4116,39 @@ case ${target} in
fi
case ${target} in
mips*el-*-*)
- tm_defines="TARGET_ENDIAN_DEFAULT=0 $tm_defines"
+ default_mips_endian=little
;;
esac
+ if test x$with_endian != x; then
+ default_mips_endian=$with_endian
+ fi
+ if test x$with_arch != x; then
+ default_mips_arch=$with_arch
+ fi
+ if test x$with_abi != x; then
+ default_mips_abi=$with_abi
+ fi
+ case ${default_mips_endian} in
+ little) tm_defines="$tm_defines TARGET_ENDIAN_DEFAULT=0" ;;
+ big) tm_defines="$tm_defines TARGET_ENDIAN_DEFAULT=1" ;;
+ esac
+ case ${default_mips_arch} in
+ mips1) tm_defines="$tm_defines MIPS_ISA_DEFAULT=1" ;;
+ mips2) tm_defines="$tm_defines MIPS_ISA_DEFAULT=2" ;;
+ mips3) tm_defines="$tm_defines MIPS_ISA_DEFAULT=3" ;;
+ mips4) tm_defines="$tm_defines MIPS_ISA_DEFAULT=4" ;;
+ mips32) tm_defines="$tm_defines MIPS_ISA_DEFAULT=32" ;;
+ mips32r2) tm_defines="$tm_defines MIPS_ISA_DEFAULT=33" ;;
+ mips64) tm_defines="$tm_defines MIPS_ISA_DEFAULT=64" ;;
+ mips64r2) tm_defines="$tm_defines MIPS_ISA_DEFAULT=65" ;;
+ esac
+ case ${default_mips_abi} in
+ 32) tm_defines="$tm_defines MIPS_ABI_DEFAULT=ABI_32" ;;
+ o64) tm_defines="$tm_defines MIPS_ABI_DEFAULT=ABI_O64" ;;
+ n32) tm_defines="$tm_defines MIPS_ABI_DEFAULT=ABI_N32" ;;
+ 64) tm_defines="$tm_defines MIPS_ABI_DEFAULT=ABI_64" ;;
+ eabi) tm_defines="$tm_defines MIPS_ABI_DEFAULT=ABI_EABI" ;;
+ esac
tmake_file="mips/t-mips $tmake_file"
;;
diff --git a/gcc/config/mips/mips.h b/gcc/config/mips/mips.h
index c7b998b..9997c8f 100644
--- a/gcc/config/mips/mips.h
+++ b/gcc/config/mips/mips.h
@@ -3009,3 +3009,14 @@ extern GTY(()) struct target_globals *mips16_globals;
with arguments ARGS. */
#define PMODE_INSN(NAME, ARGS) \
(Pmode == SImode ? NAME ## _si ARGS : NAME ## _di ARGS)
+
+/* If we are *not* using multilibs and the default ABI is not ABI_32 we
+ need to change these from /lib and /usr/lib. */
+#if MIPS_ABI_DEFAULT == ABI_N32
+#define STANDARD_STARTFILE_PREFIX_1 "/lib32/"
+#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib32/"
+#elif MIPS_ABI_DEFAULT == ABI_64
+#define STANDARD_STARTFILE_PREFIX_1 "/lib64/"
+#define STANDARD_STARTFILE_PREFIX_2 "/usr/lib64/"
+#endif
+