public inbox for fortran@gcc.gnu.org
 help / color / mirror / Atom feed
From: Steve Kargl <sgk@troutmask.apl.washington.edu>
To: Janne Blomqvist <blomqvist.janne@gmail.com>
Cc: FX Coudert <fxcoudert@gmail.com>, fortran <fortran@gcc.gnu.org>,
	gcc-patches@gcc.gnu.org
Subject: Re: [Fortran] half-cycle trig functions and atan[d] fixes
Date: Wed, 24 Jan 2024 11:28:34 -0800	[thread overview]
Message-ID: <ZbFk4qcqZ0EQ4dXa@troutmask.apl.washington.edu> (raw)
In-Reply-To: <CAO9iq9Ft3X=80Hvh8+UGTkqcWeyJE9ye3v5j2aJRczPZ_g7Kzw@mail.gmail.com>

On Wed, Jan 24, 2024 at 11:13:05AM +0200, Janne Blomqvist wrote:
> On Wed, Jan 24, 2024 at 10:28 AM FX Coudert <fxcoudert@gmail.com> wrote:
> > > Now, if
> > > the OS adds cospi() to libm and it's in libm's symbol map, then the
> > > cospi() used by gfortran depends on the search order of the loaded
> > > libraries.
> >
> > We only include the fallback math functions in libgfortran when they are not available on the system. configure detects what is present in the libc being targeted, and conditionally compiles the necessary fallback functions (and only them).
> 
> Exactly. However, there is the (corner?) case when libgfortran has
> been compiled, and cospi() not found and thus the fallback
> implementation is included, and then later libc is updated to a
> version that does provide cospi(). I believe in that case which
> version gets used is down to the library search order (i.e. the order
> that "ldd /path/to/binary" prints the libs), it will use the first
> symbol it finds.  Also, it's not necessary to do some ifdef tricks
> with gfortran.map, if a symbol listed there isn't found in the library
> it's just ignored. So the *pi() trig functions can be unconditionally
> added there, and then depending on whether the target libm includes
> those or not they are then included in the exported symbol list.
> 
> It's possible to override this to look for specific symbol versions
> etc., but that probably goes deep into the weeds of target-specific
> stuff (e.g. are we looking for cospi@FBSD_1.7, cospi@GLIBC_X.Y.Z, or
> something else?). I'm sure you don't wanna go there.
> 

Ah, so that's the part I was missing.  I was under the impression
that if a symbol appears in a libraries symbol map, then the
library had to contain a function by that name.  If the loader
ignores symbols for a missing function, then yes, I think I can
get rid of the indirection via _gfortran_cospi_r4().  It will
take a few days for me to redesign this, which shouldn't be too
problematic in that GCC is in stage 4 and this is neither a
regression or doc fix.

Janne, FX, Harald, thanks for taking a peek.

-- 
Steve

  parent reply	other threads:[~2024-01-24 19:28 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-20 20:10 Steve Kargl
2024-01-23  9:08 ` FX Coudert
2024-01-23 11:37   ` Janne Blomqvist
2024-01-23 17:30     ` Steve Kargl
2024-01-24  6:21     ` Steve Kargl
2024-01-24  8:28       ` FX Coudert
2024-01-24  9:13         ` Janne Blomqvist
2024-01-24 17:23           ` Harald Anlauf
2024-01-24 19:28           ` Steve Kargl [this message]
2024-01-23 14:40   ` Steve Kargl
2024-01-23 17:21     ` Steve Kargl

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=ZbFk4qcqZ0EQ4dXa@troutmask.apl.washington.edu \
    --to=sgk@troutmask.apl.washington.edu \
    --cc=blomqvist.janne@gmail.com \
    --cc=fortran@gcc.gnu.org \
    --cc=fxcoudert@gmail.com \
    --cc=gcc-patches@gcc.gnu.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).