mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: "Alex Rønne Petersen" <alex@alexrp.com>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Re: [PATCH] configure: prevent compilers from turning a * b + c into fma(a, b, c)
Date: Fri, 21 Feb 2025 19:37:11 -0500	[thread overview]
Message-ID: <20250222003710.GH1827@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAH9TF6Mtk=3Pw2fHXXBxNMUkBOKsB1orF8b0k7dqkRuON29dYQ@mail.gmail.com>

On Fri, Dec 06, 2024 at 01:54:45AM +0100, Alex Rønne Petersen wrote:
> On Wed, Aug 28, 2024 at 5:28 PM Alex Rønne Petersen <alex@alexrp.com> wrote:
> >
> > I've seen Clang do this for expressions in the fma() implementation itself,
> > which of course led to infinite recursion. This happened when targeting
> > arm-linux-musleabi with full soft float mode and -march=armv8-a. I imagine
> > it's possible for GCC to do similar silliness.
> >
> > Work around this by passing -ffp-contract=off for Clang and -mno-fused-madd
> > for GCC. This matches what glibc's configure.ac does, FWIW.
> > ---
> >  configure | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> >
> > diff --git a/configure b/configure
> > index bc9fbe48..7028793f 100755
> > --- a/configure
> > +++ b/configure
> > @@ -355,6 +355,15 @@ tryflag CFLAGS_C99FSE -fexcess-precision=standard \
> >  || { test "$ARCH" = i386 && tryflag CFLAGS_C99FSE -ffloat-store ; }
> >  tryflag CFLAGS_C99FSE -frounding-math
> >
> > +#
> > +# Prevent the compiler from turning a * b + c into an fma() call.
> > +# Clang at least has been known to do this in the implementation of
> > +# fma() itself when targeting arm-linux-musleabi and armv8-a, causing
> > +# infinite recursion.
> > +#
> > +tryflag CFLAGS_C99FSE -mno-fused-madd
> > +tryflag CFLAGS_C99FSE -ffp-contract=off
> > +
> >  #
> >  # Semantically we want to insist that our sources follow the
> >  # C rules for type-based aliasing, but most if not all real-world
> > --
> > 2.40.1
> >
> 
> Ping. Is the patch acceptable without -mno-fused-madd (for ancient
> GCCs)? If so, should I re-send without that line?

If this is needed at all (IIRC I was unclear on how it was needed at
all with -ffreestanding) then I'd prefer to also include the option to
unbreak old GCC.

Rich

  reply	other threads:[~2025-02-22  0:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-28 15:28 [musl] " Alex Rønne Petersen
2024-08-28 15:53 ` Alexander Monakov
2024-08-28 16:31   ` Alex Rønne Petersen
2024-08-28 20:15   ` Rich Felker
2024-08-28 20:32     ` Alexander Monakov
2024-08-28 20:47       ` Rich Felker
2024-08-28 21:11         ` Alexander Monakov
2024-08-29 13:37           ` Alex Rønne Petersen
2024-08-28 19:56 ` Alexander Monakov
2024-08-29 13:36   ` Alex Rønne Petersen
2024-08-29 15:09     ` Alexander Monakov
2024-12-06  0:54 ` [musl] " Alex Rønne Petersen
2025-02-22  0:37   ` Rich Felker [this message]
2025-02-22  0:47     ` Alex Rønne Petersen
2025-04-14  9:37       ` Szabolcs Nagy

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=20250222003710.GH1827@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=alex@alexrp.com \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).