public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* fix aix build error with math.h in gcc/sreal.c
@ 2014-12-16 16:06 Michael Haubenwallner
  2014-12-16 18:53 ` Richard Biener
  0 siblings, 1 reply; 5+ messages in thread
From: Michael Haubenwallner @ 2014-12-16 16:06 UTC (permalink / raw)
  To: GCC Patches; +Cc: David Edelsohn, Jan Hubicka

[-- Attachment #1: Type: text/plain, Size: 407 bytes --]

Recent commit 218765 adding sreal::to_double() breaks on AIX due to math.h
being included before _LARGE_FILES and __STDC_FORMAT_MACROS being defined
later in config.h and system.h, respectively.

2014-12-16  Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>

        Both config.h and system.h define ABI/API macros for system headers.
        * sreal.c: Include math.h later.

Thanks!
/haubi/

[-- Attachment #2: gcc-sreal-math.patch --]
[-- Type: text/x-patch, Size: 338 bytes --]

Index: gcc/sreal.c
===================================================================
--- gcc/sreal.c	(revision 218780)
+++ gcc/sreal.c	(working copy)
@@ -47,9 +47,9 @@
 	sig == 0 && exp == -SREAL_MAX_EXP
 */
 
-#include <math.h>
 #include "config.h"
 #include "system.h"
+#include <math.h>
 #include "coretypes.h"
 #include "sreal.h"
 

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

* Re: fix aix build error with math.h in gcc/sreal.c
  2014-12-16 16:06 fix aix build error with math.h in gcc/sreal.c Michael Haubenwallner
@ 2014-12-16 18:53 ` Richard Biener
  2014-12-16 19:15   ` Jan Hubicka
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2014-12-16 18:53 UTC (permalink / raw)
  To: Michael Haubenwallner; +Cc: GCC Patches, David Edelsohn, Jan Hubicka

On Tue, Dec 16, 2014 at 5:04 PM, Michael Haubenwallner
<michael.haubenwallner@ssi-schaefer.com> wrote:
> Recent commit 218765 adding sreal::to_double() breaks on AIX due to math.h
> being included before _LARGE_FILES and __STDC_FORMAT_MACROS being defined
> later in config.h and system.h, respectively.

sreal.c shouldn't include math.h, if really really really needed
math.h needs to be
included from system.h at the appropriate place.

Richard,

> 2014-12-16  Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
>
>         Both config.h and system.h define ABI/API macros for system headers.
>         * sreal.c: Include math.h later.
>
> Thanks!
> /haubi/

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

* Re: fix aix build error with math.h in gcc/sreal.c
  2014-12-16 18:53 ` Richard Biener
@ 2014-12-16 19:15   ` Jan Hubicka
  2014-12-17  9:39     ` Richard Biener
  0 siblings, 1 reply; 5+ messages in thread
From: Jan Hubicka @ 2014-12-16 19:15 UTC (permalink / raw)
  To: Richard Biener
  Cc: Michael Haubenwallner, GCC Patches, David Edelsohn, Jan Hubicka

> On Tue, Dec 16, 2014 at 5:04 PM, Michael Haubenwallner
> <michael.haubenwallner@ssi-schaefer.com> wrote:
> > Recent commit 218765 adding sreal::to_double() breaks on AIX due to math.h
> > being included before _LARGE_FILES and __STDC_FORMAT_MACROS being defined
> > later in config.h and system.h, respectively.
> 
> sreal.c shouldn't include math.h, if really really really needed
> math.h needs to be
> included from system.h at the appropriate place.

Hmm, I need math.h for the exponential function. genautomata is also including math.h.
Should we thus move it to system.h

Something like this?

Since i do not caremuch about performance of to_double, we could also just have loop
that multiplies/divides by 2 until exponent is reached. It is rather lame though.

Honza

Index: system.h
===================================================================
--- system.h    (revision 218788)
+++ system.h    (working copy)
@@ -45,6 +45,8 @@
 
 #include <stdio.h>
 
+#include <math.h>
+
 /* Define a generic NULL if one hasn't already been defined.  */
 #ifndef NULL
 #define NULL 0
Index: genautomata.c
===================================================================
--- genautomata.c       (revision 218788)
+++ genautomata.c       (working copy)
@@ -113,7 +113,6 @@
 #include "errors.h"
 #include "gensupport.h"
 
-#include <math.h>
 #include "hashtab.h"
 #include "vec.h"
 #include "fnmatch.h"
Index: sreal.c
===================================================================
--- sreal.c     (revision 218788)
+++ sreal.c     (working copy)
@@ -49,7 +49,6 @@
 
 #include "config.h"
 #include "system.h"
-#include <math.h>
 #include "coretypes.h"
 #include "sreal.h"
 

> 
> Richard,
> 
> > 2014-12-16  Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
> >
> >         Both config.h and system.h define ABI/API macros for system headers.
> >         * sreal.c: Include math.h later.
> >
> > Thanks!
> > /haubi/

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

