public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Luca Bacci <luca.bacci982@gmail.com>
To: gcc@gcc.gnu.org
Subject: Checking for built-in functions from build systems
Date: Wed, 10 Aug 2022 23:11:13 +0200	[thread overview]
Message-ID: <CAJSEPt1Fab81gBq6zA8LkshGYyp-oKZXm=fLUYQPgz_PY56GZw@mail.gmail.com> (raw)

Hello dear GCC developers,

I am working on an issue in Meson wrt GCC built-in functions, see
https://github.com/mesonbuild/meson/issues/10641.

As you already know, some built-ins are always inlined, while others are
inlined only at times (e.g. depending on the target architecture) and
resolve to a regular function call otherwise. The issue is about the
latter's, i.e. those that may emit regular function calls.

In fact, even though __has_builtin(func) evaluates to 1, func may not be
present in libraries (libgcc, libc, libm), causing linking errors if not
inlined.

Because some of the GCC built-in functions are not part of the C standard
(e.g. sincos), it's not worthwhile to require having implementations in
libc. In addition, should generic implementations be added to libgcc, those
would likely have sub-par performance or accuracy issues (being generic).

As such, I think that a build system should check if an implementation of a
conditionally-inlined built-in function is provided in the target libc.

I have a few questions:

1. Is inlining of built-ins dependant only on the target architecture and
command-line arguments?
2. If the answer to 1 is yes, could a __is_builtin_inlined (func) macro be
added to GCC? It should tell whether func is going to be substituted inline
for the given compiler invocation
3. Is it true that conditionally-inlined built-ins are exactly those that
come in the two variants of '__builtin_func' and 'func'?

Thanks,
Luca Bacci

             reply	other threads:[~2022-08-10 21:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-10 21:11 Luca Bacci [this message]
2022-08-10 21:27 ` Jonathan Wakely
2022-08-10 22:16   ` Luca Bacci

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='CAJSEPt1Fab81gBq6zA8LkshGYyp-oKZXm=fLUYQPgz_PY56GZw@mail.gmail.com' \
    --to=luca.bacci982@gmail.com \
    --cc=gcc@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).