[cfe-dev] Modules TS: various problems

Boris Kolpackov via cfe-dev cfe-dev at lists.llvm.org
Mon Jun 19 06:45:00 PDT 2017


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

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



More information about the cfe-dev mailing list