public inbox for newlib@sourceware.org
 help / color / mirror / Atom feed
From: "Howland, Craig D. - US via newlib" <newlib@sourceware.org>
To: Newlib <newlib@sourceware.org>
Subject: Re: i386 and x86_64 fenv support
Date: Tue, 27 Aug 2019 17:51:00 -0000	[thread overview]
Message-ID: <1566928274715.79162@caci.com> (raw)
In-Reply-To: <CAF9ehCXyEbaciR0b2YSh4HaoUBbFN546u61H8xL8D6uvusppjA@mail.gmail.com>

> From: newlib-owner@sourceware.org <newlib-owner@sourceware.org> on behalf of Joel Sherrill <joel@rtems.org>
> Sent: Tuesday, August 27, 2019 1:30 PM
> To: Joseph Myers
> Cc: Newlib
> Subject: Re: i386 and x86_64 fenv support
>
> On Tue, Aug 27, 2019 at 12:11 PM Joseph Myers <joseph@codesourcery.com> wrote:
> >
> > On Tue, 27 Aug 2019, Joel Sherrill wrote:
> >
> > > FWIW this moved up in importance because the x86_64 RTEMS toolchain
> > > won't build with the gcc/newlib master because libquadmath assumes the
> > > existence of the FE_TONEAREST since it the autoconf probe now sees
> > > we have fenv.h support now. This is probably a bug in this code since it
> > > can't assume a rounding mode is supported.
> >
> > The rule in glibc is that architectures without support for rounding modes
> > still define FE_TONEAREST, and return it from fegetround and accept it for
> > fesetround, reflecting that to-nearest is the default (and only) rounding
> > mode.
> >
> > That is, only architectures that don't support to-nearest at all should
> > fail to define FE_TONEAREST (and libquadmath doesn't support any such
> > architectures anyway).
>
> So the stub version should define FE_TONEAREST, return 0 if that's the input
> to fesetround, and return FE_TONEAREST from fegetround? The discussion
> when the behavior was picked was to match soft float. But we could have
> easily missed something.
That GLIBC requirement violates what the standards say.  C99 says, "Each of
the macros FE_DOWNWARD FE_TONEAREST FE_TOWARDZERO FE_UPWARD is defined if and 
only if the implementation supports getting and setting the represented 
rounding direction by means of the fegetround and fesetround functions."
This GLIBC rule is saying that you have to pretend FE_TONEAREST works, even
when it does not.  It does half of what is required, allowing that value
with the functions, except they don't really do it.  And it also then 
improperly tells code that is the fixed rounding direction, when it really
is not.  So while I can see how GLIBC might have chosen that for expediency,
I think it is a very bad thing.  The best thing would be to not let GCC 
tell there is fenv support when there is not.  We were fine before, but now
the new fenv.h in Newlib breaks that due to this FE_TONEAREST quirk.  So is 
there a way to have the GCC autoconf libquadmath "have fenv?" check fail 
when we're only supplying the stub?  (It seems to me that it really ought to 
fail if FE_TONEAREST is not defined, since that is required.  I'd call it
a GCC bug, but we can at least try to work around it.)
 
Craig

  reply	other threads:[~2019-08-27 17:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-27 13:32 Joel Sherrill
2019-08-27 13:37 ` Eric Blake
2019-08-27 13:45   ` Joel Sherrill
2019-08-27 15:39 ` Corinna Vinschen
2019-08-27 15:46   ` Joel Sherrill
2019-08-27 15:55     ` Corinna Vinschen
2019-08-27 17:11 ` Joseph Myers
2019-08-27 17:30   ` Joel Sherrill
2019-08-27 17:51     ` Howland, Craig D. - US via newlib [this message]
2019-08-27 19:48       ` Joseph Myers

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1566928274715.79162@caci.com \
    --to=newlib@sourceware.org \
    --cc=craig.howland@caci.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).