This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Cleanup MIPS preconfigure script


I would like to simplify the MIPS preconfigure script.  Right now it looks
at the GCC flags and tries to determine what it should set 'machine' to based
on those flags (and os_config).  I would like to run the compiler and check
what macros are set and use that to set the machine variable instead.

This seems safer since right now a platform that generated the n64 ABI by
default (as an example) might not work correctly because the '-mabi=64' flag
would not need to appear in $CFLAGS to generate n64 code.

Other platforms like arm, m68k, powerpc, and tile are already using this
technique of calling the compiler and checking macros and the macros I am
checking on MIPS (_MIPS_SIM, _MIPS_ISA, and __mips16) are already used in
various glibc source files.

Note that I removed the reference to kern64 since it no longer exists
and I removed the addition of $machine from the end of the 'machine='
line for mips32 as there did not seem to be any reason for it.

Tested with mips-mti-linux-gnu and mips-linux-gnu and mips64-linux-gnu
builds.

OK to checkin?

Steve Ellcey
sellcey@mips.com


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

	* sysdeps/mips/preconfigure: Modify ABI tests.


diff --git a/sysdeps/mips/preconfigure b/sysdeps/mips/preconfigure
index b215eb2..df958d6 100644
--- a/sysdeps/mips/preconfigure
+++ b/sysdeps/mips/preconfigure
@@ -1,34 +1,25 @@
-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'`
+isaflag=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define _MIPS_ISA \(.*\)/\1/p'`
+mips16flag=`$CC $CFLAGS $CPPFLAGS -E -dM -xc /dev/null | sed -n 's/^#define __mips16 \(.*\)/\1/p'`
+
+if  test "$isaflag" = "_MIPS_ISA_MIPS64"; then
+	base_machine=mips64
+	if test "$abiflag" = "_ABIO32" ; then
+		machine=mips/mips32
+	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
+else
+	base_machine=mips
+	if test "$mips16flag" = "1" ; then
+		machine=mips/mips32/mips16
+	else
+		machine=mips/mips32
+	fi
+fi
+machine=$machine/$config_machine


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]