public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Xi Ruoyao <xry111@xry111.site>
To: caiyinyu <caiyinyu@loongson.cn>, Florian Weimer <fweimer@redhat.com>
Cc: josmyers@redhat.com, libc-alpha@sourceware.org,
	 adhemerval.zanella@linaro.org
Subject: Re: [PATCH] LoongArch: Add soft floating-point fe* function implementations.
Date: Tue, 02 Apr 2024 18:40:06 +0800	[thread overview]
Message-ID: <98f2d5adc158e05a3fa487a8a3a3899734b97a45.camel@xry111.site> (raw)
In-Reply-To: <393612ff-b4fa-6047-d203-5b23bd96d29a@loongson.cn>

On Tue, 2024-04-02 at 11:40 +0800, caiyinyu wrote:
> The LoongArch soft ABI was added to glibc in version 2.37[1], but it was 
> not fully implemented,
> lacking functions for handling soft float exceptions/rounding modes. 
> This patch fills in
> the missing functions and fixes related failed test cases.
> Therefore, would backporting this patch to 2.37 be sufficient?

The problem is this change is breaking ABI.  The behavior of
feenableexcept etc. *is* a part of the ABI.  For example, if a not so
careful programmer invokes feenableexcept(FE_INVALID) and then
mistakenly invokes something like acos(1.0000001), before this change
the program will continue to run with a NaN, but after this change it'll
crash with SIGFPE.

You may argue such a program is buggy, but ABI stability requires that
even such a buggy program should still behave, unless it's invoking an
undefined behavior per the specification **when the program was built**.
For example, on x86_64 Glibc still have memcpy@GLIBC_2.2.5 which is
actually memmove, to support programs built before ISO C (invoking
memcpy with overlapping ranges, doing so was well defined before ISO C
but an undefined behavior today).

In this case, the specification before Glibc 2.40 is well defined as
"feenableexcept will do nothing and return an error": there is even a
linker warning actively tells the user this definition!

So backporting this to 2.37 is a no-go.  Doing so will back-stab people
relying on the ABI stability of the rolling-release branch.  
Instead we should raise the ABI version to 2.40, so soft-fp programs
linked with these Glibc-2.37 functions will refuse to run with Glibc-
2.40.  This is "adding a new ABI."

In the NEWS file we can tell the users "if your program errors out with
`cannot find ${something}@GLIBC_2_37`, you need to relink it and test it
thoroughly again to ensure it does not intentionally or unintentionally
relies on the behavior predating Glibc 2.40."

Or maybe we can provide both feenableexcept@GLIBC_2_37 and
feenableexcept@GLIBC_2_40 in libm.so.6?  I don't know if doing so is
really possible.

-- 
Xi Ruoyao <xry111@xry111.site>
School of Aerospace Science and Technology, Xidian University

  reply	other threads:[~2024-04-02 10:40 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-26 12:46 caiyinyu
2024-03-26 17:34 ` Joseph Myers
2024-03-27  8:42   ` caiyinyu
2024-03-27 17:10     ` Joseph Myers
2024-03-31 10:14       ` caiyinyu
2024-04-01 13:19         ` Florian Weimer
2024-04-02  3:40           ` caiyinyu
2024-04-02 10:40             ` Xi Ruoyao [this message]
2024-04-02 11:45               ` Florian Weimer
2024-04-02 12:02                 ` Xi Ruoyao
2024-04-02 12:34                   ` Florian Weimer
2024-04-02 12:12               ` Andreas Schwab
2024-04-02 21:18             ` Joseph Myers
2024-03-31 10:31       ` caiyinyu
2024-04-02 21:10         ` Joseph Myers
2024-04-02 14:46 caiyinyu

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=98f2d5adc158e05a3fa487a8a3a3899734b97a45.camel@xry111.site \
    --to=xry111@xry111.site \
    --cc=adhemerval.zanella@linaro.org \
    --cc=caiyinyu@loongson.cn \
    --cc=fweimer@redhat.com \
    --cc=josmyers@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /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).