C++ Logo

sg15

Advanced search

Re: Questions about wording and design intention for header units and ideas

From: Gabriel Dos Reis <gdr_at_[hidden]>
Date: Fri, 19 May 2023 18:43:52 +0000
> Yes. The specification does not make any attempt to define what makes
> a header importable or not.

And for good practical reasons, some of which you list below.

The whole "header unit" concept is really a build-system "acceleration" device; proper use highly depends on the project and build setting.
I will caution against unproven attempt to try to require in-source annotation of any sort.

-- Gaby

-----Original Message-----
From: SG15 <sg15-bounces_at_lists.isocpp.org> On Behalf Of Daniel Ruoso via SG15
Sent: Thursday, May 18, 2023 1:37 PM
To: Tom Honermann <tom_at_honermann.net>
Cc: Daniel Ruoso <daniel_at_ruoso.com>; Iain Sandoe via SG15 <sg15_at_lists.isocpp.org>
Subject: Re: [SG15] Questions about wording and design intention for header units and ideas

Em qui., 18 de mai. de 2023 às 15:19, Tom Honermann
<tom_at_[hidden]> escreveu:
> I agree with your interpretation of the standard. Since the standard is not concerned with build systems, implementation-defined was pretty much the only option for specifying which header files are importable (without introducing additional syntax).

Yes. The specification does not make any attempt to define what makes
a header importable or not.

My understanding is that the intention was to model Explicit Clang
Header modules, where the build system tells the compiler what the
header units are, and early reports of adoption in the MSVC world
seems to suggest my understanding is correct.

There is no specification on the relationship with the preprocessor
state, particularly because there is a desire that the optimization is
not required to create a BMI for every possible state at the time of
the import, since that would result in almost no reuse, but at the
same time it's difficult to specify that behavior without using a lot
of build-system-specific words.

> On 5/17/23 2:16 AM, 许传奇(夜灯) wrote:
> But the consequence is that the C++ ecosystem is going to a more breaking state. For example, MSVC (or MSBuild?)
> introduces header-units.json (https://learn.microsoft.com/en-us/cpp/build/reference/header-unit-json-reference?view=msvc-170).
> And GCC has module map for named modules (I am not sure about gcc's state for header units). Clang has non-standard clang module
> maps and doesn't have a solution for header units. It looks like things are not going right.

I just posted P2898R0 so we can discuss in Varna on this whole
situation. I think Importable Headers as a specification is not
necessary to achieve the original goals of introducing Importable
Headers, and instead we could probably achieve all the goals just
saying the implementation can optimize source inclusions in different
ways than just pasting the entire content, with implementation-defined
caveats regarding the preprocessor state. The important bit being that
the semantics of "souce inclusion" are still the "canonical" behavior,
but the implementation is allowed to introduce optimizations with
implementation-defined caveats where appropriate.

I was writing an email with a new thread to discuss P2989R0 when I saw
this, I'll still start a new thread for that to make sure people are
aware, but I think Importable Headers is not Universally
Implementable.

daniel
_______________________________________________
SG15 mailing list
SG15_at_[hidden]pp.org
https://lists.isocpp.org/mailman/listinfo.cgi/sg15

Received on 2023-05-19 18:43:55