[cfe-dev] Modules TS: various problems

David Blaikie via cfe-dev cfe-dev at lists.llvm.org
Mon Jun 19 13:28:46 PDT 2017


On Mon, Jun 19, 2017 at 6:45 AM Boris Kolpackov via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> I am trying to use the Modules TS implementation in Clang 5.0.0-svn305177.
> My module interface file:
>
> #include <string>
>
> export module hello;
>
> export namespace hello
> {
>   void say (const std::string& name);
> }
>
> Module implementation file:
>
> #include <string>
> #include <iostream>
>
> module hello;
>
> using namespace std;
>
> namespace hello
> {
>   void
>   say (const string& n)
>   {
>     cout << "Hello, " << n << '!' << endl;
>   }
> }
>
> The problems:
>
> 1. It seems the .pcm file compiled from the interface file references
>    said interface file. If I remove it after generating .pcm, then I get
>    an error like this when compiling the implementation file:
>
>    clang++-5.0 -std=c++1z -D__cpp_modules=201704 -fmodules-ts
> -fmodule-file=hello.a.pcm -o hello.a.o -c -x c++ hello.a.o.ii
>    fatal error: malformed or corrupted AST file: 'could not find file
> '/home/boris/work/build2/hello/m/libmhello/libhello/hello.a.pcm.ii'
> referenced by AST file 'hello.a.pcm''
>
>    The .pcm is produced with this command line:
>
>    clang++-5.0 -std=c++1z -D__cpp_modules=201704 -fmodules-ts -o
> hello.a.pcm --precompile -Xclang -fmodules-codegen -Xclang
> -fmodules-debuginfo -x c++-module hello.a.pcm.ii
>

This should be able to be addressed by using -Xclang
-fmodules-embed-all-files (see https://reviews.llvm.org/rL253950 for some
more info).

Perhaps Richard'll have ideas on the rest.


> 2. If I keep the source file, then I get errors along these lines (again,
>    when compiling the implementation file):
>
>    In file included from hello.cxx:3:
>    In file included from
> /usr/bin/../lib/gcc/x86_64-linux-gnu/6.2.0/../../../../include/c++/6.2.0/string:39:
>
>  /usr/bin/../lib/gcc/x86_64-linux-gnu/6.2.0/../../../../include/c++/6.2.0/bits/stringfwd.h:69:48:
> error: template parameter redefines default argument
>      template<typename _CharT, typename _Traits = char_traits<_CharT>,
>
>  /usr/bin/../lib/gcc/x86_64-linux-gnu/6.2.0/../../../../include/c++/6.2.0/bits/stringfwd.h:69:48:
> note: previous default template argument defined here
>      template<typename _CharT, typename _Traits = char_traits<_CharT>,
>
>    The same code compiles fine with VC 15u3.
>
>    If I get rid of the <string> inclusion from the interface file (and
>    use const char* to pass the name), everything compiles fine.
>
> Thanks,
> Boris
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20170619/f232fba4/attachment.html>


More information about the cfe-dev mailing list