public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [libstdc++] Inconsistent detection of __int128
@ 2021-01-04  0:43 David Edelsohn
  2021-01-04  2:45 ` Jonathan Wakely
  0 siblings, 1 reply; 8+ messages in thread
From: David Edelsohn @ 2021-01-04  0:43 UTC (permalink / raw)
  To: Jonathan Wakely; +Cc: libstdc++, Iain Sandoe, CHIGOT, CLEMENT

TL;DR: Change libstdc++ to uniformly use __SIZEOF_INT128__ to detect
__int128 and remove the definition detected by configure.

Some libstdc++ headers check for __int128 by directly testing
__SIZEOF_INT128__ and other headers test for _GLIBCXX_USE_INT128.
__GLIBCXX_USE_INT128 is probed during libstdc++ configuration phase.

* std/charconv:#if _GLIBCXX_USE_INT128
std/limits:#elif defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
std/ranges:#ifdef __SIZEOF_INT128__
std/ranges: else if constexpr (__SIZEOF_INT128__ > sizeof(_Wp))
bits/c++config:#ifdef __SIZEOF_INT128__
bits/iterator_concepts.h:#if defined __STRICT_ANSI__ && defined
__SIZEOF_INT128__
bits/iterator_concepts.h:#if __SIZEOF_INT128__
bits/iterator_concepts.h:#if __SIZEOF_INT128__
bits/max_size_type.h:#if __SIZEOF_INT128__
bits/max_size_type.h:#if __SIZEOF_INT128__
* bits/random.h:#ifdef _GLIBCXX_USE_INT128
bits/ranges_base.h:#if defined __STRICT_ANSI__ && defined __SIZEOF_INT128__
bits/uniform_int_dist.h:#if __SIZEOF_INT128__

libstdc++ headers also depend on __float128 and use
_GLIBCXX_USE_FLOAT128, but the value is defined dynamically in
c++config.h:

/* Define if __float128 is supported on this host. */
#if defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__)
#define _GLIBCXX_USE_FLOAT128 1
#endif

The GLIBXX_USE_INT128 situation is a problem for AIX, Darwin and other
platforms that are trying to convert to FAT libraries, where both 32
bit and 64 bit libraries are in the same location.  When GCC looks for
libraries in the same location, it also wants to look for header files
in the same location.  Almost all libstdc++ header files are
architecture or bitsize agonostic, with the differences localized in
c++config.h.  The configure-time definition of _GLIBCXX_USE_INT128
generates a gratuitous difference in the contents of c++config.h that
otherwise could use the same file.

As a first step to make __int128 usage consistent within libstdc++
headers, I propose that libstdc++ configure not define
_GLIBCXX_USE_INT128 and bits/c++config instead dynamically test for
__SIZEOF_INT128__

/* Define if __int128 is supported on this host. */
#ifdef __SIZEOF_INT128__
#define _GLIBCXX_USE_INT128 1
#endif

Alternatively, uses of _GLIBCXX_USE_INT128 could be changed to
__SIZEOF_INT128__ and remove all references to _GLIBCXX_USE_INT128.
In which direction would the community like to transition?

Or is there some other reason that _GLIBCXX_USE_INT128 and
__SIZEOF_INT128__ are used in different contexts?

Thanks, David

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

end of thread, other threads:[~2021-05-04 13:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-04  0:43 [libstdc++] Inconsistent detection of __int128 David Edelsohn
2021-01-04  2:45 ` Jonathan Wakely
2021-01-04  3:26   ` David Edelsohn
2021-01-08 16:09     ` Jonathan Wakely
2021-01-08 20:00       ` David Edelsohn
2021-04-30 20:24       ` David Edelsohn
2021-05-04 11:12         ` Jonathan Wakely
2021-05-04 13:53           ` David Edelsohn

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