From db401a6439d1b0950e61f409b2e64f9025ac7cd6 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Fri, 4 Sep 2026 15:01:31 +0800 Subject: [PATCH] cortex-m-rt 0.2.1, and the C library packages under upstream's namespace MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## ⚠️ The namespace is upstream's, not `mcpplibs` mcpplibs.picolibc → picolibc.picolibc mcpplibs.compiler-rt-builtins → llvm.compiler-rt-builtins A package that vendors someone else's sources and adds a manifest is not this organisation's: the code is upstream's and the identity has to say so. `mcpplibs` is for packages whose CONTENT was written here — `cortex-m-rt` is one, and keeps it. ⭐ The wrapper REPOSITORY can still live under mcpplibs. `ocornut.imgui` is published from `mcpplibs/imgui-m` for exactly this reason: where the manifest lives and whose code it describes are different questions. ## cortex-m-rt: one package, two environments, three features mcpp run # the emulator mcpp run --features hardware # the board, over a debug probe mcpp run --features libc # with a C library A board reached through an emulator and the same board reached through a probe differ in the argv of their runners and in nothing else, so the environment is a feature rather than a second package. Each brings its own tool on the `run` tier, so a CI job that compiles firmware and never flashes it downloads nothing. ⚠️ And the board sets the thread pointer, which is what makes `libc` work. picolibc reaches `stdout` through thread-local storage; a freestanding image has none until the startup file sets one. Measured without it: a `printf` program linked cleanly, ran, printed NOTHING and hung. ## ⚠️⚠️ The first picolibc entries are removed rather than kept They took UPSTREAM's version (1.8.12, 22.1.8), which is wrong in kind — a package's version has to move when the PACKAGING changes, and the packaging is most of what is there. `openkal-musl` is 0.13.1 for musl 1.2.5 for the same reason. And they shipped a `path =` dependency left over from local testing: error: path dependency 'compiler-rt-builtins' has no mcpp.toml so they resolve to nothing on any machine without a sibling checkout. Keeping a version that cannot install is not compatibility. ⭐ Found by the SANDBOX, not by CI: `xlings subos … --sandbox` installed the engine from the published index and could not resolve `cortex-m-rt`, because it had never been added here. That is the check the ecosystem needs and no repository's own CI performs. All tarballs verified against their bytes and re-fetched from the CN mirror, byte-identical. Index lints pass. Measured after the rename: `mcpp run --features libc` still prints `feature-libc: 13.00`. --- pkgs/c/cortex-m-rt.lua | 76 +++++++++++++++++++ .../llvm.compiler-rt-builtins.lua} | 36 +++++---- .../p/{picolibc.lua => picolibc.picolibc.lua} | 44 ++++++----- 3 files changed, 122 insertions(+), 34 deletions(-) create mode 100644 pkgs/c/cortex-m-rt.lua rename pkgs/{c/compiler-rt-builtins.lua => l/llvm.compiler-rt-builtins.lua} (56%) rename pkgs/p/{picolibc.lua => picolibc.picolibc.lua} (63%) diff --git a/pkgs/c/cortex-m-rt.lua b/pkgs/c/cortex-m-rt.lua new file mode 100644 index 00000000..f10ba54a --- /dev/null +++ b/pkgs/c/cortex-m-rt.lua @@ -0,0 +1,76 @@ +-- Board support for Cortex-M: startup, memory layout, a semihosting console, +-- and the runners that reach an emulator or a debug probe. +-- +-- ⭐⭐ ONE PACKAGE, TWO ENVIRONMENTS — AND SINCE 0.2.1, THREE FEATURES. +-- +-- A board reached through an emulator and the same board reached through a +-- debug probe differ in the argv of their runners and in NOTHING else: the +-- linker script, the startup code, the memory map and the exported module are +-- the same board. Publishing two packages to vary four strings would duplicate +-- all of it and let the copies drift. So the environment is a FEATURE, and the +-- consumer selects it where it selects everything else: +-- +-- mcpp run # the emulator +-- mcpp run --features hardware # the board, over a debug probe +-- mcpp run --features libc # with a C library +-- +-- ⭐ `mcpp run` IS THE WHOLE OF THE COMMON CASE, ON EITHER. On a device, +-- running a program means writing it, resetting, attaching to its output and +-- reading its exit status — ONE command, not several. So that is the DEFAULT +-- runner in both environments, and the command a developer types does not +-- change when the board arrives. `flash` and `serve` are named exceptions, and +-- the engine knows neither name. +-- +-- ⚠️ EACH ENVIRONMENT BRINGS ITS OWN TOOL, ON THE `run` TIER. `qemu-arm` under +-- `[feature-xlings.emulator]`, `probe-rs` under `[feature-xlings.hardware]`, +-- both `when = "run"` — so a consumer downloads exactly what the feature they +-- selected needs, and a CI job that compiles firmware and never flashes it +-- downloads nothing at all. Requires mcpp 2026.9.4.2. +-- +-- ⚠️ AND THE BOARD SETS THE THREAD POINTER, which is what makes `libc` work. +-- picolibc reaches `stdout` through thread-local storage, and a freestanding +-- image has none until the startup file sets one. Measured without it: a +-- `printf` program linked cleanly, ran, printed NOTHING and hung. There is no +-- diagnostic for that state; the only evidence is silence. +package = { + spec = "1", + namespace = "mcpplibs", + name = "cortex-m-rt", + description = "Board support for Cortex-M: startup, memory layout, semihosting console, and the runners that reach an emulator or a debug probe", + licenses = {"Apache-2.0"}, + repo = "https://github.com/mcpplibs/cortex-m-rt", + type = "package", + + xpm = { + linux = { + ["0.2.1"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/cortex-m-rt/archive/refs/tags/0.2.1.tar.gz", + CN = "https://gitcode.com/mcpp-res/cortex-m-rt/releases/download/0.2.1/cortex-m-rt-0.2.1.tar.gz", + }, + sha256 = "d4983148c80cd5366a3374f3bc5a379f9688657c516868e459eefd31b97cfd60", + }, + }, + macosx = { + ["0.2.1"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/cortex-m-rt/archive/refs/tags/0.2.1.tar.gz", + CN = "https://gitcode.com/mcpp-res/cortex-m-rt/releases/download/0.2.1/cortex-m-rt-0.2.1.tar.gz", + }, + sha256 = "d4983148c80cd5366a3374f3bc5a379f9688657c516868e459eefd31b97cfd60", + }, + }, + windows = { + ["0.2.1"] = { + url = { + GLOBAL = "https://github.com/mcpplibs/cortex-m-rt/archive/refs/tags/0.2.1.tar.gz", + CN = "https://gitcode.com/mcpp-res/cortex-m-rt/releases/download/0.2.1/cortex-m-rt-0.2.1.tar.gz", + }, + sha256 = "d4983148c80cd5366a3374f3bc5a379f9688657c516868e459eefd31b97cfd60", + }, + }, + }, + + -- The package's own manifest, inside the tarball's wrap directory. + mcpp = "*/mcpp.toml", +} diff --git a/pkgs/c/compiler-rt-builtins.lua b/pkgs/l/llvm.compiler-rt-builtins.lua similarity index 56% rename from pkgs/c/compiler-rt-builtins.lua rename to pkgs/l/llvm.compiler-rt-builtins.lua index cb681505..8db14fff 100644 --- a/pkgs/c/compiler-rt-builtins.lua +++ b/pkgs/l/llvm.compiler-rt-builtins.lua @@ -11,41 +11,49 @@ -- at all: cmake succeeds, ninja reports "no work to do", and the failure -- surfaces later as a missing file. A source package has no archive to name and -- no triple to translate. +-- +-- ⚠️ THE NAMESPACE IS UPSTREAM'S, NOT `mcpplibs`. This package vendors someone +-- else's sources and adds a manifest; the code is theirs and the identity says +-- so. `mcpplibs` is for packages whose CONTENT this organisation wrote. +-- +-- ⭐ The wrapper REPOSITORY can still live under mcpplibs — `ocornut.imgui` is +-- published from `mcpplibs/imgui-m` for exactly this reason. Where the manifest +-- lives and whose code it describes are different questions. package = { spec = "1", - namespace = "mcpplibs", + namespace = "llvm", name = "compiler-rt-builtins", - description = "The compiler-rt builtins as a source package: the routines a compiler emits calls to, compiled with the consuming program's own flags", + description = "The compiler-rt 22.1.8 builtins as a source package: the routines a compiler emits calls to, compiled with the consuming program's own flags", licenses = {"Apache-2.0 WITH LLVM-exception"}, repo = "https://github.com/mcpplibs/compiler-rt-builtins", type = "package", xpm = { linux = { - ["22.1.8"] = { + ["0.1.1"] = { url = { - GLOBAL = "https://github.com/mcpplibs/compiler-rt-builtins/archive/refs/tags/22.1.8.tar.gz", - CN = "https://gitcode.com/mcpp-res/compiler-rt-builtins/releases/download/22.1.8/compiler-rt-builtins-22.1.8.tar.gz", + GLOBAL = "https://github.com/mcpplibs/compiler-rt-builtins/archive/refs/tags/0.1.1.tar.gz", + CN = "https://gitcode.com/mcpp-res/compiler-rt-builtins/releases/download/0.1.1/compiler-rt-builtins-0.1.1.tar.gz", }, - sha256 = "fe00cb58128c00a3a47483f30a828bed52f4a35529c1bb0d4cb8f0376c9c492d", + sha256 = "443673d32137ae64896e341cce52f76a2e8c183cad86d5772a457c4cf4daf513", }, }, macosx = { - ["22.1.8"] = { + ["0.1.1"] = { url = { - GLOBAL = "https://github.com/mcpplibs/compiler-rt-builtins/archive/refs/tags/22.1.8.tar.gz", - CN = "https://gitcode.com/mcpp-res/compiler-rt-builtins/releases/download/22.1.8/compiler-rt-builtins-22.1.8.tar.gz", + GLOBAL = "https://github.com/mcpplibs/compiler-rt-builtins/archive/refs/tags/0.1.1.tar.gz", + CN = "https://gitcode.com/mcpp-res/compiler-rt-builtins/releases/download/0.1.1/compiler-rt-builtins-0.1.1.tar.gz", }, - sha256 = "fe00cb58128c00a3a47483f30a828bed52f4a35529c1bb0d4cb8f0376c9c492d", + sha256 = "443673d32137ae64896e341cce52f76a2e8c183cad86d5772a457c4cf4daf513", }, }, windows = { - ["22.1.8"] = { + ["0.1.1"] = { url = { - GLOBAL = "https://github.com/mcpplibs/compiler-rt-builtins/archive/refs/tags/22.1.8.tar.gz", - CN = "https://gitcode.com/mcpp-res/compiler-rt-builtins/releases/download/22.1.8/compiler-rt-builtins-22.1.8.tar.gz", + GLOBAL = "https://github.com/mcpplibs/compiler-rt-builtins/archive/refs/tags/0.1.1.tar.gz", + CN = "https://gitcode.com/mcpp-res/compiler-rt-builtins/releases/download/0.1.1/compiler-rt-builtins-0.1.1.tar.gz", }, - sha256 = "fe00cb58128c00a3a47483f30a828bed52f4a35529c1bb0d4cb8f0376c9c492d", + sha256 = "443673d32137ae64896e341cce52f76a2e8c183cad86d5772a457c4cf4daf513", }, }, }, diff --git a/pkgs/p/picolibc.lua b/pkgs/p/picolibc.picolibc.lua similarity index 63% rename from pkgs/p/picolibc.lua rename to pkgs/p/picolibc.picolibc.lua index 09e6b4d4..412ea8ca 100644 --- a/pkgs/p/picolibc.lua +++ b/pkgs/p/picolibc.picolibc.lua @@ -19,50 +19,54 @@ -- GENERATES, included — is byte-identical. The prebuilt ships seven copies of -- one directory. -- --- ⭐ Compiled with the SAME `compile_flags` as the program consuming it, ABI --- agreement holds by construction rather than by a naming convention, and the --- version lands in `mcpp.lock` rather than being pinned inside a target table. --- -- ⚠️ `picocrt` IS DELIBERATELY ABSENT. A startup object decides where execution -- begins and how it reaches the host — which board is running. Choosing among -- picolibc's nine variants is a board-support package's job; `cortex-m-rt` --- supplies its own, including the thread-pointer initialisation without which --- a `printf` program links cleanly, runs, prints nothing and hangs. +-- supplies its own, including the thread-pointer initialisation without which a +-- `printf` program links cleanly, runs, prints nothing and hangs. +-- +-- ⚠️ THE NAMESPACE IS UPSTREAM'S, NOT `mcpplibs`. This package vendors someone +-- else's sources and adds a manifest; the code is theirs and the identity says +-- so. `mcpplibs` is for packages whose CONTENT this organisation wrote. +-- +-- ⭐ The wrapper REPOSITORY can still live under mcpplibs — `ocornut.imgui` is +-- published from `mcpplibs/imgui-m` for exactly this reason. Where the manifest +-- lives and whose code it describes are different questions. package = { spec = "1", - namespace = "mcpplibs", + namespace = "picolibc", name = "picolibc", - description = "picolibc as a source package: a freestanding C library compiled with the consuming program's own flags, so there is no multilib and no ABI convention to match", + description = "picolibc 1.8.12 as a source package: a freestanding C library compiled with the consuming program's own flags, so there is no multilib and no ABI convention to match", licenses = {"BSD-3-Clause", "BSD-2-Clause"}, repo = "https://github.com/mcpplibs/picolibc", type = "package", xpm = { linux = { - ["1.8.12"] = { + ["0.1.1"] = { url = { - GLOBAL = "https://github.com/mcpplibs/picolibc/archive/refs/tags/1.8.12.tar.gz", - CN = "https://gitcode.com/mcpp-res/picolibc/releases/download/1.8.12/picolibc-1.8.12.tar.gz", + GLOBAL = "https://github.com/mcpplibs/picolibc/archive/refs/tags/0.1.1.tar.gz", + CN = "https://gitcode.com/mcpp-res/picolibc/releases/download/0.1.1/picolibc-0.1.1.tar.gz", }, - sha256 = "8f3d7a41d9981905d389b321edbfa2fac4946e5acc3a0677617b8184b21d4420", + sha256 = "2265a49e58ed02b2166a4cbef40595a2250c7a0821156f96d4e04ae2086ccf89", }, }, macosx = { - ["1.8.12"] = { + ["0.1.1"] = { url = { - GLOBAL = "https://github.com/mcpplibs/picolibc/archive/refs/tags/1.8.12.tar.gz", - CN = "https://gitcode.com/mcpp-res/picolibc/releases/download/1.8.12/picolibc-1.8.12.tar.gz", + GLOBAL = "https://github.com/mcpplibs/picolibc/archive/refs/tags/0.1.1.tar.gz", + CN = "https://gitcode.com/mcpp-res/picolibc/releases/download/0.1.1/picolibc-0.1.1.tar.gz", }, - sha256 = "8f3d7a41d9981905d389b321edbfa2fac4946e5acc3a0677617b8184b21d4420", + sha256 = "2265a49e58ed02b2166a4cbef40595a2250c7a0821156f96d4e04ae2086ccf89", }, }, windows = { - ["1.8.12"] = { + ["0.1.1"] = { url = { - GLOBAL = "https://github.com/mcpplibs/picolibc/archive/refs/tags/1.8.12.tar.gz", - CN = "https://gitcode.com/mcpp-res/picolibc/releases/download/1.8.12/picolibc-1.8.12.tar.gz", + GLOBAL = "https://github.com/mcpplibs/picolibc/archive/refs/tags/0.1.1.tar.gz", + CN = "https://gitcode.com/mcpp-res/picolibc/releases/download/0.1.1/picolibc-0.1.1.tar.gz", }, - sha256 = "8f3d7a41d9981905d389b321edbfa2fac4946e5acc3a0677617b8184b21d4420", + sha256 = "2265a49e58ed02b2166a4cbef40595a2250c7a0821156f96d4e04ae2086ccf89", }, }, },