public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
* [patch, mips] Fix stubs files for hard float vs. soft float
@ 2012-10-15 20:15 Steve Ellcey 
  2012-10-15 21:15 ` Andreas Schwab
  2012-10-15 22:08 ` Joseph S. Myers
  0 siblings, 2 replies; 24+ messages in thread
From: Steve Ellcey  @ 2012-10-15 20:15 UTC (permalink / raw)
  To: libc-ports

While working on various flavors of glibc, I found that building on MIPS 
with and without floating point enabled resulted in different stub files,
but the MIPS makefile did not handle this difference correctly (it would
always create a stubs-o32.h (or n32 or n64) header file and that file would
look different depending on whether or not you enabled floating point.

This patch creates different stub files for hard float vs. soft float, which
combined with o32, n32, and n64 results in 6 different stub files. Rather
then create 6 different Makefiles to set abi-default (there are 3 right now)
I changed mips to use the ARM method of setting abi-default by preprocessing
a C file.  This allowed me to remove the 3 Makefiles that did nothing but set
abi-default instead of having to add 3 more Makefiles to handle the soft vs.
hard differences.

Tested by building soft and hard float versions glibc on MIPS for o32, n32,
and n64 versions.

OK to checkin?

Steve Ellcey
sellcey@mips.com



2012-10-15  Steve Ellcey  <sellcey@mips.com>

	* sysdeps/unix/sysv/linux/mips/mips32/Makefile: Remove.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/Makefile: Remove.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/Makefile: Remove.
	* sysdeps/unix/sysv/linux/mips/Makefile (default-abi): Set.
	* (abi-variants): Add hard and soft float versions.
	* (abi-*-options):  update with hard and soft flags.
	* (abi-*-condition): Ditto.


diff --git a/ports/sysdeps/unix/sysv/linux/mips/Makefile b/ports/sysdeps/unix/sysv/linux/mips/Makefile
index 99c554f..27f74fc 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/Makefile
+++ b/ports/sysdeps/unix/sysv/linux/mips/Makefile
@@ -8,15 +8,60 @@ sysdep_routines += cachectl cacheflush sysmips _test_and_set
 sysdep_headers += sys/cachectl.h sys/sysmips.h sys/tas.h
 endif
 
+define default-abi-prog
+echo '#if defined(__mips_soft_float) && (_MIPS_SIM == _ABIO32)';
+echo 'o32_soft';
+echo '#elif defined(__mips_hard_float) && (_MIPS_SIM == _ABIO32)';
+echo 'o32_hard';
+echo '#elif defined(__mips_soft_float) && (_MIPS_SIM == _ABIN32)';
+echo 'n32_soft';
+echo '#elif defined(__mips_hard_float) && (_MIPS_SIM == _ABIN32)';
+echo 'n32_hard';
+echo '#elif defined(__mips_soft_float) && (_MIPS_SIM == _ABI64)';
+echo 'n64_soft';
+echo '#elif defined(__mips_hard_float) && (_MIPS_SIM == _ABI64)';
+echo 'n64_hard';
+echo '#endif'
+endef
+default-abi := $(strip $(shell \
+    ($(default-abi-prog)) | $(CC) $(CFLAGS) $(CPPFLAGS) -E -P -))
+
+ifneq ($(default-abi),o32_soft)
+ifneq ($(default-abi),o32_hard)
+ifneq ($(default-abi),n32_soft)
+ifneq ($(default-abi),n32_hard)
+ifneq ($(default-abi),n64_soft)
+ifneq ($(default-abi),n64_hard)
+Unknown ABI, must be "o32_soft", "o32_hard", "n32_soft", "n32_hard",
+"n64_soft", or "n64_hard"
+endif
+endif
+endif
+endif
+endif
+endif
+
 # _MIPS_SIM_ABI32 == 1, _MIPS_SIM_NABI32 == 2, _MIPS_SIM_ABI64 == 3
-abi-variants := o32 n32 n64
+abi-variants := o32_soft o32_hard n32_soft n32_hard n64_soft n64_hard
 abi-includes := sgidefs.h
-abi-o32-options := -D_MIPS_SIM=1
-abi-o32-condition := _MIPS_SIM == _MIPS_SIM_ABI32
-abi-n32-options := -D_MIPS_SIM=2
-abi-n32-condition := _MIPS_SIM == _MIPS_SIM_NABI32
-abi-n64-options := -D_MIPS_SIM=3
-abi-n64-condition := _MIPS_SIM == _MIPS_SIM_ABI64
+abi-o32_soft-options := -D_MIPS_SIM=1 -D__mips_soft_float
+abi-o32_soft-condition := defined(__mips_soft_float) \
+			   && (_MIPS_SIM == _MIPS_SIM_ABI32)
+abi-o32_hard-options := -D_MIPS_SIM=1 -D__mips_hard_float
+abi-o32_hard-condition := defined(__mips_hard_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_ABI32)
+abi-n32_soft-options := -D_MIPS_SIM=2 -D__mips_soft_float
+abi-n32_soft-condition := defined(__mips_soft_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_NABI32)
+abi-n32_hard-options := -D_MIPS_SIM=2 -D__mips_hard_float
+abi-n32_hard-condition := defined(__mips_hard_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_NABI32)
+abi-n64_soft-options := -D_MIPS_SIM=3 -D__mips_soft_float
+abi-n64_soft-condition := defined(__mips_soft_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_ABI64)
+abi-n64_hard-options := -D_MIPS_SIM=3 -D__mips_hard_float
+abi-n64_hard-condition := defined(__mips_hard_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_ABI64)
 
 ifeq ($(subdir),elf)
 ifeq ($(build-shared),yes)

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-15 20:15 [patch, mips] Fix stubs files for hard float vs. soft float Steve Ellcey 
@ 2012-10-15 21:15 ` Andreas Schwab
  2012-10-15 21:23   ` Andreas Schwab
  2012-10-15 22:08 ` Joseph S. Myers
  1 sibling, 1 reply; 24+ messages in thread
From: Andreas Schwab @ 2012-10-15 21:15 UTC (permalink / raw)
  To: Steve Ellcey ; +Cc: libc-ports

"Steve Ellcey " <sellcey@mips.com> writes:

> +ifneq ($(default-abi),o32_soft)
> +ifneq ($(default-abi),o32_hard)
> +ifneq ($(default-abi),n32_soft)
> +ifneq ($(default-abi),n32_hard)
> +ifneq ($(default-abi),n64_soft)
> +ifneq ($(default-abi),n64_hard)
> +Unknown ABI, must be "o32_soft", "o32_hard", "n32_soft", "n32_hard",
> +"n64_soft", or "n64_hard"
> +endif
> +endif
> +endif
> +endif
> +endif
> +endif
> +
>  # _MIPS_SIM_ABI32 == 1, _MIPS_SIM_NABI32 == 2, _MIPS_SIM_ABI64 == 3
> -abi-variants := o32 n32 n64
> +abi-variants := o32_soft o32_hard n32_soft n32_hard n64_soft n64_hard

ifneq (,$(filter $(default-abi),$(abi-variants)))
Unknown ABI, must be one of $(abi-variants)
endif

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-15 21:15 ` Andreas Schwab
@ 2012-10-15 21:23   ` Andreas Schwab
  0 siblings, 0 replies; 24+ messages in thread
From: Andreas Schwab @ 2012-10-15 21:23 UTC (permalink / raw)
  To: Steve Ellcey ; +Cc: libc-ports

Andreas Schwab <schwab@linux-m68k.org> writes:

> "Steve Ellcey " <sellcey@mips.com> writes:
>
>> +ifneq ($(default-abi),o32_soft)
>> +ifneq ($(default-abi),o32_hard)
>> +ifneq ($(default-abi),n32_soft)
>> +ifneq ($(default-abi),n32_hard)
>> +ifneq ($(default-abi),n64_soft)
>> +ifneq ($(default-abi),n64_hard)
>> +Unknown ABI, must be "o32_soft", "o32_hard", "n32_soft", "n32_hard",
>> +"n64_soft", or "n64_hard"
>> +endif
>> +endif
>> +endif
>> +endif
>> +endif
>> +endif
>> +
>>  # _MIPS_SIM_ABI32 == 1, _MIPS_SIM_NABI32 == 2, _MIPS_SIM_ABI64 == 3
>> -abi-variants := o32 n32 n64
>> +abi-variants := o32_soft o32_hard n32_soft n32_hard n64_soft n64_hard
>
> ifneq (,$(filter $(default-abi),$(abi-variants)))

ifeq, of course.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-15 20:15 [patch, mips] Fix stubs files for hard float vs. soft float Steve Ellcey 
  2012-10-15 21:15 ` Andreas Schwab
@ 2012-10-15 22:08 ` Joseph S. Myers
  2012-10-15 23:06   ` Steve Ellcey
  1 sibling, 1 reply; 24+ messages in thread
From: Joseph S. Myers @ 2012-10-15 22:08 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: libc-ports

On Mon, 15 Oct 2012, Steve Ellcey  wrote:

> While working on various flavors of glibc, I found that building on MIPS 
> with and without floating point enabled resulted in different stub files,
> but the MIPS makefile did not handle this difference correctly (it would
> always create a stubs-o32.h (or n32 or n64) header file and that file would
> look different depending on whether or not you enabled floating point.

What are the differences exactly?  We should look at whether they are 
actually all correct....

> This patch creates different stub files for hard float vs. soft float, which
> combined with o32, n32, and n64 results in 6 different stub files. Rather
> then create 6 different Makefiles to set abi-default (there are 3 right now)
> I changed mips to use the ARM method of setting abi-default by preprocessing
> a C file.  This allowed me to remove the 3 Makefiles that did nothing but set
> abi-default instead of having to add 3 more Makefiles to handle the soft vs.
> hard differences.

Note that Roland objected to the use of $(shell) in the ARM case (it's on 
my queue to revise the implementation accordingly, maybe during the 2.17 
freeze period).  So I advise trying one of his suggestions from that 
thread <http://sourceware.org/ml/libc-ports/2012-05/msg00190.html>.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-15 22:08 ` Joseph S. Myers
@ 2012-10-15 23:06   ` Steve Ellcey
  2012-10-15 23:31     ` Joseph S. Myers
  0 siblings, 1 reply; 24+ messages in thread
From: Steve Ellcey @ 2012-10-15 23:06 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: libc-ports

On Mon, 2012-10-15 at 22:08 +0000, Joseph S. Myers wrote:
> On Mon, 15 Oct 2012, Steve Ellcey  wrote:
> 
> > While working on various flavors of glibc, I found that building on MIPS 
> > with and without floating point enabled resulted in different stub files,
> > but the MIPS makefile did not handle this difference correctly (it would
> > always create a stubs-o32.h (or n32 or n64) header file and that file would
> > look different depending on whether or not you enabled floating point.
> 
> What are the differences exactly?  We should look at whether they are 
> actually all correct....

All of the soft-float versions have these entries which are not in the
hard float versions:

< #define __stub_feclearexcept
< #define __stub_fedisableexcept
< #define __stub_feenableexcept
< #define __stub_fegetenv
< #define __stub_fegetexcept
< #define __stub_fegetexceptflag
< #define __stub_fegetround
< #define __stub_feholdexcept
< #define __stub_feraiseexcept
< #define __stub_fesetenv
< #define __stub_fesetexceptflag
< #define __stub_fesetround
< #define __stub_fetestexcept
< #define __stub_feupdateenv

> Note that Roland objected to the use of $(shell) in the ARM case (it's on 
> my queue to revise the implementation accordingly, maybe during the 2.17 
> freeze period).  So I advise trying one of his suggestions from that 
> thread <http://sourceware.org/ml/libc-ports/2012-05/msg00190.html>.

Makefiles building makefiles.  That's probably going to take some trial
and error and a lot of questions on my part unless there is an existing
example to draw from.  I am not even sure what the Makefile that is
being generated would be doing and what the targets in it would be.

Steve Ellcey
sellcey@mips.com




^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-15 23:06   ` Steve Ellcey
@ 2012-10-15 23:31     ` Joseph S. Myers
  2012-10-22 23:31       ` Steve Ellcey
  0 siblings, 1 reply; 24+ messages in thread
From: Joseph S. Myers @ 2012-10-15 23:31 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: libc-ports

On Mon, 15 Oct 2012, Steve Ellcey wrote:

> On Mon, 2012-10-15 at 22:08 +0000, Joseph S. Myers wrote:
> > On Mon, 15 Oct 2012, Steve Ellcey  wrote:
> > 
> > > While working on various flavors of glibc, I found that building on MIPS 
> > > with and without floating point enabled resulted in different stub files,
> > > but the MIPS makefile did not handle this difference correctly (it would
> > > always create a stubs-o32.h (or n32 or n64) header file and that file would
> > > look different depending on whether or not you enabled floating point.
> > 
> > What are the differences exactly?  We should look at whether they are 
> > actually all correct....
> 
> All of the soft-float versions have these entries which are not in the
> hard float versions:

OK, those do look like correct differences (unless and until MIPS 
soft-float is made to support exceptions and rounding modes along the 
lines of the support for them with Power soft-float).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-15 23:31     ` Joseph S. Myers
@ 2012-10-22 23:31       ` Steve Ellcey
  2012-10-22 23:38         ` Joseph S. Myers
  0 siblings, 1 reply; 24+ messages in thread
From: Steve Ellcey @ 2012-10-22 23:31 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: libc-ports

On Mon, 2012-10-15 at 23:31 +0000, Joseph S. Myers wrote:
> On Mon, 15 Oct 2012, Steve Ellcey wrote:
> 
> > On Mon, 2012-10-15 at 22:08 +0000, Joseph S. Myers wrote:
> > > On Mon, 15 Oct 2012, Steve Ellcey  wrote:
> > > 
> > > > While working on various flavors of glibc, I found that building on MIPS 
> > > > with and without floating point enabled resulted in different stub files,
> > > > but the MIPS makefile did not handle this difference correctly (it would
> > > > always create a stubs-o32.h (or n32 or n64) header file and that file would
> > > > look different depending on whether or not you enabled floating point.
> > > 
> > > What are the differences exactly?  We should look at whether they are 
> > > actually all correct....
> > 
> > All of the soft-float versions have these entries which are not in the
> > hard float versions:
> 
> OK, those do look like correct differences (unless and until MIPS 
> soft-float is made to support exceptions and rounding modes along the 
> lines of the support for them with Power soft-float).

Does that mean the patch is OK or do you want me to get rid of the use
of $(shell) as Roland suggested?  If so, I need some help because I
don't know how to rewrite this patch to make it use a generated Makefile
instead.  I am not sure what Makefile/configure script would generate
the Makefile, what targets the Makefile would have or where the
generated Makefile would be included from.

Steve Ellcey
sellcey@mips.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-22 23:31       ` Steve Ellcey
@ 2012-10-22 23:38         ` Joseph S. Myers
  2012-10-23 20:20           ` Steve Ellcey
  0 siblings, 1 reply; 24+ messages in thread
From: Joseph S. Myers @ 2012-10-22 23:38 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: libc-ports

On Mon, 22 Oct 2012, Steve Ellcey wrote:

> > OK, those do look like correct differences (unless and until MIPS 
> > soft-float is made to support exceptions and rounding modes along the 
> > lines of the support for them with Power soft-float).
> 
> Does that mean the patch is OK or do you want me to get rid of the use
> of $(shell) as Roland suggested?  If so, I need some help because I

I mean that the principle of generating separate headers for these cases 
is OK, subject to taking into account both Roland's and Andreas's 
comments.

The generated file should only need to set the default-abi variable, not 
have any targets, be included from sysdeps/unix/sysv/linux/mips/Makefile 
where the ABI conditions are defined, and can be generated by a configure 
script fragment.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-22 23:38         ` Joseph S. Myers
@ 2012-10-23 20:20           ` Steve Ellcey
  2012-10-23 21:32             ` Roland McGrath
  2012-10-24  0:05             ` Joseph S. Myers
  0 siblings, 2 replies; 24+ messages in thread
From: Steve Ellcey @ 2012-10-23 20:20 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: libc-ports

On Mon, 2012-10-22 at 23:37 +0000, Joseph S. Myers wrote:
> On Mon, 22 Oct 2012, Steve Ellcey wrote:
> 
> > > OK, those do look like correct differences (unless and until MIPS 
> > > soft-float is made to support exceptions and rounding modes along the 
> > > lines of the support for them with Power soft-float).
> > 
> > Does that mean the patch is OK or do you want me to get rid of the use
> > of $(shell) as Roland suggested?  If so, I need some help because I
> 
> I mean that the principle of generating separate headers for these cases 
> is OK, subject to taking into account both Roland's and Andreas's 
> comments.
> 
> The generated file should only need to set the default-abi variable, not 
> have any targets, be included from sysdeps/unix/sysv/linux/mips/Makefile 
> where the ABI conditions are defined, and can be generated by a configure 
> script fragment.

OK, Here is a new patch that uses preconfigure to create a Makefile that
is included in sysdeps/unix/sysv/linux/mips/Makefile.  I also addressed
Andreas's comment about my check of whether or not default-abi is good
or not.  I am still testing it but it looks good so far.


2012-10-23  Steve Ellcey  <sellcey@mips.com>

	* sysdeps/unix/sysv/linux/mips/mips32/Makefile: Remove.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/Makefile: Remove.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/Makefile: Remove.
	* sysdeps/mips/preconfigure: Create default_abi.make.
	* sysdeps/unix/sysv/linux/mips/Makefile: Include default_abi.make.
	* (abi-variants): Add hard and soft float versions.
	* (abi-*-options):  update with hard and soft flags.
	* (abi-*-condition): Ditto.

diff --git a/ports/sysdeps/mips/preconfigure b/ports/sysdeps/mips/preconfigure
index 9190eee..3b633bd 100644
--- a/ports/sysdeps/mips/preconfigure
+++ b/ports/sysdeps/mips/preconfigure
@@ -1,3 +1,24 @@
+
+cat > conftest.c <<EOF
+#if defined(__mips_soft_float) && (_MIPS_SIM == _ABIO32)
+o32_soft
+#elif defined(__mips_hard_float) && (_MIPS_SIM == _ABIO32)
+o32_hard
+#elif defined(__mips_soft_float) && (_MIPS_SIM == _ABIN32)
+n32_soft
+#elif defined(__mips_hard_float) && (_MIPS_SIM == _ABIN32)
+n32_hard
+#elif defined(__mips_soft_float) && (_MIPS_SIM == _ABI64)
+n64_soft
+#elif defined(__mips_hard_float) && (_MIPS_SIM == _ABI64)
+n64_hard
+#else
+ERROR
+#endif
+EOF
+default_abi=`$CC $CFLAGS $CPPFLAGS -E -P conftest.c`
+echo "default-abi := $default_abi" >> default_abi.make
+
 case "$machine" in
 mips64*)	base_machine=mips64
 		case "$CC $CFLAGS $CPPFLAGS " in
diff --git a/ports/sysdeps/unix/sysv/linux/mips/Makefile b/ports/sysdeps/unix/sysv/linux/mips/Makefile
index 99c554f..f0beeb3 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/Makefile
+++ b/ports/sysdeps/unix/sysv/linux/mips/Makefile
@@ -8,15 +8,36 @@ sysdep_routines += cachectl cacheflush sysmips _test_and_set
 sysdep_headers += sys/cachectl.h sys/sysmips.h sys/tas.h
 endif
 
-# _MIPS_SIM_ABI32 == 1, _MIPS_SIM_NABI32 == 2, _MIPS_SIM_ABI64 == 3
-abi-variants := o32 n32 n64
+# Get value of abi-default
+include $(common-objpfx)default_abi.make
+
+abi-variants := o32_soft o32_hard n32_soft n32_hard n64_soft n64_hard
+
+ifeq (,$(filter $(default-abi),$(abi-variants)))
+Unknown ABI, must be one of $(abi-variants)
+endif
+
 abi-includes := sgidefs.h
-abi-o32-options := -D_MIPS_SIM=1
-abi-o32-condition := _MIPS_SIM == _MIPS_SIM_ABI32
-abi-n32-options := -D_MIPS_SIM=2
-abi-n32-condition := _MIPS_SIM == _MIPS_SIM_NABI32
-abi-n64-options := -D_MIPS_SIM=3
-abi-n64-condition := _MIPS_SIM == _MIPS_SIM_ABI64
+
+# _MIPS_SIM_ABI32 == 1, _MIPS_SIM_NABI32 == 2, _MIPS_SIM_ABI64 == 3
+abi-o32_soft-options := -D_MIPS_SIM=1 -D__mips_soft_float
+abi-o32_soft-condition := defined(__mips_soft_float) \
+			   && (_MIPS_SIM == _MIPS_SIM_ABI32)
+abi-o32_hard-options := -D_MIPS_SIM=1 -D__mips_hard_float
+abi-o32_hard-condition := defined(__mips_hard_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_ABI32)
+abi-n32_soft-options := -D_MIPS_SIM=2 -D__mips_soft_float
+abi-n32_soft-condition := defined(__mips_soft_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_NABI32)
+abi-n32_hard-options := -D_MIPS_SIM=2 -D__mips_hard_float
+abi-n32_hard-condition := defined(__mips_hard_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_NABI32)
+abi-n64_soft-options := -D_MIPS_SIM=3 -D__mips_soft_float
+abi-n64_soft-condition := defined(__mips_soft_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_ABI64)
+abi-n64_hard-options := -D_MIPS_SIM=3 -D__mips_hard_float
+abi-n64_hard-condition := defined(__mips_hard_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_ABI64)
 
 ifeq ($(subdir),elf)
 ifeq ($(build-shared),yes)


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-23 20:20           ` Steve Ellcey
@ 2012-10-23 21:32             ` Roland McGrath
  2012-10-23 22:14               ` Steve Ellcey
  2012-10-24  0:05             ` Joseph S. Myers
  1 sibling, 1 reply; 24+ messages in thread
From: Roland McGrath @ 2012-10-23 21:32 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: Joseph S. Myers, libc-ports

> 	* sysdeps/mips/preconfigure: Create default_abi.make.

We use dashes in file names for the most part, not underscores.

> --- a/ports/sysdeps/mips/preconfigure
> +++ b/ports/sysdeps/mips/preconfigure
> @@ -1,3 +1,24 @@
> +
> +cat > conftest.c <<EOF
> +#if defined(__mips_soft_float) && (_MIPS_SIM == _ABIO32)
> +o32_soft
> +#elif defined(__mips_hard_float) && (_MIPS_SIM == _ABIO32)
> +o32_hard
> +#elif defined(__mips_soft_float) && (_MIPS_SIM == _ABIN32)
> +n32_soft
> +#elif defined(__mips_hard_float) && (_MIPS_SIM == _ABIN32)
> +n32_hard
> +#elif defined(__mips_soft_float) && (_MIPS_SIM == _ABI64)
> +n64_soft
> +#elif defined(__mips_hard_float) && (_MIPS_SIM == _ABI64)
> +n64_hard
> +#else
> +ERROR
> +#endif
> +EOF
> +default_abi=`$CC $CFLAGS $CPPFLAGS -E -P conftest.c`
> +echo "default-abi := $default_abi" >> default_abi.make

This should fail at configure time if something goes wrong,
not produce bogus results.

Why does this need to be in preconfigure instead of configure?


Thanks,
Roland

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-23 21:32             ` Roland McGrath
@ 2012-10-23 22:14               ` Steve Ellcey
  2012-10-23 22:48                 ` Roland McGrath
  0 siblings, 1 reply; 24+ messages in thread
From: Steve Ellcey @ 2012-10-23 22:14 UTC (permalink / raw)
  To: Roland McGrath; +Cc: Joseph S. Myers, libc-ports

On Tue, 2012-10-23 at 14:32 -0700, Roland McGrath wrote:
> > 	* sysdeps/mips/preconfigure: Create default_abi.make.
> 
> We use dashes in file names for the most part, not underscores.

OK, that is easy enough to change.

> > --- a/ports/sysdeps/mips/preconfigure
> > +++ b/ports/sysdeps/mips/preconfigure
> > @@ -1,3 +1,24 @@
> > +
> > +cat > conftest.c <<EOF
> > +#if defined(__mips_soft_float) && (_MIPS_SIM == _ABIO32)
> > +o32_soft
> > +#elif defined(__mips_hard_float) && (_MIPS_SIM == _ABIO32)
> > +o32_hard
> > +#elif defined(__mips_soft_float) && (_MIPS_SIM == _ABIN32)
> > +n32_soft
> > +#elif defined(__mips_hard_float) && (_MIPS_SIM == _ABIN32)
> > +n32_hard
> > +#elif defined(__mips_soft_float) && (_MIPS_SIM == _ABI64)
> > +n64_soft
> > +#elif defined(__mips_hard_float) && (_MIPS_SIM == _ABI64)
> > +n64_hard
> > +#else
> > +ERROR
> > +#endif
> > +EOF
> > +default_abi=`$CC $CFLAGS $CPPFLAGS -E -P conftest.c`
> > +echo "default-abi := $default_abi" >> default_abi.make
> 
> This should fail at configure time if something goes wrong,
> not produce bogus results.

OK, so I'll get rid of the #else/ERROR lines and then have the script
print an error message and 'exit 1' if default_abi does not get set.
That should also catch problems where the CC fails to execute or aborts
for some reason.

> Why does this need to be in preconfigure instead of configure?

It doesn't have to be.  I just put it there because that script was
already using CC and CFLAGS.  Is there are reason why it shouldn't
be there?  I guess I could put it in
ports/sysdeps/unix/sysv/linux/mips/configure.in instead since the
Makefile that includes the generated Makefile is in
ports/sysdeps/unix/sysv/linux/mips.  Would that be better?

Steve Ellcey
sellcey@mips.com


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-23 22:14               ` Steve Ellcey
@ 2012-10-23 22:48                 ` Roland McGrath
  2012-10-24 16:19                   ` Steve Ellcey
  0 siblings, 1 reply; 24+ messages in thread
From: Roland McGrath @ 2012-10-23 22:48 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: Joseph S. Myers, libc-ports

> OK, so I'll get rid of the #else/ERROR lines and then have the script
> print an error message and 'exit 1' if default_abi does not get set.
> That should also catch problems where the CC fails to execute or aborts
> for some reason.

Use a chain of AC_PREPROC_IFELSE or AC_COMPILE_IFELSE instead.
Use AC_MSG_ERROR for the failure case.

> > Why does this need to be in preconfigure instead of configure?
> 
> It doesn't have to be.  I just put it there because that script was
> already using CC and CFLAGS.  Is there are reason why it shouldn't
> be there?  

preconfigure is absolutely only for things that must be there.
That is, things that affect the sysdeps directory selection.

> I guess I could put it in ports/sysdeps/unix/sysv/linux/mips/configure.in
> instead since the Makefile that includes the generated Makefile is in
> ports/sysdeps/unix/sysv/linux/mips.  Would that be better?

Yes, that's the correct place.


Thanks,
Roland

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-23 20:20           ` Steve Ellcey
  2012-10-23 21:32             ` Roland McGrath
@ 2012-10-24  0:05             ` Joseph S. Myers
  1 sibling, 0 replies; 24+ messages in thread
From: Joseph S. Myers @ 2012-10-24  0:05 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: libc-ports

On Tue, 23 Oct 2012, Steve Ellcey wrote:

> 	* (abi-variants): Add hard and soft float versions.

No "* " before such a reference to a variable, only before file names.

> 	* (abi-*-options):  update with hard and soft flags.

Each changed variable needs naming individually.  Only one space after the 
colon.  Uppercase letter at the start of the description of the changes.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-23 22:48                 ` Roland McGrath
@ 2012-10-24 16:19                   ` Steve Ellcey
  2012-10-24 16:37                     ` Andreas Schwab
  2012-10-24 16:41                     ` Joseph S. Myers
  0 siblings, 2 replies; 24+ messages in thread
From: Steve Ellcey @ 2012-10-24 16:19 UTC (permalink / raw)
  To: Roland McGrath; +Cc: Joseph S. Myers, libc-ports

On Tue, 2012-10-23 at 15:48 -0700, Roland McGrath wrote:

> > I guess I could put it in ports/sysdeps/unix/sysv/linux/mips/configure.in
> > instead since the Makefile that includes the generated Makefile is in
> > ports/sysdeps/unix/sysv/linux/mips.  Would that be better?
> 
> Yes, that's the correct place.
> 
> 
> Thanks,
> Roland

Is there a 'trick' to modifying this configure.in file?  If I change
configure.in, remove all autom4te.cache directories from my source
directory, and do a configure/build, the configure file in this
directory does not seem to get automatically updated by autoconf.  If I
try to regenerate configure by running autoconf by hand in that
directory I wind up with an empty configure file (even with no changes
in configure.in).  I thought that the glibc configure/make process was
doing the autoconf automatically, but it doesn't seem to be working for
me now.

What is the right way to regenerate
ports/sysdeps/unix/sysv/linux/mips/configure from
ports/sysdeps/unix/sysv/linux/mips/configure.in?

Steve Ellcey
sellcey@mips.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-24 16:19                   ` Steve Ellcey
@ 2012-10-24 16:37                     ` Andreas Schwab
  2012-10-24 17:13                       ` Steve Ellcey
  2012-10-24 16:41                     ` Joseph S. Myers
  1 sibling, 1 reply; 24+ messages in thread
From: Andreas Schwab @ 2012-10-24 16:37 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: Roland McGrath, Joseph S. Myers, libc-ports

Steve Ellcey <sellcey@mips.com> writes:

> What is the right way to regenerate
> ports/sysdeps/unix/sysv/linux/mips/configure from
> ports/sysdeps/unix/sysv/linux/mips/configure.in?

Just running make should do it, see autoconf-it in toplevel Makefile.
Make sure that ports/sysdeps/unix/sysv/linux/mips is part of
sysd-rules-sysdirs.

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-24 16:19                   ` Steve Ellcey
  2012-10-24 16:37                     ` Andreas Schwab
@ 2012-10-24 16:41                     ` Joseph S. Myers
  1 sibling, 0 replies; 24+ messages in thread
From: Joseph S. Myers @ 2012-10-24 16:41 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: Roland McGrath, libc-ports

On Wed, 24 Oct 2012, Steve Ellcey wrote:

> What is the right way to regenerate
> ports/sysdeps/unix/sysv/linux/mips/configure from
> ports/sysdeps/unix/sysv/linux/mips/configure.in?

autoconf ports/sysdeps/unix/sysv/linux/mips/configure.in > ports/sysdeps/unix/sysv/linux/mips/configure

(having made sure that you have the right version - currently 2.68 - in 
your PATH; use unmodified autoconf rather than a modified distribution 
version).

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-24 16:37                     ` Andreas Schwab
@ 2012-10-24 17:13                       ` Steve Ellcey
  2012-10-24 17:25                         ` Roland McGrath
  0 siblings, 1 reply; 24+ messages in thread
From: Steve Ellcey @ 2012-10-24 17:13 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Roland McGrath, Joseph S. Myers, libc-ports

On Wed, 2012-10-24 at 18:37 +0200, Andreas Schwab wrote:
> Steve Ellcey <sellcey@mips.com> writes:
> 
> > What is the right way to regenerate
> > ports/sysdeps/unix/sysv/linux/mips/configure from
> > ports/sysdeps/unix/sysv/linux/mips/configure.in?
> 
> Just running make should do it, see autoconf-it in toplevel Makefile.
> Make sure that ports/sysdeps/unix/sysv/linux/mips is part of
> sysd-rules-sysdirs.
> 
> Andreas.

I think something is wrong with the rebuild logic somewhere.  I verified
that in config.make in my object directory there is a line:

config-sysdirs = .... ports/sysdeps/unix/sysv/linux/mips ....

and in Makerules I see:

ifneq ($(sysd-rules-sysdirs),$(config-sysdirs))

    (echo 'sysd-rules-sysdirs := $(config-sysdirs)';


But configure is still not being rebuilt automatically.  If I do a touch
of *all* configure.in files in my source directory, then the configure
file in ports/sysdeps/unix/sysv/linux/mips gets rebuilt.  But if I just
touch the one in ports/sysdeps/unix/sysv/linux/mips, I don't get any
rebuild.  Meanwhile, Josephs method of calling autoconf by hand from the
top-level is very useful while working on changes to configure.in files.

Steve Ellcey
sellcey@mips.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-24 17:13                       ` Steve Ellcey
@ 2012-10-24 17:25                         ` Roland McGrath
  2012-10-25  0:00                           ` Steve Ellcey
  0 siblings, 1 reply; 24+ messages in thread
From: Roland McGrath @ 2012-10-24 17:25 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: Andreas Schwab, Joseph S. Myers, libc-ports

There is a completely generic pattern rule near the top of Makefile that
handles this.  What must be missing is the dependency on that configure
script.  The config.status target in Makeconfig is where that dependency
should be.  The usual method to debug this sort of thing is to copy
verbatim the text of the dependency list into the ... place in:

foo:=$(shell echo>&2 'XXX ...')

and then look for the XXX on stderr to see the expansion.  If it omits any
configure fragments that are getting run by configure, then figure out
where the expansion is going wrong.  You can slice up the nested variable
expansions to print out intermediate values via debugging hacks as above
to figure out why it's not right.


Thanks,
Roland

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-24 17:25                         ` Roland McGrath
@ 2012-10-25  0:00                           ` Steve Ellcey
  2012-10-25 12:41                             ` Joseph S. Myers
  0 siblings, 1 reply; 24+ messages in thread
From: Steve Ellcey @ 2012-10-25  0:00 UTC (permalink / raw)
  To: Roland McGrath; +Cc: Andreas Schwab, Joseph S. Myers, libc-ports


OK, Here is my latest attempt at this patch.  I think I have addressed
all the issues raised.  FYI, I tried putting the AC_MSG_ERROR calls
directly into the last 'else' part of the nested AC_COMPILE_IFELSE
macros but that always resulted in an error during configure, that is
why I do a separate check and AC_MSG_ERROR call outside of the
AC_COMPILE_IFELSE macros.

Steve Ellcey
sellcey@mips.com

2012-10-24  Steve Ellcey  <sellcey@mips.com>

	* sysdeps/unix/sysv/linux/mips/mips32/Makefile: Remove.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/Makefile: Remove.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/Makefile: Remove.
	* sysdeps/unix/sysv/linux/mips/configure.in: Create default_abi.make.
	* sysdeps/unix/sysv/linux/mips/configure: Regenerate.
	* sysdeps/unix/sysv/linux/mips/Makefile: Include default_abi.make.
	(abi-variants): Add hard and soft float versions.
	(abi-o32-options): Remove.
	(abi-o32-condition): Remove.
	(abi-n32-options): Remove.
	(abi-n32-condition): Remove.
	(abi-n64-options): Remove.
	(abi-n64-condition): Remove.
	(abi-o32_soft-options): New.
	(abi-o32_soft-condition): New.
	(abi-o32_hard-options): New.
	(abi-o32_hard-condition): New.
	(abi-n32_soft-options): New.
	(abi-n32_soft-condition): New.
	(abi-n32_hard-options): New.
	(abi-n32_hard-condition): New.
	(abi-n64_soft-options): New.
	(abi-n64_soft-condition): New.
	(abi-n64_hard-options): New.
	(abi-n64_hard-condition): New.


diff --git a/ports/sysdeps/unix/sysv/linux/mips/Makefile b/ports/sysdeps/unix/sysv/linux/mips/Makefile
index 99c554f..9f7d702 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/Makefile
+++ b/ports/sysdeps/unix/sysv/linux/mips/Makefile
@@ -8,15 +8,36 @@ sysdep_routines += cachectl cacheflush sysmips _test_and_set
 sysdep_headers += sys/cachectl.h sys/sysmips.h sys/tas.h
 endif
 
-# _MIPS_SIM_ABI32 == 1, _MIPS_SIM_NABI32 == 2, _MIPS_SIM_ABI64 == 3
-abi-variants := o32 n32 n64
+# Get value of abi-default
+#include $(common-objpfx)default-abi.make
+
+abi-variants := o32_soft o32_hard n32_soft n32_hard n64_soft n64_hard
+
+#ifeq (,$(filter $(default-abi),$(abi-variants)))
+#Unknown ABI, must be one of $(abi-variants)
+#endif
+
 abi-includes := sgidefs.h
-abi-o32-options := -D_MIPS_SIM=1
-abi-o32-condition := _MIPS_SIM == _MIPS_SIM_ABI32
-abi-n32-options := -D_MIPS_SIM=2
-abi-n32-condition := _MIPS_SIM == _MIPS_SIM_NABI32
-abi-n64-options := -D_MIPS_SIM=3
-abi-n64-condition := _MIPS_SIM == _MIPS_SIM_ABI64
+
+# _MIPS_SIM_ABI32 == 1, _MIPS_SIM_NABI32 == 2, _MIPS_SIM_ABI64 == 3
+abi-o32_soft-options := -D_MIPS_SIM=1 -D__mips_soft_float
+abi-o32_soft-condition := defined(__mips_soft_float) \
+			   && (_MIPS_SIM == _MIPS_SIM_ABI32)
+abi-o32_hard-options := -D_MIPS_SIM=1 -D__mips_hard_float
+abi-o32_hard-condition := defined(__mips_hard_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_ABI32)
+abi-n32_soft-options := -D_MIPS_SIM=2 -D__mips_soft_float
+abi-n32_soft-condition := defined(__mips_soft_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_NABI32)
+abi-n32_hard-options := -D_MIPS_SIM=2 -D__mips_hard_float
+abi-n32_hard-condition := defined(__mips_hard_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_NABI32)
+abi-n64_soft-options := -D_MIPS_SIM=3 -D__mips_soft_float
+abi-n64_soft-condition := defined(__mips_soft_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_ABI64)
+abi-n64_hard-options := -D_MIPS_SIM=3 -D__mips_hard_float
+abi-n64_hard-condition := defined(__mips_hard_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_ABI64)
 
 ifeq ($(subdir),elf)
 ifeq ($(build-shared),yes)
diff --git a/ports/sysdeps/unix/sysv/linux/mips/configure.in b/ports/sysdeps/unix/sysv/linux/mips/configure.in
index 18e8bbc..07cffa3 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/configure.in
+++ b/ports/sysdeps/unix/sysv/linux/mips/configure.in
@@ -2,6 +2,50 @@ sinclude(./aclocal.m4)dnl Autoconf lossage
 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
 # Local configure fragment for sysdeps/unix/sysv/linux/mips.
 
+AC_COMPILE_IFELSE(
+  [AC_LANG_PROGRAM([
+    #if (_MIPS_SIM != _ABIO32)
+    #error Not O32 ABI
+    #endif])],
+  [libc_mips_abi=o32],
+  [AC_COMPILE_IFELSE(
+    [AC_LANG_PROGRAM([
+      #if (_MIPS_SIM != _ABIN32)
+      #error Not N32 ABI
+      #endif])],
+    [libc_mips_abi=n32],
+    [AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM([
+        #if (_MIPS_SIM != _ABI64)
+        #error Not 64 ABI
+        #endif])],
+      [libc_mips_abi=64],
+      [])])])
+
+if test -z "$libc_mips_abi"; then
+  AC_MSG_ERROR([could not determine what ABI the compiler is using])
+fi
+
+AC_COMPILE_IFELSE(
+  [AC_LANG_PROGRAM([
+    #if !defined(__mips_soft_float)
+    #error Not soft ABI
+    #endif])],
+  [libc_mips_float=soft],
+  [AC_COMPILE_IFELSE(
+    [AC_LANG_PROGRAM([
+      #if !defined(__mips_hard_float)
+      #error Not hard ABI
+      #endif])],
+    [libc_mips_float=hard],
+    [])])
+
+if test -z "$libc_mips_float"; then
+  AC_MSG_ERROR([could not determine if compiler is using hard or soft floating point ABI])
+fi
+
+echo "default-abi := ${libc_mips_abi}_${libc_mips_float}" > default-abi.make
+
 case "$prefix" in
 /usr | /usr/)
   # 64-bit libraries on bi-arch platforms go in /lib64 instead of /lib.



^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-25  0:00                           ` Steve Ellcey
@ 2012-10-25 12:41                             ` Joseph S. Myers
  2012-10-25 20:36                               ` Steve Ellcey
  2012-10-26 21:06                               ` Steve Ellcey
  0 siblings, 2 replies; 24+ messages in thread
From: Joseph S. Myers @ 2012-10-25 12:41 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: Roland McGrath, Andreas Schwab, libc-ports

On Wed, 24 Oct 2012, Steve Ellcey wrote:

> +# Get value of abi-default
> +#include $(common-objpfx)default-abi.make

Is this really tested for all ABI variants?  Having this commented out 
hardly makes sense....

> +#ifeq (,$(filter $(default-abi),$(abi-variants)))
> +#Unknown ABI, must be one of $(abi-variants)
> +#endif

Don't add new commented-out code.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-25 12:41                             ` Joseph S. Myers
@ 2012-10-25 20:36                               ` Steve Ellcey
  2012-10-26 21:06                               ` Steve Ellcey
  1 sibling, 0 replies; 24+ messages in thread
From: Steve Ellcey @ 2012-10-25 20:36 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Roland McGrath, Andreas Schwab, libc-ports

On Thu, 2012-10-25 at 12:41 +0000, Joseph S. Myers wrote:
> On Wed, 24 Oct 2012, Steve Ellcey wrote:
> 
> > +# Get value of abi-default
> > +#include $(common-objpfx)default-abi.make
> 
> Is this really tested for all ABI variants?  Having this commented out 
> hardly makes sense....
> 
> > +#ifeq (,$(filter $(default-abi),$(abi-variants)))
> > +#Unknown ABI, must be one of $(abi-variants)
> > +#endif
> 
> Don't add new commented-out code.

Neither of these (the include or the ifeq) should have been commented
out, that is a remnant of my development work.  I checked to make sure
that default-abi.make was getting created and had the right value but I
didn't check the actual stub files to make sure they looked right (they
aren't).  The build did work even with these commented out.  I will
uncomment these lines, rebuild, do more testing, and resubmit.

Steve Ellcey
sellcey@mips.com


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-25 12:41                             ` Joseph S. Myers
  2012-10-25 20:36                               ` Steve Ellcey
@ 2012-10-26 21:06                               ` Steve Ellcey
  2012-10-26 22:11                                 ` Joseph S. Myers
  1 sibling, 1 reply; 24+ messages in thread
From: Steve Ellcey @ 2012-10-26 21:06 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Roland McGrath, Andreas Schwab, libc-ports

On Thu, 2012-10-25 at 12:41 +0000, Joseph S. Myers wrote:
> On Wed, 24 Oct 2012, Steve Ellcey wrote:
> 
> > +# Get value of abi-default
> > +#include $(common-objpfx)default-abi.make
> 
> Is this really tested for all ABI variants?  Having this commented out 
> hardly makes sense....
> 
> > +#ifeq (,$(filter $(default-abi),$(abi-variants)))
> > +#Unknown ABI, must be one of $(abi-variants)
> > +#endif
> 
> Don't add new commented-out code.

OK, Here is my latest patch.  I uncommented these lines (which in turn
uncovered a bug in my change where I set libc_mips_abi to '64' instead
of 'n64'.  After fixing that I did some glibc native testing and some
GCC cross testing and everything looked good.  I didn't test every
combination of options, that would take forever, but I did look at the
abi-default settings and examined the stub files for various versions of
glibc builds (the 3 different ABIs, hard/soft float) to make sure they
all looked OK.

Steve Ellcey
sellcey@mips.com



2012-10-26  Steve Ellcey  <sellcey@mips.com>

	* sysdeps/unix/sysv/linux/mips/mips32/Makefile: Remove.
	* sysdeps/unix/sysv/linux/mips/mips64/n32/Makefile: Remove.
	* sysdeps/unix/sysv/linux/mips/mips64/n64/Makefile: Remove.
	* sysdeps/unix/sysv/linux/mips/configure.in: Create default_abi.make.
	* sysdeps/unix/sysv/linux/mips/configure: Regenerate.
	* sysdeps/unix/sysv/linux/mips/Makefile: Include default_abi.make.
	(abi-variants): Add hard and soft float versions.
	(abi-o32-options): Remove.
	(abi-o32-condition): Remove.
	(abi-n32-options): Remove.
	(abi-n32-condition): Remove.
	(abi-n64-options): Remove.
	(abi-n64-condition): Remove.
	(abi-o32_soft-options): New.
	(abi-o32_soft-condition): New.
	(abi-o32_hard-options): New.
	(abi-o32_hard-condition): New.
	(abi-n32_soft-options): New.
	(abi-n32_soft-condition): New.
	(abi-n32_hard-options): New.
	(abi-n32_hard-condition): New.
	(abi-n64_soft-options): New.
	(abi-n64_soft-condition): New.
	(abi-n64_hard-options): New.
	(abi-n64_hard-condition): New.

diff --git a/ports/sysdeps/unix/sysv/linux/mips/Makefile b/ports/sysdeps/unix/sysv/linux/mips/Makefile
index 99c554f..c188cae 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/Makefile
+++ b/ports/sysdeps/unix/sysv/linux/mips/Makefile
@@ -8,15 +8,36 @@ sysdep_routines += cachectl cacheflush sysmips _test_and_set
 sysdep_headers += sys/cachectl.h sys/sysmips.h sys/tas.h
 endif
 
-# _MIPS_SIM_ABI32 == 1, _MIPS_SIM_NABI32 == 2, _MIPS_SIM_ABI64 == 3
-abi-variants := o32 n32 n64
+# Get value of abi-default
+include $(common-objpfx)default-abi.make
+
+abi-variants := o32_soft o32_hard n32_soft n32_hard n64_soft n64_hard
+
+ifeq (,$(filter $(default-abi),$(abi-variants)))
+Unknown ABI, must be one of $(abi-variants)
+endif
+
 abi-includes := sgidefs.h
-abi-o32-options := -D_MIPS_SIM=1
-abi-o32-condition := _MIPS_SIM == _MIPS_SIM_ABI32
-abi-n32-options := -D_MIPS_SIM=2
-abi-n32-condition := _MIPS_SIM == _MIPS_SIM_NABI32
-abi-n64-options := -D_MIPS_SIM=3
-abi-n64-condition := _MIPS_SIM == _MIPS_SIM_ABI64
+
+# _MIPS_SIM_ABI32 == 1, _MIPS_SIM_NABI32 == 2, _MIPS_SIM_ABI64 == 3
+abi-o32_soft-options := -D_MIPS_SIM=1 -D__mips_soft_float
+abi-o32_soft-condition := defined(__mips_soft_float) \
+			   && (_MIPS_SIM == _MIPS_SIM_ABI32)
+abi-o32_hard-options := -D_MIPS_SIM=1 -D__mips_hard_float
+abi-o32_hard-condition := defined(__mips_hard_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_ABI32)
+abi-n32_soft-options := -D_MIPS_SIM=2 -D__mips_soft_float
+abi-n32_soft-condition := defined(__mips_soft_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_NABI32)
+abi-n32_hard-options := -D_MIPS_SIM=2 -D__mips_hard_float
+abi-n32_hard-condition := defined(__mips_hard_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_NABI32)
+abi-n64_soft-options := -D_MIPS_SIM=3 -D__mips_soft_float
+abi-n64_soft-condition := defined(__mips_soft_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_ABI64)
+abi-n64_hard-options := -D_MIPS_SIM=3 -D__mips_hard_float
+abi-n64_hard-condition := defined(__mips_hard_float) \
+			  && (_MIPS_SIM == _MIPS_SIM_ABI64)
 
 ifeq ($(subdir),elf)
 ifeq ($(build-shared),yes)
diff --git a/ports/sysdeps/unix/sysv/linux/mips/configure b/ports/sysdeps/unix/sysv/linux/mips/configure
index 051432d..36757e8 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/configure
+++ b/ports/sysdeps/unix/sysv/linux/mips/configure
@@ -1,6 +1,112 @@
 # This file is generated from configure.in by Autoconf.  DO NOT EDIT!
  # Local configure fragment for sysdeps/unix/sysv/linux/mips.
 
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+    #if (_MIPS_SIM != _ABIO32)
+    #error Not O32 ABI
+    #endif
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libc_mips_abi=o32
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+      #if (_MIPS_SIM != _ABIN32)
+      #error Not N32 ABI
+      #endif
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libc_mips_abi=n32
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+        #if (_MIPS_SIM != _ABI64)
+        #error Not 64 ABI
+        #endif
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libc_mips_abi=n64
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test -z "$libc_mips_abi"; then
+  as_fn_error "could not determine what ABI the compiler is using" "$LINENO" 5
+fi
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+    #if !defined(__mips_soft_float)
+    #error Not soft ABI
+    #endif
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libc_mips_float=soft
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+      #if !defined(__mips_hard_float)
+      #error Not hard ABI
+      #endif
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  libc_mips_float=hard
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test -z "$libc_mips_float"; then
+  as_fn_error "could not determine if compiler is using hard or soft floating point ABI" "$LINENO" 5
+fi
+
+echo "default-abi := ${libc_mips_abi}_${libc_mips_float}" > default-abi.make
+
 case "$prefix" in
 /usr | /usr/)
   # 64-bit libraries on bi-arch platforms go in /lib64 instead of /lib.
diff --git a/ports/sysdeps/unix/sysv/linux/mips/configure.in b/ports/sysdeps/unix/sysv/linux/mips/configure.in
index 18e8bbc..167779e 100644
--- a/ports/sysdeps/unix/sysv/linux/mips/configure.in
+++ b/ports/sysdeps/unix/sysv/linux/mips/configure.in
@@ -2,6 +2,50 @@ sinclude(./aclocal.m4)dnl Autoconf lossage
 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
 # Local configure fragment for sysdeps/unix/sysv/linux/mips.
 
+AC_COMPILE_IFELSE(
+  [AC_LANG_PROGRAM([
+    #if (_MIPS_SIM != _ABIO32)
+    #error Not O32 ABI
+    #endif])],
+  [libc_mips_abi=o32],
+  [AC_COMPILE_IFELSE(
+    [AC_LANG_PROGRAM([
+      #if (_MIPS_SIM != _ABIN32)
+      #error Not N32 ABI
+      #endif])],
+    [libc_mips_abi=n32],
+    [AC_COMPILE_IFELSE(
+      [AC_LANG_PROGRAM([
+        #if (_MIPS_SIM != _ABI64)
+        #error Not 64 ABI
+        #endif])],
+      [libc_mips_abi=n64],
+      [])])])
+
+if test -z "$libc_mips_abi"; then
+  AC_MSG_ERROR([could not determine what ABI the compiler is using])
+fi
+
+AC_COMPILE_IFELSE(
+  [AC_LANG_PROGRAM([
+    #if !defined(__mips_soft_float)
+    #error Not soft ABI
+    #endif])],
+  [libc_mips_float=soft],
+  [AC_COMPILE_IFELSE(
+    [AC_LANG_PROGRAM([
+      #if !defined(__mips_hard_float)
+      #error Not hard ABI
+      #endif])],
+    [libc_mips_float=hard],
+    [])])
+
+if test -z "$libc_mips_float"; then
+  AC_MSG_ERROR([could not determine if compiler is using hard or soft floating point ABI])
+fi
+
+echo "default-abi := ${libc_mips_abi}_${libc_mips_float}" > default-abi.make
+
 case "$prefix" in
 /usr | /usr/)
   # 64-bit libraries on bi-arch platforms go in /lib64 instead of /lib.


^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-26 21:06                               ` Steve Ellcey
@ 2012-10-26 22:11                                 ` Joseph S. Myers
  2012-10-26 23:00                                   ` Roland McGrath
  0 siblings, 1 reply; 24+ messages in thread
From: Joseph S. Myers @ 2012-10-26 22:11 UTC (permalink / raw)
  To: Steve Ellcey; +Cc: Roland McGrath, Andreas Schwab, libc-ports

On Fri, 26 Oct 2012, Steve Ellcey wrote:

> +# Get value of abi-default

You mean, of default-abi.  '.' at end of comment.

> +abi-o32_soft-options := -D_MIPS_SIM=1 -D__mips_soft_float

Should also have -U__mips_hard_float (and, I'd say, -U_MIPS_SIM before the 
-D_MIPS_SIM=1).  Likewise for the other *-options variables.  This 
probably won't cause any issues in practice, since the syscall list don't 
depend on hard/soft float and that's where the *-options values are used, 
but it's logically correct.

OK with those changes if Roland doesn't see any other problems.

-- 
Joseph S. Myers
joseph@codesourcery.com

^ permalink raw reply	[flat|nested] 24+ messages in thread

* Re: [patch, mips] Fix stubs files for hard float vs. soft float
  2012-10-26 22:11                                 ` Joseph S. Myers
@ 2012-10-26 23:00                                   ` Roland McGrath
  0 siblings, 0 replies; 24+ messages in thread
From: Roland McGrath @ 2012-10-26 23:00 UTC (permalink / raw)
  To: Joseph S. Myers; +Cc: Steve Ellcey, Andreas Schwab, libc-ports

> OK with those changes if Roland doesn't see any other problems.

I didn't look at the last version closely.  The essential style of the
configure check is about right, and if the rest looks fine to you then
it's probably all fine.

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2012-10-26 23:00 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-15 20:15 [patch, mips] Fix stubs files for hard float vs. soft float Steve Ellcey 
2012-10-15 21:15 ` Andreas Schwab
2012-10-15 21:23   ` Andreas Schwab
2012-10-15 22:08 ` Joseph S. Myers
2012-10-15 23:06   ` Steve Ellcey
2012-10-15 23:31     ` Joseph S. Myers
2012-10-22 23:31       ` Steve Ellcey
2012-10-22 23:38         ` Joseph S. Myers
2012-10-23 20:20           ` Steve Ellcey
2012-10-23 21:32             ` Roland McGrath
2012-10-23 22:14               ` Steve Ellcey
2012-10-23 22:48                 ` Roland McGrath
2012-10-24 16:19                   ` Steve Ellcey
2012-10-24 16:37                     ` Andreas Schwab
2012-10-24 17:13                       ` Steve Ellcey
2012-10-24 17:25                         ` Roland McGrath
2012-10-25  0:00                           ` Steve Ellcey
2012-10-25 12:41                             ` Joseph S. Myers
2012-10-25 20:36                               ` Steve Ellcey
2012-10-26 21:06                               ` Steve Ellcey
2012-10-26 22:11                                 ` Joseph S. Myers
2012-10-26 23:00                                   ` Roland McGrath
2012-10-24 16:41                     ` Joseph S. Myers
2012-10-24  0:05             ` Joseph S. Myers

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).