From 630cc3185d03c0cf2c03866d90d1d7f5dbb8de99 Mon Sep 17 00:00:00 2001 From: sergio Date: Fri, 19 Jun 2026 00:00:12 -0400 Subject: [PATCH] recipes/linux: WIP kernel 6.16.12 desde fuente (frente kernel-from-source) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Arranque del último frente de soberanía del bootstrap: construir el kernel que bootea la VM del selfhost-verify (hoy importado pinned). Versión 6.16.12 (coherente con recipes/linux-headers.toml). Estado: defconfig + ajustes monolíticos (e1000/overlay/userns =y, BTF/firma off, frame-pointer unwinder). deps.build=[flex,bison,m4] (materializados como capa overlay en /usr). flex/bison YA funcionan: kconfig parsea y asm-offsets se genera. BLOQUEO confirmado: tools/objtool necesita libelf (gelf.h) — en x86_64 las mitigaciones seleccionan CONFIG_OBJTOOL aunque se use frame-pointer. PRÓXIMO PASO: recipes/elfutils.toml (libelf) como dep.build → completa el bzImage. Luego: KERNEL= ./scripts/selfhost-verify.sh debe dar ✓ REPRODUCIBLE (iterar la config hasta que el builder bootee). CC=gcc/HOSTCC=gcc (zig miscompila binarios grandes; el kernel es el mayor). Co-Authored-By: Claude Opus 4.8 (1M context) --- recipes/linux.toml | 53 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 recipes/linux.toml diff --git a/recipes/linux.toml b/recipes/linux.toml new file mode 100644 index 00000000..4efe4f40 --- /dev/null +++ b/recipes/linux.toml @@ -0,0 +1,53 @@ +# Linux kernel 6.16.12 — frente kernel-from-source (soberanía del bootstrap). +# +# Hoy la VM del selfhost-verify bootea un kernel importado pinned (/boot/vmlinuz-linux del host). Esta +# receta lo construye desde fuente con hammer: el último eslabón del bootstrap que no era hammer-built. +# Misma versión que recipes/linux-headers.toml (6.16.12) ⇒ coherencia headers↔kernel. +# +# Criterio de éxito: el bzImage hammer-built bootea el builder de selfhost-verify y la corrida da +# ✓ REPRODUCIBLE (KERNEL= ./scripts/selfhost-verify.sh). +# +# Compilador: CC=gcc/HOSTCC=gcc (NO zig) — el kernel es el binario más grande del lab y zig 0.16 +# miscompila binarios grandes (lesson binutils/python/cmake/flex); el kernel se compila con la GNU +# toolchain estándar (gcc + binutils as/ld del toolchain). No es input del 4/4 (es el kernel que +# BOOTEA la VM, no algo que el 4/4 enlace), así que el compilador da igual mientras el kernel bootee. +# +# Config: defconfig x86_64 (base PC booteable en QEMU: 8250 serial, initrd, PCI) + ajustes monolíticos +# - E1000/OVERLAY_FS/USER_NS =y (built-in): el builder usa e1000 (vendoring) + overlay (sandbox bwrap) +# + user namespaces (bwrap). Built-in ⇒ sin inyección de .ko ni version-magic. +# - MODULE_SIG/DEBUG_INFO_BTF off: evitan openssl (firma) y pahole (BTF), ausentes del toolchain. +# - UNWINDER_FRAME_POINTER en vez de ORC: reduce el uso de objtool, PERO no lo elimina — en x86_64 +# las mitigaciones (RETHUNK / retpoline-validation) seleccionan CONFIG_OBJTOOL igual, y objtool +# necesita libelf (gelf.h). [CONFIRMADO 2026-06-19: el build falla en tools/objtool con "gelf.h: +# No such file or directory".] PRÓXIMO PASO: recipes/elfutils.toml (libelf) como dep.build — es la +# única pieza que falta para el bzImage. flex/bison/m4 YA funcionan (kconfig parsea, asm-offsets +# se genera). [WIP: esta receta aún no produce el bzImage hasta wirear libelf.] + +name = "linux" +version = "6.16.12" + +[source] +tarball = "https://mirrors.edge.kernel.org/pub/linux/kernel/v6.x/linux-6.16.12.tar.gz" +sha256 = "ffc6af80b014ddebd55e116aa29a9f7a5256c87a29a8a9dd97270b6d49625109" + +[build] +compiler = "zig-cc" +target = "x86_64-linux-musl" +link = "dynamic" + +[deps] +# flex (lexer kconfig) + bison (parser kconfig) + m4 (bison lo invoca en runtime). Se materializan como +# capa overlay en /usr (binarios en /usr/bin, skeletons de bison en /usr/share/bison). +build = ["flex", "bison", "m4"] + +[build.phases] +configure = """ +make ARCH=x86_64 defconfig && \ +scripts/config -d MODULE_SIG -d MODULE_SIG_ALL -d DEBUG_INFO_BTF -d DEBUG_INFO \ + -d UNWINDER_ORC -e UNWINDER_FRAME_POINTER \ + -e BLK_DEV_INITRD -e DEVTMPFS -e DEVTMPFS_MOUNT -e TMPFS \ + -e E1000 -e OVERLAY_FS -e USER_NS -e NAMESPACES && \ +make ARCH=x86_64 olddefconfig +""" +compile = "make ARCH=x86_64 CC=gcc HOSTCC=gcc -j\"$(nproc)\" bzImage" +install = "mkdir -p /out/boot && cp arch/x86/boot/bzImage /out/boot/bzImage && cp .config /out/boot/config-6.16.12"