C++ Logo

sg15

Advanced search

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

From: Boris Kolpackov <boris_at_[hidden]>
Date: Tue, 12 Dec 2023 17:56:33 +0200
Olga Arkhipova <olgaark_at_[hidden]> writes:

> The tool invokes the compiler to scan the sources, constructs the
> dependency graph and builds all given c++ sources and header units.

I am convinced such a tool will sooner rather than later contain
a substantial chunk of a real-world build system.

Take the `import std;` support as an example. I have it implemented
in build2 for MSVC and Clang/libc++. Here are the extras I needed to
do that:

1. Detect the compiler id and version (to check the requested
   functionality is available).

2. Detect the standard library being used (to detect libc++).

3. Detect the header search paths used by the compiler (to find the std
   module for MSVC).

4. Detect the standard library variant being linked (-static-libstdc++,
   /MT[d] or /MD[d]) in order to build the corresponding BMI.

5. Unless the plan is to rebuilt the std module on every invocation (and
   endure several second compilation times for hello-world programs),
   extract headers (/M*, /showIncludes) and track changes since the
   std modules for both implementations include headers.

Received on 2023-12-12 15:56:27