Skip to content

Commit dae86ef

Browse files
feat: 裸机分配器与零 libc 层 —— 三个新包,两个新版本 (#226)
## 新增 * `std-freestanding-alloc-kal` 0.1.0 —— 十二个 operator new/delete 转发 openkal * `std-freestanding-alloc-libc` 0.1.0 —— 同上,转发目标 C 库 * `std-freestanding-nolibc` 0.1.0 —— memcpy/memmove/memset/memcmp/strlen ⚠️ 两个 alloc 包**同图只能有一个**。两者都 provide `freestanding-allocator`, 而 `operator new` 是全程序单例:解析器会点名两个 provider 并拒绝,这正是把选择做成 capability 而不是「链接器先看见谁算谁」的理由。 ⚠️ `std-freestanding-nolibc` **仅用于零 libc 档**。mcpp 把依赖包的目标文件无条件 放进消费方的链接行,没有「符号仍缺失才拉入」的归档语义,所以板级包链了 `-lc` 的 工程会得到两份 `memcpy`。其消费者应设 `[target.<triple>].sysroot = ""`。 ## 新版本 * `std-freestanding` 0.3.0 —— `alloc` / `alloc-kal` / `alloc-libc` feature。 feature 作开关、capability 作仲裁、实现在别的包;普通消费者只写一个 feature, 连 provider 包名都不必知道。 * `riscv-virt-rt` 0.4.0 —— 解除对编译器与 C 库的隐式耦合(改向引擎提问), 新增 openkal 裸机后端(置于 feature 之后)与零 libc 内核模板。 旧版本全部保留:已发布过的版本就是可能有人 pin 过的版本。 ## 校验 五个 tarball 的 GitHub 与 GitCode 镜像**逐字节一致**(sha256 相同)。 `check_mirror_urls` / `check_package_name` / `check_platform_version_parity` / `check_cross_package_refs` 本地全过。`min_mcpp` 未动。 Co-authored-by: speak-agent <248744407+speak-agent@users.noreply.github.com>
1 parent eb4ec48 commit dae86ef

5 files changed

Lines changed: 200 additions & 0 deletions

File tree

pkgs/r/riscv-virt-rt.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,13 @@ package = {
5252
},
5353
sha256 = "71fc43daa4903d4f3037c204bd2b3be9aea56371b123a4529cc8c0c8c9b7f525",
5454
},
55+
["0.4.0"] = {
56+
url = {
57+
GLOBAL = "https://github.com/mcpplibs/riscv-virt-rt/archive/refs/tags/0.4.0.tar.gz",
58+
CN = "https://gitcode.com/mcpp-res/riscv-virt-rt/releases/download/0.4.0/riscv-virt-rt-0.4.0.tar.gz",
59+
},
60+
sha256 = "2eef43aefb00905236a72d49924129c379e9d085fafdc4dd5c868e8a52b0414e",
61+
},
5562
},
5663
macosx = {
5764
deps = { "xim:qemu-riscv@9.2.4-1" },
@@ -76,6 +83,13 @@ package = {
7683
},
7784
sha256 = "71fc43daa4903d4f3037c204bd2b3be9aea56371b123a4529cc8c0c8c9b7f525",
7885
},
86+
["0.4.0"] = {
87+
url = {
88+
GLOBAL = "https://github.com/mcpplibs/riscv-virt-rt/archive/refs/tags/0.4.0.tar.gz",
89+
CN = "https://gitcode.com/mcpp-res/riscv-virt-rt/releases/download/0.4.0/riscv-virt-rt-0.4.0.tar.gz",
90+
},
91+
sha256 = "2eef43aefb00905236a72d49924129c379e9d085fafdc4dd5c868e8a52b0414e",
92+
},
7993
},
8094
windows = {
8195
deps = { "xim:qemu-riscv@9.2.4-1" },
@@ -100,6 +114,13 @@ package = {
100114
},
101115
sha256 = "71fc43daa4903d4f3037c204bd2b3be9aea56371b123a4529cc8c0c8c9b7f525",
102116
},
117+
["0.4.0"] = {
118+
url = {
119+
GLOBAL = "https://github.com/mcpplibs/riscv-virt-rt/archive/refs/tags/0.4.0.tar.gz",
120+
CN = "https://gitcode.com/mcpp-res/riscv-virt-rt/releases/download/0.4.0/riscv-virt-rt-0.4.0.tar.gz",
121+
},
122+
sha256 = "2eef43aefb00905236a72d49924129c379e9d085fafdc4dd5c868e8a52b0414e",
123+
},
103124
},
104125
},
105126

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
-- std-freestanding-alloc-kal — one of the allocator implementations the
2+
-- freestanding subset can bind.
3+
--
4+
-- Form A because mcpp looks for a package manifest at the package ROOT, and
5+
-- Form B would leave it one level down inside the tarball's wrap directory.
6+
--
7+
-- ⚠️ NO `deps`. The package depends on `openkal` for the C declarations it is
8+
-- written against, and that is an mcpp dependency declared in its own
9+
-- manifest — not an xim payload. Nothing here needs installing.
10+
--
11+
-- The consumer does not name this package. `std-freestanding`'s `alloc-kal`
12+
-- feature pulls it, because the feature both states the requirement and brings
13+
-- an implementation; see that package's `[feature-deps]`.
14+
package = {
15+
spec = "1",
16+
namespace = "mcpplibs",
17+
name = "std-freestanding-alloc-kal",
18+
description = "The replaceable allocation functions for the freestanding subset, forwarded to openkal",
19+
licenses = {"Apache-2.0"},
20+
repo = "https://github.com/mcpplibs/std-freestanding-alloc-kal",
21+
type = "package",
22+
23+
xpm = {
24+
linux = {
25+
["0.1.0"] = {
26+
url = {
27+
GLOBAL = "https://github.com/mcpplibs/std-freestanding-alloc-kal/archive/refs/tags/0.1.0.tar.gz",
28+
CN = "https://gitcode.com/mcpp-res/std-freestanding-alloc-kal/releases/download/0.1.0/std-freestanding-alloc-kal-0.1.0.tar.gz",
29+
},
30+
sha256 = "6d3c746e5013655464fd47de54868e06c81a3563046d6bff58c9cb28e689e899",
31+
},
32+
},
33+
macosx = {
34+
["0.1.0"] = {
35+
url = {
36+
GLOBAL = "https://github.com/mcpplibs/std-freestanding-alloc-kal/archive/refs/tags/0.1.0.tar.gz",
37+
CN = "https://gitcode.com/mcpp-res/std-freestanding-alloc-kal/releases/download/0.1.0/std-freestanding-alloc-kal-0.1.0.tar.gz",
38+
},
39+
sha256 = "6d3c746e5013655464fd47de54868e06c81a3563046d6bff58c9cb28e689e899",
40+
},
41+
},
42+
windows = {
43+
["0.1.0"] = {
44+
url = {
45+
GLOBAL = "https://github.com/mcpplibs/std-freestanding-alloc-kal/archive/refs/tags/0.1.0.tar.gz",
46+
CN = "https://gitcode.com/mcpp-res/std-freestanding-alloc-kal/releases/download/0.1.0/std-freestanding-alloc-kal-0.1.0.tar.gz",
47+
},
48+
sha256 = "6d3c746e5013655464fd47de54868e06c81a3563046d6bff58c9cb28e689e899",
49+
},
50+
},
51+
},
52+
53+
-- The package's own manifest, inside the tarball's wrap directory.
54+
mcpp = "*/mcpp.toml",
55+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
-- std-freestanding-alloc-libc — the sibling of std-freestanding-alloc-kal,
2+
-- forwarding to the target's C library instead of to openkal.
3+
--
4+
-- ⚠️ Exactly one of the two may be in a graph. Both provide the
5+
-- `freestanding-allocator` capability, and `operator new` is a whole-program
6+
-- singleton: the resolver reports two providers by name, which is the reason
7+
-- the choice is made through a capability rather than by whichever definition
8+
-- the linker happened to see first.
9+
package = {
10+
spec = "1",
11+
namespace = "mcpplibs",
12+
name = "std-freestanding-alloc-libc",
13+
description = "The replaceable allocation functions for the freestanding subset, forwarded to the target's C library",
14+
licenses = {"Apache-2.0"},
15+
repo = "https://github.com/mcpplibs/std-freestanding-alloc-libc",
16+
type = "package",
17+
18+
xpm = {
19+
linux = {
20+
["0.1.0"] = {
21+
url = {
22+
GLOBAL = "https://github.com/mcpplibs/std-freestanding-alloc-libc/archive/refs/tags/0.1.0.tar.gz",
23+
CN = "https://gitcode.com/mcpp-res/std-freestanding-alloc-libc/releases/download/0.1.0/std-freestanding-alloc-libc-0.1.0.tar.gz",
24+
},
25+
sha256 = "019d13c2363a0a3487f9e2664ef3f533724edb46deb9badf2ea21298e932505c",
26+
},
27+
},
28+
macosx = {
29+
["0.1.0"] = {
30+
url = {
31+
GLOBAL = "https://github.com/mcpplibs/std-freestanding-alloc-libc/archive/refs/tags/0.1.0.tar.gz",
32+
CN = "https://gitcode.com/mcpp-res/std-freestanding-alloc-libc/releases/download/0.1.0/std-freestanding-alloc-libc-0.1.0.tar.gz",
33+
},
34+
sha256 = "019d13c2363a0a3487f9e2664ef3f533724edb46deb9badf2ea21298e932505c",
35+
},
36+
},
37+
windows = {
38+
["0.1.0"] = {
39+
url = {
40+
GLOBAL = "https://github.com/mcpplibs/std-freestanding-alloc-libc/archive/refs/tags/0.1.0.tar.gz",
41+
CN = "https://gitcode.com/mcpp-res/std-freestanding-alloc-libc/releases/download/0.1.0/std-freestanding-alloc-libc-0.1.0.tar.gz",
42+
},
43+
sha256 = "019d13c2363a0a3487f9e2664ef3f533724edb46deb9badf2ea21298e932505c",
44+
},
45+
},
46+
},
47+
48+
-- The package's own manifest, inside the tarball's wrap directory.
49+
mcpp = "*/mcpp.toml",
50+
}

pkgs/s/std-freestanding-nolibc.lua

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
-- std-freestanding-nolibc — the five C functions a freestanding C++
2+
-- translation unit still reaches for, for targets that have declined one.
3+
--
4+
-- ⚠️ FOR THE ZERO-LIBC TIER ONLY. mcpp contributes a dependency package's
5+
-- object files to the consumer's link unconditionally, so a project whose
6+
-- board package links `-lc` would get two definitions of `memcpy`. The
7+
-- intended consumer sets `[target.<triple>].sysroot = ""`.
8+
--
9+
-- Four of the five are an obligation rather than a convenience: a freestanding
10+
-- implementation provides memcpy, memmove, memset and memcmp because the
11+
-- compiler lowers structure assignment and array initialisation onto them.
12+
package = {
13+
spec = "1",
14+
namespace = "mcpplibs",
15+
name = "std-freestanding-nolibc",
16+
description = "memcpy, memmove, memset, memcmp and strlen for targets with no C library",
17+
licenses = {"Apache-2.0"},
18+
repo = "https://github.com/mcpplibs/std-freestanding-nolibc",
19+
type = "package",
20+
21+
xpm = {
22+
linux = {
23+
["0.1.0"] = {
24+
url = {
25+
GLOBAL = "https://github.com/mcpplibs/std-freestanding-nolibc/archive/refs/tags/0.1.0.tar.gz",
26+
CN = "https://gitcode.com/mcpp-res/std-freestanding-nolibc/releases/download/0.1.0/std-freestanding-nolibc-0.1.0.tar.gz",
27+
},
28+
sha256 = "280ffe0180e0bd19ef94d4655c564507c4799e5c72ac7624d58722cb8aac363a",
29+
},
30+
},
31+
macosx = {
32+
["0.1.0"] = {
33+
url = {
34+
GLOBAL = "https://github.com/mcpplibs/std-freestanding-nolibc/archive/refs/tags/0.1.0.tar.gz",
35+
CN = "https://gitcode.com/mcpp-res/std-freestanding-nolibc/releases/download/0.1.0/std-freestanding-nolibc-0.1.0.tar.gz",
36+
},
37+
sha256 = "280ffe0180e0bd19ef94d4655c564507c4799e5c72ac7624d58722cb8aac363a",
38+
},
39+
},
40+
windows = {
41+
["0.1.0"] = {
42+
url = {
43+
GLOBAL = "https://github.com/mcpplibs/std-freestanding-nolibc/archive/refs/tags/0.1.0.tar.gz",
44+
CN = "https://gitcode.com/mcpp-res/std-freestanding-nolibc/releases/download/0.1.0/std-freestanding-nolibc-0.1.0.tar.gz",
45+
},
46+
sha256 = "280ffe0180e0bd19ef94d4655c564507c4799e5c72ac7624d58722cb8aac363a",
47+
},
48+
},
49+
},
50+
51+
-- The package's own manifest, inside the tarball's wrap directory.
52+
mcpp = "*/mcpp.toml",
53+
}

pkgs/s/std-freestanding.lua

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ package = {
3030
},
3131
sha256 = "c0026e6aa85d207b3dd00c3f2fe2674174c2e25d86a162f64fe70742420efb00",
3232
},
33+
["0.3.0"] = {
34+
url = {
35+
GLOBAL = "https://github.com/mcpplibs/std-freestanding/archive/refs/tags/0.3.0.tar.gz",
36+
CN = "https://gitcode.com/mcpp-res/std-freestanding/releases/download/0.3.0/std-freestanding-0.3.0.tar.gz",
37+
},
38+
sha256 = "04c02fc42d1fb608a831ff6a1c780a4c12901d8d1d680bd602cb4ff439eedf9a",
39+
},
3340
},
3441
macosx = {
3542
["0.2.0"] = {
@@ -39,6 +46,13 @@ package = {
3946
},
4047
sha256 = "c0026e6aa85d207b3dd00c3f2fe2674174c2e25d86a162f64fe70742420efb00",
4148
},
49+
["0.3.0"] = {
50+
url = {
51+
GLOBAL = "https://github.com/mcpplibs/std-freestanding/archive/refs/tags/0.3.0.tar.gz",
52+
CN = "https://gitcode.com/mcpp-res/std-freestanding/releases/download/0.3.0/std-freestanding-0.3.0.tar.gz",
53+
},
54+
sha256 = "04c02fc42d1fb608a831ff6a1c780a4c12901d8d1d680bd602cb4ff439eedf9a",
55+
},
4256
},
4357
windows = {
4458
["0.2.0"] = {
@@ -48,6 +62,13 @@ package = {
4862
},
4963
sha256 = "c0026e6aa85d207b3dd00c3f2fe2674174c2e25d86a162f64fe70742420efb00",
5064
},
65+
["0.3.0"] = {
66+
url = {
67+
GLOBAL = "https://github.com/mcpplibs/std-freestanding/archive/refs/tags/0.3.0.tar.gz",
68+
CN = "https://gitcode.com/mcpp-res/std-freestanding/releases/download/0.3.0/std-freestanding-0.3.0.tar.gz",
69+
},
70+
sha256 = "04c02fc42d1fb608a831ff6a1c780a4c12901d8d1d680bd602cb4ff439eedf9a",
71+
},
5172
},
5273
},
5374

0 commit comments

Comments
 (0)