diff mbox

Cleanup MIPS preconfigure script

Message ID 1409948236.2740.110.camel@ubuntu-sellcey
State New
Headers show

Commit Message

Steve Ellcey Sept. 5, 2014, 8:17 p.m. UTC
On Fri, 2014-09-05 at 00:23 +0100, Maciej W. Rozycki wrote:

>  Hmm, I never thought of such use and I keep considering it weird, but 
> having looked through the current script again we already permit e.g. 
> `mips64-linux-gnuabi32' to select o32, so I take my concern back, no need 
> for any checks here.

OK, that shrinks the preconfigure script even more.

>  Good.  Frankly (with the observation I made above) I think there should 
> be no difference between configuring for `mips-linux-gnu' and 
> `mips64-linux-gnuabi32'.

I agree, here is a new patch.  I complete removed the setting of
base_machine since it is not used and I removed the line:

machine=$machine/$config_machine

that was in my earlier patch because that did serve any purpose
that I could find, it was part of the original 32 bit mips preconfigure
path, which is why I originally had left it in.

Steve Ellcey
sellcey@mips.com


2014-09-05  Steve Ellcey  <sellcey@mips.com>

	* sysdeps/mips/preconfigure: Modify ABI tests.

Comments

Joseph Myers Sept. 5, 2014, 9:55 p.m. UTC | #1
On Fri, 5 Sep 2014, Steve Ellcey wrote:

> I agree, here is a new patch.  I complete removed the setting of
> base_machine since it is not used and I removed the line:

base_machine *is* used, to set base-machine in config.make.  But the only 
things that's used for now are (mach/Makefile for powerpc and) libc-abis 
handling (regarding which see 
<https://sourceware.org/ml/libc-alpha/2014-01/msg00375.html>) - and 
whatever the libc-abis handling does or does not work for, there is no use 
in a special setting of base_machine for mips64; just setting to mips for 
all MIPS cases seems most appropriate and consistent with other 
architectures.
Steve Ellcey Sept. 5, 2014, 10:36 p.m. UTC | #2
On Fri, 2014-09-05 at 21:55 +0000, Joseph S. Myers wrote:
> On Fri, 5 Sep 2014, Steve Ellcey wrote:
> 
> > I agree, here is a new patch.  I complete removed the setting of
> > base_machine since it is not used and I removed the line:
> 
> base_machine *is* used, to set base-machine in config.make.  But the only 
> things that's used for now are (mach/Makefile for powerpc and) libc-abis 
> handling (regarding which see 
> <https://sourceware.org/ml/libc-alpha/2014-01/msg00375.html>) - and 
> whatever the libc-abis handling does or does not work for, there is no use 
> in a special setting of base_machine for mips64; just setting to mips for 
> all MIPS cases seems most appropriate and consistent with other 
> architectures.

OK, I will put 'base_machine=mips' back in.  I also found a problem with
my removal of

machine=$machine/$config_machine

Everything was fine building mips-mti-linux-gnu and mips-linux-gnu but I
forgot to rebuild mips64-linux-gnu.  When I did it failed because
sysdeps/unix/sysv/linux/mips/configure.ac contains:

case $machine in
mips/mips64/n64/*)
  LIBC_SLIBDIR_RTLDDIR([lib64], [lib64])
  ;;
mips/mips64/n32/*)
  LIBC_SLIBDIR_RTLDDIR([lib32], [lib32])
  ;;
esac

and if machine is set to 'mips/mips64/n64' or 'mips/mips64/n32' it
doesn't match the case statements.  I am not sure if I should put
the 'machine=$machine/$config_machine' line back or change the
case statement to match n64* and n32* instead of n64/* and n32/*.
Opinions?

Steve Ellcey
diff mbox

Patch

diff --git a/sysdeps/mips/preconfigure b/sysdeps/mips/preconfigure
index b215eb2..343ef16 100644
--- a/sysdeps/mips/preconfigure
+++ b/sysdeps/mips/preconfigure
@@ -1,34 +1,20 @@ 
-case "$machine" in
-mips64*)	base_machine=mips64
-		case "$CC $CFLAGS $CPPFLAGS " in
-		*" -mabi=n32 "*) mips_cc_abi=n32 ;;
-		*" -mabi=64 "*|*" -mabi=n64 "*) mips_cc_abi=64 ;;
-		*" -mabi=32 "*|*" -mabi=o32 "*) mips_cc_abi=32 ;;
-		*) mips_cc_abi=default ;;
-		esac
-		case $config_os in
-		*abin32*) mips_config_abi=n32 ;;
-		*abi64*|*abin64*) mips_config_abi=64 ;;
-		*abi32*|*abio32*) mips_config_abi=32 ;;
-		*) mips_config_abi=$mips_cc_abi ;;
-		esac
-		case $mips_config_abi in
-		default) machine=mips/mips64/n32 mips_config_abi=n32 ;;
-		n32) machine=mips/mips64/n32 ;;
-		64) machine=mips/mips64/n64 ;;
-		32) machine=mips/mips32/kern64 ;;
-		esac
-		machine=$machine/$config_machine
-		if test $mips_config_abi != $mips_cc_abi; then
-		  # This won't make it to config.make, but we want to
-		  # set this in case configure tests depend on it.
-		  CPPFLAGS="$CPPFLAGS -mabi=$mips_config_abi"
-		fi
-		;;
-mips*)		base_machine=mips
-		case "$CC $CFLAGS $CPPFLAGS " in
-		*" -mips16 "*) machine=mips/mips32/mips16/$machine ;;
-		*) machine=mips/mips32/$machine ;;
-		esac
-		;;
-esac
+abiflag=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define _MIPS_SIM \(.*\)/\1/p'`
+mips16flag=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __mips16 \(.*\)/\1/p'`
+
+if test "$abiflag" = "_ABIO32" ; then
+	if test "$mips16flag" = "1" ; then
+		machine=mips/mips32/mips16
+	else
+		machine=mips/mips32
+	fi
+elif test "$abiflag" = "_ABIN32" ; then
+	machine=mips/mips64/n32
+elif test "$abiflag" = "_ABI64" ; then
+	machine=mips/mips64/n64
+else
+	as_fn_error $? "Unable to determine ABI." "$LINENO" 5
+fi
+
+if test "$abiflag" != "_ABIO32" -a "$mips16flag" = "1"; then
+	as_fn_error $? "mips16 is only supported with the O32 ABI." "$LINENO" 5
+fi