From 357beef5d02cc00b83340d1251a98490df226061 Mon Sep 17 00:00:00 2001 From: speak-agent <248744407+speak-agent@users.noreply.github.com> Date: Thu, 20 Aug 2026 15:38:43 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=A3=B8=E6=9C=BA=E5=88=86=E9=85=8D?= =?UTF-8?q?=E5=99=A8=E4=B8=8E=E9=9B=B6=20libc=20=E5=B1=82=20=E2=80=94?= =?UTF-8?q?=E2=80=94=20=E4=B8=89=E4=B8=AA=E6=96=B0=E5=8C=85,=E4=B8=A4?= =?UTF-8?q?=E4=B8=AA=E6=96=B0=E7=89=88=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## 新增 * `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.].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` 未动。 --- pkgs/r/riscv-virt-rt.lua | 21 ++++++++++ pkgs/s/std-freestanding-alloc-kal.lua | 55 ++++++++++++++++++++++++++ pkgs/s/std-freestanding-alloc-libc.lua | 50 +++++++++++++++++++++++ pkgs/s/std-freestanding-nolibc.lua | 53 +++++++++++++++++++++++++ pkgs/s/std-freestanding.lua | 21 ++++++++++ 5 files changed, 200 insertions(+) create mode 100644 pkgs/s/std-freestanding-alloc-kal.lua create mode 100644 pkgs/s/std-freestanding-alloc-libc.lua create mode 100644 pkgs/s/std-freestanding-nolibc.lua diff --git a/pkgs/r/riscv-virt-rt.lua b/pkgs/r/riscv-virt-rt.lua index d339d82..5442dab 100644 --- a/pkgs/r/riscv-virt-rt.lua +++ b/pkgs/r/riscv-virt-rt.lua @@ -52,6 +52,13 @@ package = { }, sha256 = "71fc43daa4903d4f3037c204bd2b3be9aea56371b123a4529cc8c0c8c9b7f525", }, + ["0.4.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/riscv-virt-rt/archive/refs/tags/0.4.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/riscv-virt-rt/releases/download/0.4.0/riscv-virt-rt-0.4.0.tar.gz", + }, + sha256 = "2eef43aefb00905236a72d49924129c379e9d085fafdc4dd5c868e8a52b0414e", + }, }, macosx = { deps = { "xim:qemu-riscv@9.2.4-1" }, @@ -76,6 +83,13 @@ package = { }, sha256 = "71fc43daa4903d4f3037c204bd2b3be9aea56371b123a4529cc8c0c8c9b7f525", }, + ["0.4.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/riscv-virt-rt/archive/refs/tags/0.4.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/riscv-virt-rt/releases/download/0.4.0/riscv-virt-rt-0.4.0.tar.gz", + }, + sha256 = "2eef43aefb00905236a72d49924129c379e9d085fafdc4dd5c868e8a52b0414e", + }, }, windows = { deps = { "xim:qemu-riscv@9.2.4-1" }, @@ -100,6 +114,13 @@ package = { }, sha256 = "71fc43daa4903d4f3037c204bd2b3be9aea56371b123a4529cc8c0c8c9b7f525", }, + ["0.4.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/riscv-virt-rt/archive/refs/tags/0.4.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/riscv-virt-rt/releases/download/0.4.0/riscv-virt-rt-0.4.0.tar.gz", + }, + sha256 = "2eef43aefb00905236a72d49924129c379e9d085fafdc4dd5c868e8a52b0414e", + }, }, }, diff --git a/pkgs/s/std-freestanding-alloc-kal.lua b/pkgs/s/std-freestanding-alloc-kal.lua new file mode 100644 index 0000000..bccf5d0 --- /dev/null +++ b/pkgs/s/std-freestanding-alloc-kal.lua @@ -0,0 +1,55 @@ +-- std-freestanding-alloc-kal — one of the allocator implementations the +-- freestanding subset can bind. +-- +-- Form A because mcpp looks for a package manifest at the package ROOT, and +-- Form B would leave it one level down inside the tarball's wrap directory. +-- +-- ⚠️ NO `deps`. The package depends on `openkal` for the C declarations it is +-- written against, and that is an mcpp dependency declared in its own +-- manifest — not an xim payload. Nothing here needs installing. +-- +-- The consumer does not name this package. `std-freestanding`'s `alloc-kal` +-- feature pulls it, because the feature both states the requirement and brings +-- an implementation; see that package's `[feature-deps]`. +package = { + spec = "1", + namespace = "mcpplibs", + name = "std-freestanding-alloc-kal", + description = "The replaceable allocation functions for the freestanding subset, forwarded to openkal", + licenses = {"Apache-2.0"}, + repo = "https://github.com/mcpplibs/std-freestanding-alloc-kal", + type = "package", + + xpm = { + linux = { + ["0.1.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/std-freestanding-alloc-kal/archive/refs/tags/0.1.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/std-freestanding-alloc-kal/releases/download/0.1.0/std-freestanding-alloc-kal-0.1.0.tar.gz", + }, + sha256 = "6d3c746e5013655464fd47de54868e06c81a3563046d6bff58c9cb28e689e899", + }, + }, + macosx = { + ["0.1.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/std-freestanding-alloc-kal/archive/refs/tags/0.1.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/std-freestanding-alloc-kal/releases/download/0.1.0/std-freestanding-alloc-kal-0.1.0.tar.gz", + }, + sha256 = "6d3c746e5013655464fd47de54868e06c81a3563046d6bff58c9cb28e689e899", + }, + }, + windows = { + ["0.1.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/std-freestanding-alloc-kal/archive/refs/tags/0.1.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/std-freestanding-alloc-kal/releases/download/0.1.0/std-freestanding-alloc-kal-0.1.0.tar.gz", + }, + sha256 = "6d3c746e5013655464fd47de54868e06c81a3563046d6bff58c9cb28e689e899", + }, + }, + }, + + -- The package's own manifest, inside the tarball's wrap directory. + mcpp = "*/mcpp.toml", +} diff --git a/pkgs/s/std-freestanding-alloc-libc.lua b/pkgs/s/std-freestanding-alloc-libc.lua new file mode 100644 index 0000000..aead352 --- /dev/null +++ b/pkgs/s/std-freestanding-alloc-libc.lua @@ -0,0 +1,50 @@ +-- std-freestanding-alloc-libc — the sibling of std-freestanding-alloc-kal, +-- forwarding to the target's C library instead of to openkal. +-- +-- ⚠️ Exactly one of the two may be in a graph. Both provide the +-- `freestanding-allocator` capability, and `operator new` is a whole-program +-- singleton: the resolver reports two providers by name, which is the reason +-- the choice is made through a capability rather than by whichever definition +-- the linker happened to see first. +package = { + spec = "1", + namespace = "mcpplibs", + name = "std-freestanding-alloc-libc", + description = "The replaceable allocation functions for the freestanding subset, forwarded to the target's C library", + licenses = {"Apache-2.0"}, + repo = "https://github.com/mcpplibs/std-freestanding-alloc-libc", + type = "package", + + xpm = { + linux = { + ["0.1.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/std-freestanding-alloc-libc/archive/refs/tags/0.1.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/std-freestanding-alloc-libc/releases/download/0.1.0/std-freestanding-alloc-libc-0.1.0.tar.gz", + }, + sha256 = "019d13c2363a0a3487f9e2664ef3f533724edb46deb9badf2ea21298e932505c", + }, + }, + macosx = { + ["0.1.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/std-freestanding-alloc-libc/archive/refs/tags/0.1.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/std-freestanding-alloc-libc/releases/download/0.1.0/std-freestanding-alloc-libc-0.1.0.tar.gz", + }, + sha256 = "019d13c2363a0a3487f9e2664ef3f533724edb46deb9badf2ea21298e932505c", + }, + }, + windows = { + ["0.1.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/std-freestanding-alloc-libc/archive/refs/tags/0.1.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/std-freestanding-alloc-libc/releases/download/0.1.0/std-freestanding-alloc-libc-0.1.0.tar.gz", + }, + sha256 = "019d13c2363a0a3487f9e2664ef3f533724edb46deb9badf2ea21298e932505c", + }, + }, + }, + + -- The package's own manifest, inside the tarball's wrap directory. + mcpp = "*/mcpp.toml", +} diff --git a/pkgs/s/std-freestanding-nolibc.lua b/pkgs/s/std-freestanding-nolibc.lua new file mode 100644 index 0000000..c42c214 --- /dev/null +++ b/pkgs/s/std-freestanding-nolibc.lua @@ -0,0 +1,53 @@ +-- std-freestanding-nolibc — the five C functions a freestanding C++ +-- translation unit still reaches for, for targets that have declined one. +-- +-- ⚠️ FOR THE ZERO-LIBC TIER ONLY. mcpp contributes a dependency package's +-- object files to the consumer's link unconditionally, so a project whose +-- board package links `-lc` would get two definitions of `memcpy`. The +-- intended consumer sets `[target.].sysroot = ""`. +-- +-- Four of the five are an obligation rather than a convenience: a freestanding +-- implementation provides memcpy, memmove, memset and memcmp because the +-- compiler lowers structure assignment and array initialisation onto them. +package = { + spec = "1", + namespace = "mcpplibs", + name = "std-freestanding-nolibc", + description = "memcpy, memmove, memset, memcmp and strlen for targets with no C library", + licenses = {"Apache-2.0"}, + repo = "https://github.com/mcpplibs/std-freestanding-nolibc", + type = "package", + + xpm = { + linux = { + ["0.1.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/std-freestanding-nolibc/archive/refs/tags/0.1.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/std-freestanding-nolibc/releases/download/0.1.0/std-freestanding-nolibc-0.1.0.tar.gz", + }, + sha256 = "280ffe0180e0bd19ef94d4655c564507c4799e5c72ac7624d58722cb8aac363a", + }, + }, + macosx = { + ["0.1.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/std-freestanding-nolibc/archive/refs/tags/0.1.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/std-freestanding-nolibc/releases/download/0.1.0/std-freestanding-nolibc-0.1.0.tar.gz", + }, + sha256 = "280ffe0180e0bd19ef94d4655c564507c4799e5c72ac7624d58722cb8aac363a", + }, + }, + windows = { + ["0.1.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/std-freestanding-nolibc/archive/refs/tags/0.1.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/std-freestanding-nolibc/releases/download/0.1.0/std-freestanding-nolibc-0.1.0.tar.gz", + }, + sha256 = "280ffe0180e0bd19ef94d4655c564507c4799e5c72ac7624d58722cb8aac363a", + }, + }, + }, + + -- The package's own manifest, inside the tarball's wrap directory. + mcpp = "*/mcpp.toml", +} diff --git a/pkgs/s/std-freestanding.lua b/pkgs/s/std-freestanding.lua index dc96c0d..5c7adc6 100644 --- a/pkgs/s/std-freestanding.lua +++ b/pkgs/s/std-freestanding.lua @@ -30,6 +30,13 @@ package = { }, sha256 = "c0026e6aa85d207b3dd00c3f2fe2674174c2e25d86a162f64fe70742420efb00", }, + ["0.3.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/std-freestanding/archive/refs/tags/0.3.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/std-freestanding/releases/download/0.3.0/std-freestanding-0.3.0.tar.gz", + }, + sha256 = "04c02fc42d1fb608a831ff6a1c780a4c12901d8d1d680bd602cb4ff439eedf9a", + }, }, macosx = { ["0.2.0"] = { @@ -39,6 +46,13 @@ package = { }, sha256 = "c0026e6aa85d207b3dd00c3f2fe2674174c2e25d86a162f64fe70742420efb00", }, + ["0.3.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/std-freestanding/archive/refs/tags/0.3.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/std-freestanding/releases/download/0.3.0/std-freestanding-0.3.0.tar.gz", + }, + sha256 = "04c02fc42d1fb608a831ff6a1c780a4c12901d8d1d680bd602cb4ff439eedf9a", + }, }, windows = { ["0.2.0"] = { @@ -48,6 +62,13 @@ package = { }, sha256 = "c0026e6aa85d207b3dd00c3f2fe2674174c2e25d86a162f64fe70742420efb00", }, + ["0.3.0"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/std-freestanding/archive/refs/tags/0.3.0.tar.gz", + CN = "https://gitcode.com/mcpp-res/std-freestanding/releases/download/0.3.0/std-freestanding-0.3.0.tar.gz", + }, + sha256 = "04c02fc42d1fb608a831ff6a1c780a4c12901d8d1d680bd602cb4ff439eedf9a", + }, }, },