public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug build/27527] New: mutually inclusive headers bad for c++20 header-units
@ 2021-03-05 20:13 nathan at acm dot org
  2021-03-08 13:03 ` [Bug build/27527] " nathan at acm dot org
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: nathan at acm dot org @ 2021-03-05 20:13 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27527

            Bug ID: 27527
           Summary: mutually inclusive headers bad for c++20 header-units
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: build
          Assignee: unassigned at sourceware dot org
          Reporter: nathan at acm dot org
                CC: carlos at redhat dot com
  Target Milestone: ---

We're trying to build the C++ library's headers as c++20 header-units, and this
is wandering into glibc headers.  Mutually inclusive headers are bad for this
(yes, even with header guards).

glibc has a loop between features.h:
/* This is here only because every header file already includes this one.  */
#ifndef __ASSEMBLER__
# ifndef _SYS_CDEFS_H
#  include <sys/cdefs.h>
# endif
...
#endif

and sys/cdefs.h:
/* We are almost always included from features.h. */
#ifndef _FEATURES_H
# include <features.h>
#endif

The explicit guard of _SYS_CDEFS_H seems unneccessary -- the guard inside
sys/cdefs.h will work fine. But the loop's the problem.

Specifically neither of these files can be built as header-units, they must be
textually included everywhere.  That will work, but is suboptimal, as the
compiler will have to do checking on duplicates (of macros in this case), for
every header-unit that textually includes these.  Is there a way to avoid this
loop?

FYI Jonathan fixed a similar libstdc++-v3 loop with <new> & <exception> last
year:
commit 6bdbf0f37bda2587a4e82cbb956de7a159a397ae
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Wed Sep 2 13:27:57 2020 +0100

    libstdc++: Break header cycle between <new> and <exception>

    The <new> and <exception> headers each include each other, which makes
    building them as header-units "exciting". The <new> header only needs
    the definition of std::exception (in order to derive from it) which is
    already in its own header, so just include that.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug build/27527] mutually inclusive headers bad for c++20 header-units
  2021-03-05 20:13 [Bug build/27527] New: mutually inclusive headers bad for c++20 header-units nathan at acm dot org
@ 2021-03-08 13:03 ` nathan at acm dot org
  2021-03-09 17:52 ` jwakely.gcc at gmail dot com
  2021-03-09 18:05 ` [Bug libc/27527] " fweimer at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: nathan at acm dot org @ 2021-03-08 13:03 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27527

--- Comment #1 from Nathan Sidwell <nathan at acm dot org> ---
oh, the explicit ifndef _SYS_CDEFS_H protection also breaks (some) #include
graph analyzers, as it doesn't create a line marker for sys/cdefs.h.  See
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=98968

And in case you're wondering all[*] compilers implement header guard
optimization where they won't actually go and refind and reread a guarded
include on 2nd inclusion, so you don't need to micro-optimize for that.


[*] well, I can't say unambiguously all, but like, come on :)

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug build/27527] mutually inclusive headers bad for c++20 header-units
  2021-03-05 20:13 [Bug build/27527] New: mutually inclusive headers bad for c++20 header-units nathan at acm dot org
  2021-03-08 13:03 ` [Bug build/27527] " nathan at acm dot org
@ 2021-03-09 17:52 ` jwakely.gcc at gmail dot com
  2021-03-09 18:05 ` [Bug libc/27527] " fweimer at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: jwakely.gcc at gmail dot com @ 2021-03-09 17:52 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27527

Jonathan Wakely <jwakely.gcc at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jwakely.gcc at gmail dot com

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

* [Bug libc/27527] mutually inclusive headers bad for c++20 header-units
  2021-03-05 20:13 [Bug build/27527] New: mutually inclusive headers bad for c++20 header-units nathan at acm dot org
  2021-03-08 13:03 ` [Bug build/27527] " nathan at acm dot org
  2021-03-09 17:52 ` jwakely.gcc at gmail dot com
@ 2021-03-09 18:05 ` fweimer at redhat dot com
  2 siblings, 0 replies; 4+ messages in thread
From: fweimer at redhat dot com @ 2021-03-09 18:05 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=27527

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |drepper.fsp at gmail dot com,
                   |                            |fweimer at redhat dot com
          Component|build                       |libc
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.

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

end of thread, other threads:[~2021-03-09 18:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-05 20:13 [Bug build/27527] New: mutually inclusive headers bad for c++20 header-units nathan at acm dot org
2021-03-08 13:03 ` [Bug build/27527] " nathan at acm dot org
2021-03-09 17:52 ` jwakely.gcc at gmail dot com
2021-03-09 18:05 ` [Bug libc/27527] " fweimer at redhat dot com

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