Skip to content

Commit f3df5f5

Browse files
authored
picolibc 1.8.12 and compiler-rt-builtins 22.1.8 — the C library, as source (#336)
⭐⭐ SOURCE PACKAGES, NOT A PREBUILT SYSROOT, AND THE MEASUREMENTS SAY WHY. A prebuilt C library ships one build per ABI a target table can name — seven for Cortex-M alone — and every consumer then finds the right one through a `libdir` convention that must match the payload byte for byte. That convention is what #481 was filed about, and on ARM it cannot work at all: the key `<march>/<mabi>` does not separate the float ABI, because `mabi` there names the procedure call standard and is `aapcs` either way. Measured while building the prebuilt first: the seven profiles collapsed into FIVE directories and the soft-float row received a library carrying `Tag_ABI_HardFP_use`. Nothing failed at build time. ⚠️ And the headers were never per-profile. Across those seven builds the whole include tree — `picolibc.h` and `newlib.h`, which meson GENERATES, included — is byte-identical. The prebuilt shipped seven copies of one directory. Compiled with the same `compile_flags` as the program consuming it, ABI agreement holds by construction, and the version lands in `mcpp.lock` rather than being pinned inside a target table. ## What the source route cost instead Four upstream partitions a flat library has to be told about, each found by a link error rather than by reading: * `libos/semihost` and `libos/dummyhost` define the same syscalls and upstream keeps them in separate ARCHIVES, where link order decides. A feature here. * `semihost/fake` is the COMPLEMENT of `semihost/common` — 13 of 26 files — and the complement cannot be computed from filenames: `fake_io.c` collides with `common/iob.c` on `stdin`/`stdout`/`stderr`. * the machine directory carries variants for every ARM profile upstream serves; `memcpy-armv7a.S` needs ARM mode and Thumb-2, which no M-profile core has. * a negative glob in a base source set applies to the MERGED set, so `!…/machine/**` cancels the per-target block that adds the right one back. And for the builtins, one more: upstream picks per CPU and the sets are nested — 25 files on armv6-m, 90 on armv8-m.main — so the list is the INTERSECTION, and the routines it omits come from the generic C. An exclusion pattern was not enough either: `!builtins/arm/*vfp.S` misses `save_vfp_d8_d15_regs.S`. ## Measured Both build for all seven M-profile rows. A `printf("%.2f")` program built against them plus `cortex-m-rt` boots on QEMU's `mps2-an385`, prints `13.00` and exits 0 — and the same source without the feature fails at `'stdio.h' file not found`, which is the zero-libc tier behaving as documented. Both tarballs verified against their bytes and re-fetched from the CN mirror, byte-identical. Index lints pass.
1 parent daa40fd commit f3df5f5

2 files changed

Lines changed: 127 additions & 0 deletions

File tree

pkgs/c/compiler-rt-builtins.lua

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
-- The compiler-rt builtins as a SOURCE package.
2+
--
3+
-- ⭐ TWO PACKAGES RATHER THAN ONE, AND THE EDGE IS THE REASON. picolibc's
4+
-- `printf` formats floats through ryu, which calls routines no C library
5+
-- defines — and on rv64 a 128-bit shift the instruction set has none for. A C
6+
-- library carrying its own copy would be wrong for anyone supplying their own
7+
-- builtins; the dependency edge says the same thing and can be overridden.
8+
--
9+
-- ⚠️ AND compiler-rt DOES NOT RECOGNISE A `thumb*` TRIPLE. Configuring its own
10+
-- CMake with `thumbv6m-none-eabi` produces a build tree with NO builtins target
11+
-- at all: cmake succeeds, ninja reports "no work to do", and the failure
12+
-- surfaces later as a missing file. A source package has no archive to name and
13+
-- no triple to translate.
14+
package = {
15+
spec = "1",
16+
namespace = "mcpplibs",
17+
name = "compiler-rt-builtins",
18+
description = "The compiler-rt builtins as a source package: the routines a compiler emits calls to, compiled with the consuming program's own flags",
19+
licenses = {"Apache-2.0 WITH LLVM-exception"},
20+
repo = "https://github.com/mcpplibs/compiler-rt-builtins",
21+
type = "package",
22+
23+
xpm = {
24+
linux = {
25+
["22.1.8"] = {
26+
url = {
27+
GLOBAL = "https://github.com/mcpplibs/compiler-rt-builtins/archive/refs/tags/22.1.8.tar.gz",
28+
CN = "https://gitcode.com/mcpp-res/compiler-rt-builtins/releases/download/22.1.8/compiler-rt-builtins-22.1.8.tar.gz",
29+
},
30+
sha256 = "fe00cb58128c00a3a47483f30a828bed52f4a35529c1bb0d4cb8f0376c9c492d",
31+
},
32+
},
33+
macosx = {
34+
["22.1.8"] = {
35+
url = {
36+
GLOBAL = "https://github.com/mcpplibs/compiler-rt-builtins/archive/refs/tags/22.1.8.tar.gz",
37+
CN = "https://gitcode.com/mcpp-res/compiler-rt-builtins/releases/download/22.1.8/compiler-rt-builtins-22.1.8.tar.gz",
38+
},
39+
sha256 = "fe00cb58128c00a3a47483f30a828bed52f4a35529c1bb0d4cb8f0376c9c492d",
40+
},
41+
},
42+
windows = {
43+
["22.1.8"] = {
44+
url = {
45+
GLOBAL = "https://github.com/mcpplibs/compiler-rt-builtins/archive/refs/tags/22.1.8.tar.gz",
46+
CN = "https://gitcode.com/mcpp-res/compiler-rt-builtins/releases/download/22.1.8/compiler-rt-builtins-22.1.8.tar.gz",
47+
},
48+
sha256 = "fe00cb58128c00a3a47483f30a828bed52f4a35529c1bb0d4cb8f0376c9c492d",
49+
},
50+
},
51+
},
52+
53+
-- The package's own manifest, inside the tarball's wrap directory.
54+
mcpp = "*/mcpp.toml",
55+
}

pkgs/p/picolibc.lua

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
-- picolibc as a SOURCE package: compiled with the consuming program's own flags.
2+
--
3+
-- ⭐⭐ THERE IS NO MULTILIB HERE, AND THAT IS WHY IT IS A SOURCE PACKAGE.
4+
--
5+
-- A prebuilt C library ships one build per ABI a target table can name — seven
6+
-- for Cortex-M alone — and every consumer then finds the right one through a
7+
-- `libdir` convention that must match the payload byte for byte. That
8+
-- convention is what #481 was filed about, and on ARM it cannot work at all:
9+
-- the key `<march>/<mabi>` does not separate the float ABI, because `mabi`
10+
-- there names the procedure call standard and is `aapcs` either way.
11+
--
12+
-- Measured while building the prebuilt (`xim:picolibc-arm`, which remains
13+
-- published and is NOT the route): the seven profiles collapsed into five
14+
-- directories and the soft-float row received a library carrying
15+
-- `Tag_ABI_HardFP_use`. Nothing failed at build time.
16+
--
17+
-- ⚠️ AND THE HEADERS WERE NEVER PER-PROFILE. Measured across those seven
18+
-- builds, the whole include tree — `picolibc.h` and `newlib.h`, which meson
19+
-- GENERATES, included — is byte-identical. The prebuilt ships seven copies of
20+
-- one directory.
21+
--
22+
-- ⭐ Compiled with the SAME `compile_flags` as the program consuming it, ABI
23+
-- agreement holds by construction rather than by a naming convention, and the
24+
-- version lands in `mcpp.lock` rather than being pinned inside a target table.
25+
--
26+
-- ⚠️ `picocrt` IS DELIBERATELY ABSENT. A startup object decides where execution
27+
-- begins and how it reaches the host — which board is running. Choosing among
28+
-- picolibc's nine variants is a board-support package's job; `cortex-m-rt`
29+
-- supplies its own, including the thread-pointer initialisation without which
30+
-- a `printf` program links cleanly, runs, prints nothing and hangs.
31+
package = {
32+
spec = "1",
33+
namespace = "mcpplibs",
34+
name = "picolibc",
35+
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",
36+
licenses = {"BSD-3-Clause", "BSD-2-Clause"},
37+
repo = "https://github.com/mcpplibs/picolibc",
38+
type = "package",
39+
40+
xpm = {
41+
linux = {
42+
["1.8.12"] = {
43+
url = {
44+
GLOBAL = "https://github.com/mcpplibs/picolibc/archive/refs/tags/1.8.12.tar.gz",
45+
CN = "https://gitcode.com/mcpp-res/picolibc/releases/download/1.8.12/picolibc-1.8.12.tar.gz",
46+
},
47+
sha256 = "8f3d7a41d9981905d389b321edbfa2fac4946e5acc3a0677617b8184b21d4420",
48+
},
49+
},
50+
macosx = {
51+
["1.8.12"] = {
52+
url = {
53+
GLOBAL = "https://github.com/mcpplibs/picolibc/archive/refs/tags/1.8.12.tar.gz",
54+
CN = "https://gitcode.com/mcpp-res/picolibc/releases/download/1.8.12/picolibc-1.8.12.tar.gz",
55+
},
56+
sha256 = "8f3d7a41d9981905d389b321edbfa2fac4946e5acc3a0677617b8184b21d4420",
57+
},
58+
},
59+
windows = {
60+
["1.8.12"] = {
61+
url = {
62+
GLOBAL = "https://github.com/mcpplibs/picolibc/archive/refs/tags/1.8.12.tar.gz",
63+
CN = "https://gitcode.com/mcpp-res/picolibc/releases/download/1.8.12/picolibc-1.8.12.tar.gz",
64+
},
65+
sha256 = "8f3d7a41d9981905d389b321edbfa2fac4946e5acc3a0677617b8184b21d4420",
66+
},
67+
},
68+
},
69+
70+
-- The package's own manifest, inside the tarball's wrap directory.
71+
mcpp = "*/mcpp.toml",
72+
}

0 commit comments

Comments
 (0)