* Re: fix aix build error with math.h in gcc/sreal.c
  2014-12-16 19:15   ` Jan Hubicka
@ 2014-12-17  9:39     ` Richard Biener
  2014-12-17 22:11       ` Mike Stump
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Biener @ 2014-12-17  9:39 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: Michael Haubenwallner, GCC Patches, David Edelsohn

On Tue, Dec 16, 2014 at 8:05 PM, Jan Hubicka <hubicka@ucw.cz> wrote:
>> On Tue, Dec 16, 2014 at 5:04 PM, Michael Haubenwallner
>> <michael.haubenwallner@ssi-schaefer.com> wrote:
>> > Recent commit 218765 adding sreal::to_double() breaks on AIX due to math.h
>> > being included before _LARGE_FILES and __STDC_FORMAT_MACROS being defined
>> > later in config.h and system.h, respectively.
>>
>> sreal.c shouldn't include math.h, if really really really needed
>> math.h needs to be
>> included from system.h at the appropriate place.
>
> Hmm, I need math.h for the exponential function. genautomata is also including math.h.
> Should we thus move it to system.h

Do we even link GCC with libm ...?  Probably as a side-effect with linking with
mpfr?  Only genautomata is explicitely linked with -lm.

Can't you simply prototype exp2() properly?  Also we don't require a
C99 runtime,
so I'm not sure that exp2 is available everywhere (didn't check the C++ standard
when it appears, but if then via <cmath>, not <math.h> I suppose - but cmath
doesn't have exp2).

Please avoid libm code in GCC, I suppose using std::pow (2., (int)m_exp) is
ok though after including <cmath> - there is a double, int overload that
uses __builtin_powi which eventually expands to a libgcc call.

Thus following genautomata I suppose we can try including <cmath> in
sreal.c after the system.h include and if that works everywhere fine.

Thanks,
Richard.

> Something like this?
>
> Since i do not caremuch about performance of to_double, we could also just have loop
> that multiplies/divides by 2 until exponent is reached. It is rather lame though.
>
> Honza
>
> Index: system.h
> ===================================================================
> --- system.h    (revision 218788)
> +++ system.h    (working copy)
> @@ -45,6 +45,8 @@
>
>  #include <stdio.h>
>
> +#include <math.h>
> +
>  /* Define a generic NULL if one hasn't already been defined.  */
>  #ifndef NULL
>  #define NULL 0
> Index: genautomata.c
> ===================================================================
> --- genautomata.c       (revision 218788)
> +++ genautomata.c       (working copy)
> @@ -113,7 +113,6 @@
>  #include "errors.h"
>  #include "gensupport.h"
>
> -#include <math.h>
>  #include "hashtab.h"
>  #include "vec.h"
>  #include "fnmatch.h"
> Index: sreal.c
> ===================================================================
> --- sreal.c     (revision 218788)
> +++ sreal.c     (working copy)
> @@ -49,7 +49,6 @@
>
>  #include "config.h"
>  #include "system.h"
> -#include <math.h>
>  #include "coretypes.h"
>  #include "sreal.h"
>
>
>>
>> Richard,
>>
>> > 2014-12-16  Michael Haubenwallner <michael.haubenwallner@ssi-schaefer.com>
>> >
>> >         Both config.h and system.h define ABI/API macros for system headers.
>> >         * sreal.c: Include math.h later.
>> >
>> > Thanks!
>> > /haubi/

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

* Re: fix aix build error with math.h in gcc/sreal.c
  2014-12-17  9:39     ` Richard Biener
@ 2014-12-17 22:11       ` Mike Stump
  0 siblings, 0 replies; 5+ messages in thread
From: Mike Stump @ 2014-12-17 22:11 UTC (permalink / raw)
  To: Richard Biener
  Cc: Jan Hubicka, Michael Haubenwallner, GCC Patches, David Edelsohn

On Dec 17, 2014, at 1:34 AM, Richard Biener <richard.guenther@gmail.com> wrote:
> Do we even link GCC with libm …?

Yes.  :-)  If you grew up on C++, you would realize, -lm as you call it, is just there in C++, always.  If you compile with g++ -v, you will even see it.

> Also we don't require a C99 runtime,

With the major version bump, and considering the age of a system that runs an OS from that era, I think these are mainly museum pieces.  I think it would be reasonable to add that requirement.  I think we should accept any patches from folks that want gcc to still work for whatever reason in such an environment, but, they can use libliberty, autoconfg, gnulib or some other advanced technique to make things work.  For exp2, gnulib states:

  This function is missing on some platforms: MacOS X 10.3, FreeBSD 5.2.1, NetBSD 3.0, OpenBSD 3.8, AIX 5.1, IRIX 6.5, OSF/1 4.0, Solaris 9, Interix 3.5.

to put a specific context of which systems are affected by this.  These tend to be 10 year old systems.

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

end of thread, other threads:[~2014-12-17 22:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-12-16 16:06 fix aix build error with math.h in gcc/sreal.c Michael Haubenwallner
2014-12-16 18:53 ` Richard Biener
2014-12-16 19:15   ` Jan Hubicka
2014-12-17  9:39     ` Richard Biener
2014-12-17 22:11       ` Mike Stump

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).