public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ben Boeckel <ben.boeckel@kitware.com>
To: gcc@gcc.gnu.org
Subject: [modules] Preprocessing requires compiled header unit modules
Date: Thu, 24 Feb 2022 18:46:30 -0500	[thread overview]
Message-ID: <YhgY1lJpBIM1vnhx@megas.dev.benboeckel.internal> (raw)

Hi,

I'm looking to update my patch which implements P1689[1] for GCC. I
originally wrote this back in February 2019 at Kona for a proof of
concept[2], but never really got the time to delve back in until now.
I'd like to get header units implemented prior to submitting it as it
will be an important part in the long run (as I don't think having a
partial implementation in the wild would be beneficial).

Now that modules have been merged, my patch works just fine for named
modules. However, for header unit modules, it runs into a problem that
imported header units are required to be compiled and available in the
mapper while scanning for dependencies.

Example code:

```c++ # use-header.cpp
module;

import "header-unit.hpp";

int main(int argc, char* argv[]) {
    return good;
}
```

```c++ # header-unit.hpp
constexpr int good = 0;
```

When trying to preprocess this:

```console
% g++ -std=c++20 -fmodules-ts -E use-header.cpp -o use-header.cpp.i
In module imported at use-header.cpp:3:1:
./header-unit.hpp: error: failed to read compiled module: No such file or directory
./header-unit.hpp: note: compiled module file is ‘gcm.cache/,/header-unit.hpp.gcm’
./header-unit.hpp: note: imports must be built before being imported
./header-unit.hpp: fatal error: returning to the gate for a mechanical issue
compilation terminated
```

There used to be no need to do this back prior to the modules landing in
`master`, but I can see this being an oversight in the meantime. I am
not familiar enough with the code to know how to untangle its current
state (attempting to bisect the change throws me back in to the depths
of the history without modules so "does it work" is unanswerable there).

I tried this on commits:

    4efde6781bba8d64b9dcff07e7efe71d35aa6f6a c++: Modules Is Landing
    f4ed267fa5b82d6dafbc8afc82baf45bfcae549c master as of the 23rd

Thanks,

--Ben

[1] https://wg21.link/p1689r4
[2] https://github.com/mathstuf/cxx-modules-sandbox/ (see the `docker`
branch for the instructions on putting things together)

             reply	other threads:[~2022-02-24 23:46 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-24 23:46 Ben Boeckel [this message]
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
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=YhgY1lJpBIM1vnhx@megas.dev.benboeckel.internal \
    --to=ben.boeckel@kitware.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).