[PATCH] D119409: [C++20] [Modules] Remain dynamic initializing internal-linkage variables in module interface unit

Iain Sandoe via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 28 02:16:18 PDT 2022


iains added a comment.

In D119409#3410474 <https://reviews.llvm.org/D119409#3410474>, @ChuanqiXu wrote:

> In D119409#3409806 <https://reviews.llvm.org/D119409#3409806>, @iains wrote:
>
>> I think that this problem might well be a consequence of the bug which is fixed by D122413 <https://reviews.llvm.org/D122413>.
>>
>> We have been generating code with module internal entities (always) given the special ModuleInternalLinkage (which means that, although the linkage is formally 'internal', the entities are made global when emitted.  We should only be doing this for fmodules-ts, not for regular standard modules.
>>
>> If you apply D122413 <https://reviews.llvm.org/D122413> (which I hope to land soon), then I would expect that iostream should work as expected (with one internal instance of std::__ioinit in each TU that includes iostream).
>>
>> IFF (after applying D122413 <https://reviews.llvm.org/D122413> ) you add to the command line -fmodules-ts, then the patch here (D119409 <https://reviews.llvm.org/D119409>) would, presumably, be needed to work around multiple instances of the globalised std::__ioinit.
>
> Sadly it wouldn't work after D122413 <https://reviews.llvm.org/D122413> applied. Since the <iostream> is lived in GlobalModuleFragment, the calculated linkage wouldn't affect them. So I met the same segfault as before.

Is this because we are not creating an initialiser for a static entity in the GMF ?

- I did a quick test and that seemed to be the case.

(module initialisers need quite some work, it seems)

>> addendum: note we still have work to do on the module initialisers - those are not correct yet (so probably some nesting of modules might not work).
>
> What does the nesting of modules mean?

If we have an import of a module that imports another - then we should be running the module initializers for the imported stack (in the correct order) .. at present, we do not do this.
As noted above, we have some work to do here.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119409/new/

https://reviews.llvm.org/D119409



More information about the cfe-commits mailing list