This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH] Cleanup MIPS preconfigure script
- From: "Maciej W. Rozycki" <macro at codesourcery dot com>
- To: Steve Ellcey <sellcey at mips dot com>
- Cc: <libc-alpha at sourceware dot org>, <matthew dot fortune at imgtec dot com>, Catherine Moore <clm at codesourcery dot com>
- Date: Thu, 4 Sep 2014 23:29:31 +0100
- Subject: Re: [PATCH] Cleanup MIPS preconfigure script
- Authentication-results: sourceware.org; auth=none
- References: <6b5ce132-2a69-4ee9-aaa5-d07792e72b50 at BAMAIL02 dot ba dot imgtec dot org>
On Thu, 4 Sep 2014, Steve Ellcey wrote:
> 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
Hmm, that's quite a change in the interpretation of host triplets, but
I'm leaning towards finding it acceptable, I think we have sufficient
means in GCC nowadays to control the default ABI so that we don't have to
rely on suffixes in the triplets. I wonder if a sanity check wouldn't be
good to have though, such as rejecting mips64* with the compiler set to
the 32-bit ABI to trap accidental silly use.
Your change has a flaw though, you can't rely on _MIPS_ISA being set
exactly to _MIPS_ISA_MIPS64 on determining if you want a 64-bit or a
32-bit configuration, there are other 64-bit ISAs, starting from
_MIPS_ISA_MIPS3, e.g. I have an n64 MIPS III compiler. I think you can
just skip this check altogether, GCC will have set the ABI and the ISA
consistently already and you can merge the two legs of this conditional
into one. You may just sanity-check that a 64-bit ABI is not used
together with the MIPS16 option as we have no 64-bit MIPS16 PIC support.
Thanks for thinking of cleaning this piece up.
Maciej