[cfe-dev] [Modules TS] feedback
David Blaikie via cfe-dev
cfe-dev at lists.llvm.org
Thu May 11 11:35:02 PDT 2017
On Thu, May 11, 2017 at 6:22 AM Boris Kolpackov <boris at codesynthesis.com>
wrote:
> Hi David,
>
> David Blaikie <dblaikie at gmail.com> writes:
>
> > Passing -fmodules-codegen and -fmodules-debuginfo (I think I'm
> remembering
> > the spelling right) to the step that creates the pcm file will establish
> > the right conditions, then passing that pcm file to clang again -c,
> should
> > generate the required object file.
>
> While I believe the spelling is correct, it still does not work:
>
> clang++-5.0 -std=c++1z -fmodules-ts -fmodules-codegen -fmodules-debuginfo \
> -I.. --precompile -x c++-module -o hello.pcm hello.mxx
>
> clang: error: unknown argument: '-fmodules-codegen'
> clang: error: unknown argument: '-fmodules-debuginfo'
>
Right, sorry - these flags aren't exposed through the driver yet, so for
now you can pass them like:
-Xclang -fmodules-codegen
-Xclang -fmodules-debuginfo
>
> Also note that this is not an unresolved symbol but a duplicate:
>
It should work naturally either way, I think.
Here we go:
foo.cppm:
export module foo;
export {
int f() { return 0; }
}
use1.cpp:
import foo;
void use1() { f(); }
use2.cpp:
import foo;
void use1();
int main() { f(); use1(); }
$ clang++-tot -std=c++1z -fmodules-ts foo.cppm --precompile -o foo.pcm
-Xclang -fmodules-codegen
$ clang++-tot -std=c++1z -fmodules-ts foo.pcm -c
$ clang++-tot -std=c++1z -fmodules-ts -fmodule-file=foo.pcm use1.cpp
use2.cpp -c
$ nm {foo,use1,use2}.o
foo.o:
0000000000000000 T _Z1fv
use1.o:
0000000000000000 T main
U _Z1fv
U _Z4use2v
use2.o:
U _Z1fv
0000000000000000 T _Z4use2v
$ clang++-tot {foo,use1,use2}.o
$ ./a.out
$ clang++-tot -std=c++1z -fmodules-ts foo.cppm --precompile -o foo.pcm
$ clang++-tot -std=c++1z -fmodules-ts -fmodule-file=foo.pcm use1.cpp
use2.cpp -c
$ nm {use1,use2}.o
use1.o:
0000000000000010 T main
0000000000000000 T _Z1fv
U _Z4use2v
use2.o:
0000000000000000 T _Z1fv
0000000000000010 T _Z4use2v
$ clang++-tot use1.o use2.o
use2.o: In function `f()':
use2.cpp:(.text+0x0): multiple definition of `f()'
use1.o:use1.cpp:(.text+0x0): first defined here
I suppose -fmodules-codegen will be the default for -fmodules-ts sooner or
later. (-fmodules-debuginfo is useful too, but you won't see the
correctness issue, just debug info size changes)
It may be that two degrees of -fmodules-codegen would be useful - one that
only homes the non-inline functions (external functions become external in
the module's object, available_externally in module users objects), and the
one we have here that homes all functions (even inline ones, so
linkonce_odr functions become weak in the module's object and
available_externally in module users objects).
> clang++-5.0 -std=c++1z -fmodules-ts -I.. --precompile -x c++-module -o
> hello.pcm hello.mxx
> clang++-5.0 -std=c++1z -fmodules-ts -I.. -fmodule-file=hello.pcm -c
> hello.cxx
> clang++-5.0 -std=c++1z -fmodules-ts -I.. -fprebuilt-module-path=. -c
> driver.cxx
> clang++-5.0 -std=c++1z -fmodules-ts -I.. -o driver driver.o hello.o
> hello.o: In function `hello::non_inline()':
> hello.cxx:(.text+0x0): multiple definition of `hello::non_inline()'
> driver.o:driver.cxx:(.text+0x0): first defined here
>
> Thanks,
> Boris
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170511/ac3f195c/attachment.html>
More information about the cfe-dev
mailing list