Skip to content

Use crosstool-ng based rootfs for net12.0 musl cross images - #1855

Open
am11 wants to merge 3 commits into
dotnet:mainfrom
am11:feature/crosstool-ng-musl
Open

am11 wants to merge 3 commits into
dotnet:mainfrom
am11:feature/crosstool-ng-musl

Conversation

@am11

@am11 am11 commented Dec 4, 2026

Copy link
Copy Markdown
Member

crosstool-ng-build-rootfs.sh --libc musl builds the rootfs with musl instead of glibc. The GCC triple uses the alpine vendor (for example x86_64-alpine-linux-musl), which is how toolchain.cmake recognizes a musl rootfs, and the rootfs gets etc/os-release with ID=alpine and a usr/bin/ldd link to musl's libc.so, which is how CMake, init-distro-rid.sh and NativeAOT detect musl.

musl versions follow the current Alpine based images: 1.2.3 by default and 1.2.5 for riscv64 and loongarch64. Table rows can now be specific to a C library (<arch>-<libc> and *-<libc>). musl uses Linux 6.1 UAPI headers because the 4.19 arm64 asm/ptrace.h pulls in asm/sigcontext.h, which redefines types that musl's bits/signal.h already defines.

The net12.0 Azure Linux 4.0 musl cross images (amd64, arm, arm64, loongarch64, riscv64) now build their rootfs with it instead of build-rootfs.sh with Alpine.

`crosstool-ng-build-rootfs.sh --libc musl` builds the rootfs with musl instead of glibc. The GCC triple uses the `alpine` vendor (for example `x86_64-alpine-linux-musl`), which is how `toolchain.cmake` recognizes a musl rootfs, and the rootfs gets `etc/os-release` with `ID=alpine` and a `usr/bin/ldd` link to musl's `libc.so`, which is how CMake, `init-distro-rid.sh` and NativeAOT detect musl.

musl versions follow the current Alpine based images: 1.2.3 by default and 1.2.5 for riscv64 and loongarch64. Table rows can now be specific to a C library (`<arch>-<libc>` and `*-<libc>`). musl uses Linux 6.1 UAPI headers because the 4.19 arm64 `asm/ptrace.h` pulls in `asm/sigcontext.h`, which redefines types that musl's `bits/signal.h` already defines.

The net12.0 Azure Linux 4.0 musl cross images (amd64, arm, arm64, loongarch64, riscv64) now build their rootfs with it instead of `build-rootfs.sh` with Alpine.

Co-authored-by: Cursor <cursoragent@cursor.com>
am11 and others added 2 commits December 4, 2026 09:46
The runtime uses the loongarch64 signal context definitions (`FPU_CTX_MAGIC`, `struct sctx_info`, `struct fpu_context`) that musl added in 1.2.6. It also matches the musl version in the current Alpine edge based loongarch64 image.

Co-authored-by: Cursor <cursoragent@cursor.com>
The strip step passed every `*.so*`, `*.a` and `*.o` file to a single `llvm-strip` call. Some of them are linker scripts (`libc.so`, `libpthread.so`, `libm.a`, ...), and `llvm-strip` stops at the first file that isn't an object, so everything after it kept its debug info. The error was hidden, and how much got stripped depended on `find` order.

Strip only ELF objects and archives instead. On Ubuntu 24.04 this takes the x64 rootfs from 200 MB to 92 MB, arm64 from 213 MB to 87 MB and riscv64 from 212 MB to 138 MB.

Co-authored-by: Cursor <cursoragent@cursor.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant