public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Checking for built-in functions from build systems
@ 2022-08-10 21:11 Luca Bacci
  2022-08-10 21:27 ` Jonathan Wakely
  0 siblings, 1 reply; 3+ messages in thread
From: Luca Bacci @ 2022-08-10 21:11 UTC (permalink / raw)
  To: gcc

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-08-10 22:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-08-10 21:11 Checking for built-in functions from build systems Luca Bacci
2022-08-10 21:27 ` Jonathan Wakely
2022-08-10 22:16   ` Luca Bacci

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).