在 linux 上使用标准 headers 的 C++ 模块 TS

Using C++ Modules TS with standard headers on linux

我正在使用模块 ts:

测试一个简单的 C++ 模块
export module strings;
#include <string>

当我尝试在 linux 上使用 clang (trunk) 和 GCC 7.2 headers 编译它时,我得到了这个:

clang++ -std=c++2a -fmodules-ts -fprebuilt-module-path=. --precompile -x c++-module -o strings.pcm ../../src/base/strings.cc
In file included from ../../src/base/strings.cc:2:
In file included from /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/string:52:
In file included from /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/bits/basic_string.h:39:
In file included from /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/c++/7.2.0/ext/atomicity.h:35:
In file included from /usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0/bits/gthr.h:148:
/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0/bits/gthr-default.h:101:1: error: weakref declaration must have internal linkage
__gthrw(pthread_once)
^
/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0/bits/gthr-default.h:99:23: note: expanded from macro '__gthrw'
#define __gthrw(name) __gthrw2(__gthrw_ ## name,name,name)
                      ^
/usr/lib/gcc/x86_64-linux-gnu/7.2.0/../../../../include/x86_64-linux-gnu/c++/7.2.0/bits/gthr-default.h:90:46: note: expanded from macro '__gthrw2'
  static __typeof(type) name __attribute__ ((__weakref__(#name2))); \
                                             ^

我尝试 pre-include <bits/gthr-default.h>(在 export module 之前),但随后我收到关于 time.hsched.h 的错误...

有谁知道编译它的方法吗?

(有关完整的错误消息,请参见此处:https://godbolt.org/g/wfjmpW

郑重声明,我找到了(稍微)更好的 solution:

export module strings;
#if defined(__GXX_WEAK__)
#include <bits/gthr-default.h>
#endif

#include <string>

即使我需要 #include <ctime> 模块内部也能正常工作。