C++ Logo

sg15

Advanced search

Re: [Tooling] [Ext] Modules and tooling: Resolving module import declarations

From: Nathan Sidwell <nathan_at_[hidden]>
Date: Sun, 2 Sep 2018 10:01:31 -0400
On 09/02/2018 12:07 AM, Tom Honermann wrote:

> Gcc
> $ gcc -Ifoo/include t.cpp -lfoo -o t
> $ gcc -fmodules-ts -c Ifoo/include foo.cpp # generates foo.nms (and
> unused foo.o)
[missed '-' on the I option there, but that's obvious]

foo.o is not unused in general, it contains things like the definitions
of exported or module-linkage non-inline functions & variables.
Remember, a module interface can contain implementation:

export module foo;
export int frob (int i) { return i; }
// my current favourite:
export auto widget () { return []{}{}; } // look, not inline!

Richard & I have discussed the possibility of placing things that
currently have to be comdat there. For instance,
*) vtables etc of class definitions lacking a key function
*) out-of-line bodies of inline functions
*) debug data

IIUC clang treats the module BMI as an additional stage of compilation:
   x.cpp->x.pcm->x.o
which must be compiled down to an object for correctness.

nathan

-- 
Nathan Sidwell

Received on 2018-09-02 16:01:35