From: Iain Sandoe <idsandoe@googlemail.com>
To: Ben Boeckel <ben.boeckel@kitware.com>
Cc: Boris Kolpackov <boris@codesynthesis.com>, gcc@gcc.gnu.org
Subject: Re: [modules] Preprocessing requires compiled header unit modules
Date: Thu, 21 Apr 2022 19:18:29 +0100 [thread overview]
Message-ID: <5DD78076-C7C2-4941-9E04-A97DAC305C63@googlemail.com> (raw)
In-Reply-To: <YmGdr7pwmiRrvuxi@megas.dev.benboeckel.internal>
> On 21 Apr 2022, at 19:08, Ben Boeckel <ben.boeckel@kitware.com> wrote:
>
> On Thu, Apr 21, 2022 at 18:59:56 +0100, Iain Sandoe wrote:
>> Hi Ben,
>>
>>> On 21 Apr 2022, at 13:05, Ben Boeckel via Gcc <gcc@gcc.gnu.org> wrote:
>>>
>>> On Thu, Apr 21, 2022 at 06:05:52 +0200, Boris Kolpackov wrote:
>>>> I don't think it is. A header unit (unlike a named module) may export
>>>> macros which could affect further dependencies. Consider:
>>>>
>>>> import "header-unit.hpp"; // May or may not export macro FOO.
>>
>> 1. If you know how this was built, then you could do an -E -fdirectives-only build (both
>> GCC and clang support this now) to obtain the macros.
>
> My understanding is that how it gets used determines how it should be
> made for Clang (because the consumer's `-D`, `-W`, etc. flags matter). I
> do not yet know how I am to support this in CMake.
I think that is what I mean by “if you know how it is built” - it means you can replicate those
conditions, but produce the fdirectives-only output. Perhaps I’m missing a subtelty …
>> 2. I suppose we could invent a tool (or FE mode) to dump the macros exported by a HU ***
>
> Fun considerations:
>
> - are `-D` flags exported? `-U`?
> - how about this if `value` is the same as or different from the
> at-start expansion:
>
> ```c++
> #undef SOME_MACRO
> #define SOME_MACRO value
> ```
>
> - how about `#undef FOO`?
AFAIU, that is defined by the standard - only the defined state of a macro is exported.
So if the file contains
#define FOO 1
….
….
#undef FOO
— there will be no mention of FOO in the exported macros (at least, that is what
my impl. does ;) ).
— and the output would contain 'SOME_MACRO value’ for your other case.
This is quite different from the behaviour of PCH where the macro history is preserved.
>>>> #ifdef FOO
>>>> import "header-unit2.hpp"
>>>> #endif
>>>
>>> I agree that the header needs to be *found*, but scanning cannot require
>>> a pre-existing BMI for that header. A new mode likely needs to be laid
>>> down to get the information necessary (instead of just piggy-backing on
>>> `-E` behavior to get what I want).
>>
>> perhaps that means (2)?
>
> Can't it just read the header as if it wasn't imported? AFAIU, that's
> what GCC did in Jan 2019. I understand that CPP state is probably not
> easy, but something to consider.
The BMIs (at least the two I’ve got some familiarity with) are quite complex - there
would have to be some mode that specifically extracted the macros only.
>> *** it’s kinda frustrating that this is hard infomation to get as a developer, so
>> perhaps we can anticipate users wanting such output.
>
> I think cacheing and distributed build tools are the most likely
> consumers of such information.
On an “industrial scale”, sure - but the ability for a user to check that what they think
is present _is_ present, is valuable - at least in debug.
Iain
next prev parent reply other threads:[~2022-04-21 18:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-24 23:46 Ben Boeckel
2022-04-21 4:05 ` Boris Kolpackov
2022-04-21 12:05 ` Ben Boeckel
2022-04-21 17:59 ` Iain Sandoe
2022-04-21 18:08 ` Ben Boeckel
2022-04-21 18:18 ` Iain Sandoe [this message]
2022-04-22 14:08 ` Boris Kolpackov
2022-04-22 15:06 ` Iain Sandoe
2022-04-25 9:20 ` Boris Kolpackov
2022-04-22 16:05 ` Ben Boeckel
2022-04-25 9:42 ` Boris Kolpackov
2022-04-25 11:34 ` Ben Boeckel
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=5DD78076-C7C2-4941-9E04-A97DAC305C63@googlemail.com \
--to=idsandoe@googlemail.com \
--cc=ben.boeckel@kitware.com \
--cc=boris@codesynthesis.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).