Open ynty opened 1 year ago
The problem here probably is that the platform is not modularized yet:
https://clang.llvm.org/docs/Modules.html#modularizing-a-platform
Your test case also fails to compile on Debian Testing with clang 16.0.1 and the gcc 12.2.0 C++ Standard Library:
$ clang++ modules.cpp -o modules -std=c++20 -fmodules
modules.cpp:1:8: error: header file <iostream> (aka
'/usr/lib/gcc/x86_64-linux-gnu/12/../../../../include/c++/12/iostream') cannot be imported because it is not known
to be a header unit
import <iostream>;
^
modules.cpp:2:7: error: use of undeclared identifier 'std'
using std::cout, std::endl;
^
modules.cpp:2:18: error: use of undeclared identifier 'std'
using std::cout, std::endl;
^
modules.cpp:4:9: error: use of undeclared identifier 'cout'
cout << "Hello C++ 20." << endl;
^
modules.cpp:4:36: error: use of undeclared identifier 'endl'
cout << "Hello C++ 20." << endl;
^
5 errors generated
However, it works when using libc++:
$ clang++ -stdlib=libc++ modules.cpp -o modules -std=c++20 -fmodules
$ ./modules
Hello C++ 20
Description / Steps to reproduce the issue
clang++
with:pacman -S mingw-w64-clang-x86_64-toolchain
.clang++ hello.cpp -o hello -std=c++20 -fmodules
, just like how compile it on Mac with clang 16 (installed from homebrew).通过
pacman -S mingw-w64-clang-x86_64-toolchain
安装clang++
以下是一个 C++ 20 模块功能的简单示例:
使用
clang++ hello.cpp -o hello -std=c++20 -fmodules
编译。(在 Mac 上使用 clang 16 可以编译成功)Expected behavior
Actual behavior
clang++
failed to compilehello.cpp
, with the message "fatal error: could not build module 'std'
".<msys64>
is where I installed MSYS2.编译失败,提示“致命错误:无法构建模组‘std’”,详细信息如上。其中
<msys64>
为 MSYS2 的安装路径。(D:/msys64)Verification
Windows Version
MINGW64_NT-10.0-22621
MINGW environments affected
As I'm using a x86_64 PC, I don't know whether this issue will affect CLANG32.
Are you willing to submit a PR?
No.