Skip to content

Commit d08a723

Browse files
committed
feat: 声明自己的 std 模块源
构建工具否则会向编译器问 std.cppm 在哪,而这一份是这个包为一个编译器毫不知情的 目标配置出来的:它的 __config_site 在 llvm-generated/,它的片段在 llvm/libcxx/modules/std/。 三个 flag 都是实测逼出来的,不是预防性的: --no-default-config 载荷的 clang++.cfg 无条件加一个宿主 C 库的头, 模块于是编那个库的 <wchar.h> 并停在它指望宿主编译器 提供的名字上 -nostdinc/-nostdinc++ 同上 -D_GNU_SOURCE libc++ 的 locale 层去够 musl 只在这个宏下声明的名字 (vasprintf、strtof_l 等),LLVM 自己的 runtimes 构建 出于同样理由定义它 -I llvm/libcxx/modules 模块源按相对名 include 九十来个片段,它们是上游的、 未改动,所以留在上游放的地方,由搜索路径点名那个目录 配套:mcpp-community/mcpp#486
1 parent 2be6ae2 commit d08a723

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

mcpp.toml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,38 @@ repo = "https://github.com/mcpplibs/openkal-llvm-runtime"
1717
# declared here and read there.
1818
provides = ["hosted-standard-library"]
1919

20+
# Where this package's `std' module source is, and what it needs.
21+
#
22+
# The build tool otherwise asks the compiler (`-print-library-module-manifest-path'),
23+
# which is the right question when the standard library is the compiler's own
24+
# and the wrong one here: this source was configured for a target the compiler
25+
# knows nothing about, and its configuration is in llvm-generated/ rather than
26+
# beside the compiler.
27+
std-module = "llvm-generated/std.cppm"
28+
std-module-flags = [
29+
# ⚠️ --no-default-config, and it is not tidiness.
30+
#
31+
# The toolchain payload ships a clang++.cfg that names a host C library's
32+
# headers unconditionally. For an ordinary translation unit that is right and
33+
# invisible; for this one it puts a C library that is not the one beneath this
34+
# package first, and the module fails compiling <wchar.h> with names that
35+
# library expects the host compiler to have supplied. Measured.
36+
"--no-default-config",
37+
"-nostdinc",
38+
"-nostdinc++",
39+
# libc++'s locale layer reaches for names musl declares only under this macro
40+
# (vasprintf, strtof_l and their relatives). LLVM's own runtimes build defines
41+
# it for the same reason. It is stated here rather than left to the target
42+
# block, because that block describes how this package's own sources are
43+
# compiled and the module is compiled separately.
44+
"-D_GNU_SOURCE",
45+
# The module source is one file that includes ninety-odd fragments by
46+
# relative name. They are upstream's and unmodified, so they stay where
47+
# upstream put them and the search path names that directory rather than the
48+
# fragments being copied next to the configured source.
49+
"-I", "llvm/libcxx/modules",
50+
]
51+
2052
# The C library beneath. A C++ standard library is not portable in the sense a
2153
# program is: it is configured for one C library and compiled against that
2254
# library's headers, and the configuration is what this package supplies. The

0 commit comments

Comments
 (0)