C++ Logo

sg15

Advanced search

Re: [Modules] Should the compiler try to build std module implicitly?

From: Michael Spencer <bigcheesegs_at_[hidden]>
Date: Mon, 11 Dec 2023 23:53:46 -0800
On Sun, Dec 3, 2023 at 10:00 PM Chuanqi Xu via SG15 <sg15_at_[hidden]>
wrote:

> When I start to learn C++, I only need to copy a hello world example
> and run:
> ```
> clang++ hello.cpp -o hello
> ```
>

My idea for how to handle this and the related case of passing multiple
source files to clang was to embed a mini-build system in the clang driver
that would:
* Scan each input source file for deps
* Knows how to handle the std module
* Builds modules in dependency order
  * pcm files are put in a unique tmp directory, no sharing with other
clang driver instances.
* Delete all the temp files at the end after linking

This is actually pretty simple to do in the Clang driver. There's no
invalidation checking, compatibility issues, mixing of command line
options, or anything else that makes modules complicated. I am extremely
against having clang itself be responsible for managing a BMI cache. This
is how implicitly built modules work and it's been terrible, and really
can't be done both safely and fast. The Clang module build daemon work gets
around this by having a single cache per Clang version and having a single
process manage that cache.

This is specifically intended to support the cases of having just a few
files, so even if you have to reparse everything it's not going to take
that long to build anyway. I agree that things would be much better if we
had a default build tool that works for common cases, and support work on
such a thing, but I also think that the above should be supported too for
practical reasons.

- Michael Spencer

Received on 2023-12-12 07:54:03