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: Tue, 23 Jan 2024 22:21:00 -0800	[thread overview]
Message-ID: <ZbCsTM9ZAicn28tM@troutmask.apl.washington.edu> (raw)
In-Reply-To: <CAO9iq9F8xUbRefzVQn0xV+MmZXTB_FodL-sUYz_uz+82-6ue2A@mail.gmail.com>

On Tue, Jan 23, 2024 at 01:37:54PM +0200, Janne Blomqvist wrote:
> 
> > - If I get this right, to take one example, the Fortran front-end will emit a call to gfortran_acospi_r4(), libgfortran provides this as a wrapper calling acospif(), which is called either from libm or from libgfortran. This is different from other math library functions, like ACOS() where the acosf() call is generated directly from the front-end (and then the implementation comes either from libm or from libgfortran). Why not follow our usual way of doing things?
> 
> Good point, that's what we've done in c99_functions.c in libgfortran.
> We should probably do this so we can skip jumping via libgfortran when
> libm implements these directly.
> 

Hopefully, FX sees this as my emails to gmail bounce.

I don't see how this can work or I don't understand symbol versioning
in libraries.

If an OS does not supply cospi() in its libm, then gfortran will
fallback to a cospi() in libgfortran.  With the indirection I 
currently implement, cospi() is not in the symbol map of libgfortran
and _gfortran_cospi_r4() will use the libgfortran version.  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.  Consider on FreeBSD, I have

% nm --dynamic /lib/libm.so.5 | grep cospi
0000000000025b60 T cospi@@FBSD_1.7
0000000000025fe0 T cospif@@FBSD_1.7
000000000002e230 T cospil@@FBSD_1.7

% nm --dynamic work/lib/libgfortran.so.5 | grep cospi
00000000002b1e60 T _gfortran_acospi_r10@@GFORTRAN_14
00000000002b4590 T _gfortran_acospi_r16@@GFORTRAN_14
00000000002b1d80 T _gfortran_acospi_r4@@GFORTRAN_14
00000000002b1df0 T _gfortran_acospi_r8@@GFORTRAN_14
00000000002b1ea0 T _gfortran_cospi_r10@@GFORTRAN_14
00000000002b46d0 T _gfortran_cospi_r16@@GFORTRAN_14
00000000002b1dc0 T _gfortran_cospi_r4@@GFORTRAN_14
00000000002b1e30 T _gfortran_cospi_r8@@GFORTRAN_14
                 U cospi@FBSD_1.7
                 U cospif@FBSD_1.7
                 U cospil@FBSD_1.7

The FE generates code for _gfortran_cospi_rXX.  If FreeBSD
adds say acospif() and libgfortran also exported, then 
how does the linker choose between acospif@@FBSD_1.7 and
acospif@@GFORTRAN_14?.

-- 
Steve

  parent reply	other threads:[~2024-01-24  6:21 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 [this message]
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
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=ZbCsTM9ZAicn28tM@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).