Skip to content

Conversation

@tlaurion
Copy link
Collaborator

@tlaurion tlaurion commented Jul 30, 2025

TODO:


  • bumps musl-cross-make to latest commit, bump gcc 9.4.0 -> 15.1.0; rename/bump kexec-tools to latest version + gcc 15.1.0, switch/patch modules to switch from -Os to -Oz

TLDR: 1.44% space reduction (115kb gain)

Stats from global to specifics:

coreboot final stiching stats diff

"/home/user/heads/build/x86/coreboot-24.12/EOL_x230-hotp-maximized/cbfstool" "/home/user/heads/build/x86/coreboot-24.12/EOL_x230-hotp-maximized/coreboot.rom" print
FMAP REGION: COREBOOT
Name                           Offset     Type           Size   Comp
cbfs_master_header             0x0        cbfs header        32 none
cpu_microcode_blob.bin         0x80       microcode       26624 none
fallback/romstage              0x68c0     stage          107512 none
fallback/ramstage              0x20d40    stage          149993 LZMA (324488 decompressed)
config                         0x45780    raw              3521 LZMA (11135 decompressed)
revision                       0x46580    raw               724 none
build_info                     0x46880    raw               101 none
bootsplash.jpg                 0x46940    bootsplash      43282 none
fallback/dsdt.aml              0x51280    raw             14748 none
vbt.bin                        0x54c80    raw              1433 LZMA (4281 decompressed)
cmos_layout.bin                0x55280    cmos_layout      2012 none
fallback/postcar               0x55ac0    stage           40156 none
fallback/payload               0x5f800    simple elf    7908858 none
(empty)                        0x7ea640   null          4048740 none
bootblock                      0xbc6dc0   bootblock       36864 none

Master:

Jul 28 03:19:40 EOL_x230-hotp-maximized/util/cbfstool/cbfstool EOL_x230-hotp-maximized/coreboot.rom print -r COREBOOT
Jul 28 03:19:40 FMAP REGION: COREBOOT
Jul 28 03:19:40 Name                           Offset     Type           Size   Comp
Jul 28 03:19:40 cbfs_master_header             0x0        cbfs header        32 none
Jul 28 03:19:40 cpu_microcode_blob.bin         0x80       microcode       26624 none
Jul 28 03:19:40 fallback/romstage              0x68c0     stage          107512 none
Jul 28 03:19:40 fallback/ramstage              0x20d40    stage          149982 LZMA (324488 decompressed)
Jul 28 03:19:40 config                         0x45780    raw              3521 LZMA (11135 decompressed)
Jul 28 03:19:40 revision                       0x46580    raw               724 none
Jul 28 03:19:40 build_info                     0x46880    raw               101 none
Jul 28 03:19:40 bootsplash.jpg                 0x46940    bootsplash      43282 none
Jul 28 03:19:40 fallback/dsdt.aml              0x51280    raw             14748 none
Jul 28 03:19:40 vbt.bin                        0x54c80    raw              1433 LZMA (4281 decompressed)
Jul 28 03:19:40 cmos_layout.bin                0x55280    cmos_layout      2012 none
Jul 28 03:19:40 fallback/postcar               0x55ac0    stage           40156 none
Jul 28 03:19:40 fallback/payload               0x5f800    simple elf    8024362 none
Jul 28 03:19:40 (empty)                        0x806980   null          3933220 none
Jul 28 03:19:40 bootblock                      0xbc6dc0   bootblock       36864 none

Analysis:

  • gain (emtpy comparison) = 4048740 - 3933220 = 115520 bytes

sizes.txt comparison (diff -u master pr)

--- /tmp/master_sizes.txt       2025-07-27 23:19:45.000000000 -0400
+++ build/x86/EOL_x230-hotp-maximized/sizes.txt 2025-07-30 12:22:53.607423022 -0400
-2025-07-28 03:11:34+00:00 652eff3d831aaf195825e55903cbc4fab67d4a56 clean
- 2822912:/root/heads/build/x86/EOL_x230-hotp-maximized/bzImage
-  930816:/root/heads/build/x86/EOL_x230-hotp-maximized/modules.cpio
+2025-07-30 16:19:56+00:00 b5a94d5488287500316e4de1072a6fba41d593b9 clean
+ 2798032:/home/user/heads/build/x86/EOL_x230-hotp-maximized/bzImage
+  928256:/home/user/heads/build/x86/EOL_x230-hotp-maximized/modules.cpio
[...]
-13865984:/root/heads/build/x86/EOL_x230-hotp-maximized/tools.cpio
+13262336:/home/user/heads/build/x86/EOL_x230-hotp-maximized/tools.cpio
[...]
-  434176:/root/heads/build/x86/EOL_x230-hotp-maximized/heads.cpio
+  434176:/home/user/heads/build/x86/EOL_x230-hotp-maximized/heads.cpio
[...]
- 2508800:/root/heads/build/x86/EOL_x230-hotp-maximized/data.cpio
+ 2508800:/home/user/heads/build/x86/EOL_x230-hotp-maximized/data.cpio
[...]
- 5212160:build/x86/EOL_x230-hotp-maximized/initrd.cpio.xz
+ 5121536:build/x86/EOL_x230-hotp-maximized/initrd.cpio.xz

Analysis:

  • initrd.cpio.xz (concatenated+compressed cpio) reduced by 90,624 bytes (compression gains maybe suboptimal?)
    • modules.cpio (kernel modules) reduced by 2,560 bytes
    • tools.cpio (compiled libs/bins) reduced by 603,648 bytes
  • bzImage (kernel) reduced by 24,880 bytes

TLDR:

  • Master Heads payload: 8,035,072 bytes (7.66 MB)
  • PR Heads payload: 7,919,568 bytes (7.55 MB)
    Total Savings: 115,504 bytes (1.44% reduction)

Continues #590

@tlaurion tlaurion changed the title Agressive optimization for space (-Os -> -Oz): musl-cross-make-> bump to gcc 15.1.0 & related changes Further optimization for space (-Os -> -Oz): musl-cross-make-> bump to gcc 15.1.0 & related changes Aug 9, 2025
@tlaurion tlaurion marked this pull request as draft August 14, 2025 16:26
@tlaurion tlaurion force-pushed the musl-cross-make_gcc_15.1.0-Optimized_for_space-Oz branch from 69ab1d1 to c19ab15 Compare August 19, 2025 20:14
@tlaurion
Copy link
Collaborator Author

tlaurion commented Jan 5, 2026

This PR will be needed soon, since xx20 (t420/x220) are near space exhaustion (less than 100kb free left) as can be seen at #2041 (comment) : the t420-hotp-maximized rom has 67kb free left in CBFS region.

Introduce validation to ensure coreboot CBFS size matches IFD BIOS region:

- Add bin/validate_cbfs_ifd_fit.sh: New script to validate CBFS size against
  Intel Flash Descriptor (IFD) BIOS region and provide space usage statistics
- Add Makefile targets: validate_cbfs_ifd and fix_cbfs_ifd for manual validation
  and automatic fixes
- Integrate validation into coreboot module build process to catch misconfigs
  at compile time
- Add validation to final ROM image generation step
- Add informational hint to Makefile when V=1 verbose flag is not set

This prevents shipping firmware with CBFS sizes that exceed the available
BIOS region, catching configuration errors early in the build process.

Signed-off-by: Thierry Laurion <[email protected]>
@tlaurion
Copy link
Collaborator Author

tlaurion commented Jan 5, 2026

This PR will be needed soon, since xx20 (t420/x220) are near space exhaustion (less than 100kb free left) as can be seen at #2041 (comment) : the t420-hotp-maximized rom has 67kb free left in CBFS region.

For the t420-hotp-maximized in this pr, CBFS free space is 209 KiB :)

"/home/user/heads/build/x86/coreboot-25.09/EOL_t420-hotp-maximized/cbfstool" "/home/user/heads/build/x86/coreboot-25.09/EOL_t420-hotp-maximized/coreboot.rom" print
FMAP REGION: COREBOOT
Name                           Offset     Type           Size   Comp
cbfs_master_header             0x0        cbfs header        32 none
cpu_microcode_blob.bin         0x80       microcode       26624 none
fallback/romstage              0x68c0     stage          101016 none
fallback/ramstage              0x1f3c0    stage          151145 LZMA (323316 decompressed)
config                         0x44280    raw              3526 LZMA (11252 decompressed)
revision                       0x45080    raw               766 none
build_info                     0x453c0    raw               101 none
bootsplash.jpg                 0x45480    bootsplash      43282 none
fallback/dsdt.aml              0x4fdc0    raw             14520 none
vbt.bin                        0x536c0    raw              1368 LZMA (3985 decompressed)
cmos.default                   0x53c80    cmos_default      256 none
cmos_layout.bin                0x53dc0    cmos_layout      2120 none
fallback/postcar               0x54640    stage           31180 none
fallback/payload               0x5c080    simple elf    7571488 none
(empty)                        0x794900   null           214180 none
bootblock                      0x7c8dc0   bootblock       28672 none

Validating final CBFS/IFD configuration...
===================================================================
IFD vs CBFS Size Validation
===================================================================
IFD BIOS Region: 0x00018000 - 0x007fffff
IFD BIOS Size:   0x7E8000 (8096 KiB)
CONFIG_CBFS_SIZE: 0x7E7FFF (8095 KiB)

✓ CONFIG_CBFS_SIZE fits within IFD BIOS region
   Unused IFD capacity: 1 bytes (< 1 KiB)

CBFS Free Space: 214180 bytes (209 KiB)

===================================================================
✓ Validation complete
===================================================================

@tlaurion
Copy link
Collaborator Author

tlaurion commented Jan 5, 2026

https://app.circleci.com/pipelines/github/tlaurion/heads/3449/workflows/6b0bd1cc-8d3f-43f4-b176-1c4f6435a36b/jobs/76833/parallel-runs/0/steps/0-102?invite=true#step-102-2244532_182

2d073289ba2bb5ba6be6650c055928faf8020931f61eeb35c1b3bfe3625f55b8 /root/heads/build/x86/EOL_x220-hotp-maximized/heads-EOL_x220-hotp-maximized-v0.2.0-2902-g6b403e0.rom

Local build:

2d073289ba2bb5ba6be6650c055928faf8020931f61eeb35c1b3bfe3625f55b8 /home/user/heads/build/x86/EOL_x220-hotp-maximized/heads-EOL_x220-hotp-maximized-v0.2.0-2902-g6b403e0.rom

Builds are reproducible if built clean (./docker_repro.sh make BOARD=xyz real.clean && make BOARD=xyz )

@tlaurion tlaurion marked this pull request as ready for review January 5, 2026 16:47
Copilot AI review requested due to automatic review settings January 5, 2026 16:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades the Heads build toolchain from GCC 9.4.0 to GCC 15.1.0 and systematically switches compiler optimization flags from -Os (optimize for size) to -Oz (optimize aggressively for size) across 30+ modules. The changes deliver a 1.44% space reduction (115 KB) in the final firmware payload through improved compiler optimization and enhanced binary stripping.

Key changes include:

  • GCC toolchain upgrade via musl-cross-make bump to latest commit with GCC 15.1.0
  • C23 compatibility patches for multiple modules (tpmtotp, powerpc-utils, bash, e2fsprogs, gpg2, cairo, linux kernel)
  • Systematic -Os to -Oz optimization flag conversion across all modules
  • New CBFS/IFD validation script with automatic size fixing capability
  • Module version bumps: kexec-tools (2.0.26→2.0.31), dropbear (2016.74→2025.88)
  • Enhanced Makefile with GPG injection caching and improved stripping flags
  • Disabled features in OpenSSL and LVM2 for additional space savings

Reviewed changes

Copilot reviewed 59 out of 60 changed files in this pull request and generated 13 comments.

Show a summary per file
File Description
modules/musl-cross-make Bumps commit hash and GCC version from 9.4.0 to 15.1.0 with upgrade notes
patches/musl-cross-make-3635262e4524c991552789af6f36211a335a77b3/0001-use-gcc-15_1_0.patch Updates musl-cross-make Makefile to use GCC 15.1.0
patches/tpmtotp-4d63d21c8b7db2e92ddb393057f168aead147f47/*.patch Three patches fixing GCC 15.1.0 compatibility issues (function signatures, printf formats, AES macro)
patches/powerpc-utils-1.3.5/0001-fix-rtas-function-pointer-signatures-gcc15.patch Fixes function pointer declarations for C23 compatibility
patches/kexec-tools-2.0.31/*.patch Six patches for kexec-tools 2.0.31: disables unused modules, improves framebuffer support, adds EBDA workaround, fixes purgatory build, uses build compiler for utils, adds x86-64 baseline flags
patches/lvm2-2.03.23.patch Adds libgen.h include for basename() function required by GCC 15.1.0
patches/linux-6.6.16-openpower/0008-powerpc-boot-Fix-C23-bool-compatibility-for-GCC-15.patch Adds -std=gnu11 to PowerPC boot Makefile for C23 bool keyword conflicts
patches/dropbear-2025.88/0001-disable-fatal-user-group-change-errors-for-heads-environment.patch Updates patch paths for dropbear 2025.88 source tree restructuring
patches/coreboot-talos_2/0003-ugly_skiboot-patch_fix_for_newer_gcc_from_musl_125.patch Adds additional GCC 15.1.0 warning suppressions for skiboot (-Wno-error=unterminated-string-initialization, -Wno-error=misleading-indentation)
patches/bash-5.1.16.patch Adds unistd.h include to lib/termcap/tparam.c for write() declaration
modules/kexec Deleted - replaced by modules/kexec-tools
modules/kexec-tools New module file for kexec-tools 2.0.31 with -Oz optimization
modules/dropbear Updates to version 2025.88 with additional configure options for space savings
modules/openssl Switches to -Oz and disables additional protocols/algorithms (dtls, ec2m, engine, gost, md2, srp, ssl3, tls1, tls1_1)
modules/lvm2 Switches to -Oz and disables advanced features (thin, cache, VDO, writecache, integrity, snapshots, mirrors)
modules/linux Adds -std=gnu11 flag and PowerPC-specific GCC 15.1.0 compatibility flags
modules/bash Changes to -Oz with -std=gnu11 for C23 compatibility
modules/cairo Changes to -Oz with -std=gnu11, -Wno-inline, -Wno-incompatible-pointer-types
modules/coreboot Adds validation script calls and extensive GCC 15.1.0 compatibility documentation
modules/e2fsprogs Changes to -Oz with -std=gnu11 for C23 bool keyword conflicts
modules/gpg2 Changes to -Oz with -std=gnu11 and adds -DDISABLE_PHOTO_VIEWER
modules/libgcrypt Changes to -Oz and disables jent-support
modules/zstd, modules/util-linux, modules/tpmtotp, modules/qrencode, modules/powerpc-utils, modules/pixman, modules/pinentry, modules/newt, modules/ncurses, modules/mbedtls, modules/libusb-compat, modules/libusb, modules/libpng, modules/libnitrokey, modules/libksba, modules/libhidapi-libusb, modules/libgpg-error, modules/libassuan, modules/kbd, modules/ioport, modules/io386, modules/gpg, modules/flashtools, modules/flashrom, modules/flashprog, modules/fbwhiptail, modules/exfatprogs, modules/cryptsetup2, modules/cryptsetup All changed from -Os to -Oz optimization
bin/validate_cbfs_ifd_fit.sh New validation script that checks CONFIG_CBFS_SIZE against IFD BIOS region with auto-fix capability
Makefile Adds validation targets, enhances strip flags (--strip-all), implements GPG injection caching, adds verbose build hints, fixes kexec module reference, adds coreboot cbmem GCC 15.1.0 compatibility flag
Comments suppressed due to low confidence (2)

patches/dropbear-2025.88/0001-disable-fatal-user-group-change-errors-for-heads-environment.patch:1

  • The patch header line references the old path "dropbear-2016.74" but this module is being updated to "dropbear-2025.88". The patch should use paths that match the new version to avoid confusion during patch application.
    patches/dropbear-2025.88/0001-disable-fatal-user-group-change-errors-for-heads-environment.patch:12
  • Commenting out the dropbear_exit calls when setgid/initgroups or setuid fail means the server will continue executing the user session even if it could not drop privileges to ses.authstate.pw_uid/pw_gid, so a user who authenticated as an unprivileged account could end up with a shell running under the original (likely root) UID/GID. This silently bypasses the operating system’s privilege separation mechanisms and can turn any failure in the privilege-dropping path (for example due to security policy or environment issues) into a remote privilege escalation to the Dropbear daemon’s UID. The fix is to keep these failures fatal (e.g., by retaining dropbear_exit or otherwise aborting the session) so that no user commands are executed when user/group changes fail.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +192 to +201
echo ""; \
echo "Validating CONFIG_CBFS_SIZE vs IFD BIOS region..."; \
$(pwd)/bin/validate_cbfs_ifd_fit.sh \
--coreboot-dir "$(build)/$(coreboot_dir)" \
--board-dir "$(build)/$(BOARD)" \
--config "$(pwd)/$(CONFIG_COREBOOT_CONFIG)" \
|| exit 1; \
echo ""
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The validation script is called twice during the build: once at configuration time (lines 193-199) and once after the build (lines 273-278). Both calls use || exit 1 which will cause the build to fail if validation fails. However, the first call (at configuration time) checks before coreboot is built, when cbfstool and ifdtool don't exist yet. The script handles this by returning exit code 0 when tools are missing, but this makes the || exit 1 pattern misleading. Consider documenting why the validation is called twice, or restructuring to only validate when tools are definitely available.

Copilot uses AI. Check for mistakes.
Comment on lines +1 to +24
From 14f48ea80e510e5af79ca6c46fa28e99a3695d1c Mon Sep 17 00:00:00 2001
From: Ross Lagerwall <[email protected]>
Date: Thu, 17 Apr 2025 09:31:40 +0100
Subject: [PATCH] x86_64: Use the x86-64 level for purgatory

The compiler may be configured by default to use a newer
microarchitecture level such as x86-64-v3. Set purgatory to compile
using the baseline x86-64 level since the environment isn't set up
correctly to use SSE and AVX instructions. At the same time, be a bit
paranoid and add some additional flags to ensure that the compiler
doesn't use any such instructions.

Signed-off-by: Ross Lagerwall <[email protected]>
Signed-off-by: Simon Horman <[email protected]>
---
--- a/purgatory/arch/x86_64/Makefile 2025-08-11 16:40:00.000000000 +0000
+++ b/purgatory/arch/x86_64/Makefile 2025-08-11 16:40:00.000000000 +0000
@@ -24,5 +24,5 @@ x86_64_PURGATORY_SRCS += purgatory/arch/i386/vga.c
x86_64_PURGATORY_SRCS += purgatory/arch/i386/pic.c

ifneq ($(SUBARCH),x32)
-x86_64_PURGATORY_EXTRA_CFLAGS = -mcmodel=large
+x86_64_PURGATORY_EXTRA_CFLAGS = -mcmodel=large -march=x86-64 -mno-mmx -mno-sse -mno-sse2 -mno-avx
endif
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The patch comment mentions "GCC 15.10" but the PR description and other patches consistently reference GCC 15.1.0. This appears to be a typo where "15.10" should be "15.1.0".

Copilot uses AI. Check for mistakes.
@@ -0,0 +1,27 @@
modules-$(CONFIG_KEXEC) += kexec-tools

kexec-tools_version := 2.0.31
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description mentions "rename/bump kexec-tools to latest version + gcc 15.10" but kexec-tools is being set to version 2.0.31 (released in 2024). According to the kernel.org repository, version 2.0.31 is not the latest version - version 2.0.32 was released in December 2024. Consider bumping to 2.0.32 if compatible, or clarify in the PR description that 2.0.31 was chosen intentionally.

Copilot uses AI. Check for mistakes.
Comment on lines +4 to +8
dropbear_version := 2025.88
dropbear_dir := dropbear-$(dropbear_version)
dropbear_tar := dropbear-$(dropbear_version).tar.bz2
dropbear_url := https://mirror.dropbear.nl/mirror/releases/$(dropbear_tar)
dropbear_hash := 2720ea54ed009af812701bcc290a2a601d5c107d12993e5d92c0f5f81f718891
dropbear_url := https://matt.ucc.asn.au/dropbear/releases/$(dropbear_tar)
dropbear_hash := 783f50ea27b17c16da89578fafdb6decfa44bb8f6590e5698a4e4d3672dc53d4
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropbear is being updated from version 2016.74 (released in July 2016) to version 2025.88 (released in April 2025), which is a major version jump spanning 9 years. This is a significant upgrade that likely includes many changes. While the space optimization goals are met, ensure that:

  1. The patch for disabling user/group change errors still applies correctly to the new source code structure
  2. All Heads-specific configurations remain compatible with the new version
  3. Testing has been performed to verify SSH/SCP functionality still works as expected

The patch shows the file path changed from dropbear-2016.74/svr-chansession.c to src/svr-chansession.c, indicating a source tree restructuring. Verify the patch applies cleanly.

Copilot uses AI. Check for mistakes.
Comment on lines 8 to 10
# - Converts void (*)() to properly typed function pointers:
# * int (*)(int, int, ...) for variadic RTAS calls
# * int (*)(int, int, int, int *, int *, int *) for specific RTAS calls
Copy link

Copilot AI Jan 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment describes function pointer types but contains inaccuracies. The actual patch (lines 17-19 in the patch file) shows the function pointers are converted to:

  • void *(*parse_rtas_event)(char *, int)
  • void (*rtas_print_event)(FILE *, void *, int)
  • void (*cleanup_rtas_event)(void *)

However, the comment in lines 8-10 claims they are converted to types with "int" return values and different signatures. The comment should accurately reflect what the patch actually does.

Copilot uses AI. Check for mistakes.
@tlaurion tlaurion marked this pull request as draft January 5, 2026 17:16
tlaurion added a commit to tlaurion/heads that referenced this pull request Jan 5, 2026
Upgrade from 5.1.16 (Jan 2022) to 5.3 (Jul 2025). The newer version doesn't
require patches - it already includes proper C header handling and the -std=gnu11
workaround is no longer needed thanks to upstream fixes.

Ref: GCC 15.1.0 upgrade (PR linuxboot#1991)
tlaurion added a commit to tlaurion/heads that referenced this pull request Jan 5, 2026
…for 6.1.8 only

Remove duplication of EXTRA_FLAGS definition across kernel versions. Define
base flags once (-fdebug-prefix-map, -gno-record-gcc-switches), then
conditionally add -std=gnu11 only for kernel 6.1.8 which requires GCC 15.1
C23 compatibility workaround. Other kernel versions (4.14.62, 4.19.139,
5.4.69, 5.10.214, 6.6.16-openpower) compile without workaround flags.

Ref: GCC 15.1.0 upgrade (PR linuxboot#1991)

Signed-off-by: Thierry Laurion <[email protected]>
tlaurion added a commit to tlaurion/heads that referenced this pull request Jan 5, 2026
Upgrade from 2.03.23 (Nov 2023) to 2.03.25 (Jul 2024). The newer version
removes the libgen.h issue that required a GCC 15.1.0 workaround patch.

However, GCC 15.1.0's C23 mode enforces const qualifiers on stdin/stdout/stderr,
which breaks lvm2's reopen_standard_stream() calls. Port the working patch from
lvm2-2.03.23 in osresearch/heads master branch (commit 63290d6) to 2.03.25.

The patch wraps problematic memory allocation and log10() calls in #if 0 blocks
to disable them at compile-time, maintaining compatibility with musl-libc and
C23 standard enforcement.

Changes:
- Bump lvm2 from 2.03.23 to 2.03.25
- Update hash to 4bea6fd2e5af9cdb3e27b48b4efa8d89210d9bfa13df900e092e404720a59b1d
- Replace -Os with -Oz for space optimization
- Port lvm2-2.03.23.patch to lvm2-2.03.25.patch for C23 compatibility
- Remove obsolete lvm2-gcc-15.1-libgen.patch

Tested: EOL_x220-hotp-maximized board builds successfully with 182 KiB free CBFS

Ref: GCC 15.1.0 upgrade (PR linuxboot#1991)
Signed-off-by: Thierry Laurion <[email protected]>
tlaurion added a commit to tlaurion/heads that referenced this pull request Jan 5, 2026
Upgrade from 5.1.16 (Jan 2022) to 5.3 (Jul 2025). The newer version doesn't
require patches - it already includes proper C header handling and the -std=gnu11
workaround is no longer needed thanks to upstream fixes.

Ref: GCC 15.1.0 upgrade (PR linuxboot#1991)
Signed-off-by: Thierry Laurion <[email protected]>
tlaurion added a commit to tlaurion/heads that referenced this pull request Jan 5, 2026
…for 6.1.8 only

Remove duplication of EXTRA_FLAGS definition across kernel versions. Define
base flags once (-fdebug-prefix-map, -gno-record-gcc-switches), then
conditionally add -std=gnu11 only for kernel 6.1.8 which requires GCC 15.1
C23 compatibility workaround. Other kernel versions (4.14.62, 4.19.139,
5.4.69, 5.10.214, 6.6.16-openpower) compile without workaround flags.

Ref: GCC 15.1.0 upgrade (PR linuxboot#1991)

Signed-off-by: Thierry Laurion <[email protected]>
tlaurion added a commit to tlaurion/heads that referenced this pull request Jan 5, 2026
Upgrade from 2.03.23 (Nov 2023) to 2.03.25 (Jul 2024). The newer version
removes the libgen.h issue that required a GCC 15.1.0 workaround patch.

However, GCC 15.1.0's C23 mode enforces const qualifiers on stdin/stdout/stderr,
which breaks lvm2's reopen_standard_stream() calls. Port the working patch from
lvm2-2.03.23 in osresearch/heads master branch (commit 63290d6) to 2.03.25.

The patch wraps problematic memory allocation and log10() calls in #if 0 blocks
to disable them at compile-time, maintaining compatibility with musl-libc and
C23 standard enforcement.

Changes:
- Bump lvm2 from 2.03.23 to 2.03.25
- Update hash to 4bea6fd2e5af9cdb3e27b48b4efa8d89210d9bfa13df900e092e404720a59b1d
- Replace -Os with -Oz for space optimization
- Port lvm2-2.03.23.patch to lvm2-2.03.25.patch for C23 compatibility
- Remove obsolete lvm2-gcc-15.1-libgen.patch

Tested: EOL_x220-hotp-maximized board builds successfully with 182 KiB free CBFS

Ref: GCC 15.1.0 upgrade (PR linuxboot#1991)
Signed-off-by: Thierry Laurion <[email protected]>
@tlaurion tlaurion force-pushed the musl-cross-make_gcc_15.1.0-Optimized_for_space-Oz branch from a6f1917 to f547ef2 Compare January 5, 2026 20:37
tlaurion and others added 7 commits January 5, 2026 15:49
For KVM/QEMU boards, cache source/key hashes in a .meta file to skip repeated
injections when inputs are unchanged. Default SRC_SHA256/KEY_SHA256 to empty if
the meta file lacks them (or sourcing fails) before comparing hashes to avoid
false negatives.

Signed-off-by: Thierry Laurion <[email protected]>
….1.0 (in the goal of using gcc 12+ -Oz instead of -Os for more agressive optimization for space)

Signed-off-by: Thierry Laurion <[email protected]>
… (purgatory cannot be built with i386; do 2.0.31(latest) + missing patch)

Signed-off-by: Thierry Laurion <[email protected]>
…ility fixes

This commit upgrades the cross-compilation toolchain from GCC 9.4.0 to GCC 15.1.0
and implements systematic compatibility fixes across the codebase.

**Core Changes:**
- modules/musl-cross-make: Update to commit 3635262e (GCC 15.1.0 toolchain)
- Systematic conversion from -Os to -Oz optimization across 33+ modules
- Added comprehensive C23 compatibility fixes for affected modules

**C23 Standard Compatibility Fixes:**
- modules/linux: Added -std=gnu11 to resolve bool/false keyword conflicts
- modules/gpg2: Added -std=gnu11 to resolve true keyword conflicts
- modules/bash: Added -std=gnu11 + patched tparam.c for unistd.h include
- modules/e2fsprogs: Added -std=gnu11 to resolve bool typedef conflicts

**Header Include Fixes:**
- patches/lvm2-2.03.23.patch: Added libgen.h include for basename() function
- patches/bash-5.1.16.patch: Added unistd.h include for write() function

**Compiler Flag Adjustments:**
- modules/cairo: Added -Wno-inline and -Wno-incompatible-pointer-types for -Oz
- Makefile: Added -Wno-unterminated-string-initialization for cbmem utility

**Optimization Improvements:**
- Converted CFLAGS from -Os to -Oz in 33+ modules for better size optimization
- All modules: cryptsetup, flashrom, gpg, libgcrypt, ncurses, util-linux, etc.

**Documentation & Future Maintenance:**
- Added unified TODO_GCC_15_* comments across all modified modules
- Created doc/GCC_15_UPGRADE_SUMMARY.md for tracking changes
- Created doc/GCC_15_COMPATIBILITY_TEMPLATE.md for future upgrades
- All compatibility fixes documented with removal conditions

**Build Validation:**
- Full build testing completed successfully
- All modules compile cleanly with GCC 15.1.0
- Cross-compiler toolchain verified functional
- Systematic C23 compatibility approach established

This upgrade enables modern GCC optimizations while maintaining compatibility
with current module versions. All changes include TODO comments for easy
removal when modules are updated to support C23 natively.

Co-authored-by: GitHub Copilot <[email protected]>
Signed-off-by: Thierry Laurion <[email protected]>
…being added to cpio then initrd.cpio.xz

Signed-off-by: Thierry Laurion <[email protected]>
…e fixes to comply with gcc 15.1+

Signed-off-by: Thierry Laurion <[email protected]>
….patch individual patch files

Signed-off-by: Thierry Laurion <[email protected]>
• Upgrade from 2016.74 to 2025.88 for GCC 15.1.0 compatibility
• Apply extensive configure optimizations to minimize feature set:
  --disable-lastlog, --disable-syslog, --disable-utmp, --disable-utmpx,
  --disable-wtmp, --disable-wtmpx, --disable-loginfunc, --disable-pututline,
  --disable-pututxline, --disable-openpty, --disable-shadow
• Restore critical security patch for Heads embedded environment:
  Comment out fatal user/group change errors that legitimately fail in firmware
• Organize patches under patches/dropbear-2025.88/ directory structure
• Size impact: +89KB (185KB→274KB dropbear, 23KB→27KB scp)
  Trade-off necessary for security updates and compiler compatibility

Signed-off-by: Thierry Laurion <[email protected]>
…c algorithms

Reduce OpenSSL libcrypto.so.3 size by 103KB (3.1%) through aggressive
algorithm disabling via configure flags. Removed unused cryptographic
algorithms while maintaining compatibility with TPM2-TSS requirements.

Disabled algorithms:
- Legacy ciphers: DES, RC2/RC4, IDEA, Blowfish, CAST
- Hash functions: MD2/MD4/MD5, RIPEMD160, Whirlpool
- Modern algorithms: ChaCha20, Poly1305, ARIA, Camellia
- Elliptic curves: EC2M curves, SM2/SM4 Chinese algorithms
- Key exchange: DH, DSA, SRP, GOST
- Protocol versions: SSL 3.0, TLS 1.0/1.1
- Advanced features: OCB, SIV, CMAC, BLAKE2, engines

Size impact:
- libcrypto.so.3: 3,280,536 → 3,177,880 bytes (-103KB, -3.1%)
- tools.cpio total: ~621KB cumulative savings vs master

Maintains required algorithms for TPM2 operations (SHA, AES, SM3).

Signed-off-by: Thierry Laurion <[email protected]>
…tion

Further optimize LVM2 by disabling unused features:
- --with-snapshots=none: Disable snapshot support
- --with-mirrors=none: Disable mirror support
- --disable-udev_rules: Disable udev integration
- --disable-pkgconfig: Disable pkgconfig support
- --disable-nls: Disable internationalization

Results (stripped binary sizes):
- lvm: 2,140,888 → 2,132,376 bytes (-8,512 bytes)
- dmsetup: 110,936 bytes (unchanged)
- Total LVM2 optimization: 51,976 bytes saved

These flags safely remove functionality not needed by Heads
while maintaining essential device-mapper capabilities required
by cryptsetup for disk encryption support.

Signed-off-by: Thierry Laurion <[email protected]>
…tion

Algorithm-specific optimization targeting only required cryptographic functions:
- Ciphers: aes des chacha20 (for GPG2 and factory reset)
- Public key: rsa ecc (RSA keys and ECDSA/ECDH nistp256)
- Digests: sha1 sha256 sha512 blake2 (essential hash functions)

Space reduction:
- Baseline (stripped): 814,928 bytes
- Optimized (stripped): 497,504 bytes
- Space saved: 317,424 bytes (310KB)
- Reduction: 38.9%

Excluded unused algorithms:
- Symmetric: arcfour blowfish cast5 twofish serpent rfc2268 seed camellia idea salsa20 gost28147 sm4
- Digests: crc gostr3411-94 md4 md5 rmd160 sha3 tiger whirlpool stribog sm3
- Public key: dsa elgamal

Hardware acceleration preserved for optimal performance.
Maintains full functionality for GPG2 operations and factory reset key generation.

Signed-off-by: GitHub Copilot <[email protected]>
Signed-off-by: Thierry Laurion <[email protected]>
Optimized libgcrypt with -Oz optimization:
- Stripped size: 564,192 bytes (551KB)
- Significant improvement over master baseline
- All algorithms enabled for full compatibility

Baseline measurements:
- Master baseline: 1,198,224 bytes (1.17MB)
- Current (-Oz): 564,192 bytes (551KB)
- Space saved: 634,032 bytes (619KB) - 53% reduction!
- Previous attempt: 497,504 bytes (restricted algorithms, GPG broken)

This provides a solid optimized baseline for further systematic algorithm
optimization while maintaining full functionality for GPG2, factory reset,
and cryptsetup2. The -Oz flag alone provides massive space savings.

Signed-off-by: GitHub Copilot <[email protected]>
Signed-off-by: Thierry Laurion <[email protected]>
…-gcc15.patch: function pointers need proper signatures to match their actual usage

modules/powerpc-utils contains docs traces in regard of gcc15 requirements

Signed-off-by: Thierry Laurion <[email protected]>
…atch_fix_for_newer_gcc_from_musl_125.patch: add patches needed for skiboot to be compiled in little-endian by heads boostrapped gcc15.1 compiler

Signed-off-by: Thierry Laurion <[email protected]>
Introduce validation to ensure coreboot CBFS size matches IFD BIOS region:

- Add bin/validate_cbfs_ifd_fit.sh: New script to validate CBFS size against
  Intel Flash Descriptor (IFD) BIOS region and provide space usage statistics
- Add Makefile targets: validate_cbfs_ifd and fix_cbfs_ifd for manual validation
  and automatic fixes
- Integrate validation into coreboot module build process to catch misconfigs
  at compile time
- Add validation to final ROM image generation step
- Add informational hint to Makefile when V=1 verbose flag is not set

This prevents shipping firmware with CBFS sizes that exceed the available
BIOS region, catching configuration errors early in the build process.

Signed-off-by: Thierry Laurion <[email protected]>
- Cairo version bump will require Meson buildstack support since version 1.16.0. At time of writing, Cairo is 1.18.4

Signed-off-by: Thierry Laurion <[email protected]>
tlaurion added a commit to tlaurion/heads that referenced this pull request Jan 5, 2026
Upgrade from 5.1.16 (Jan 2022) to 5.3 (Jul 2025). The newer version doesn't
require patches - it already includes proper C header handling and the -std=gnu11
workaround is no longer needed thanks to upstream fixes.

Ref: GCC 15.1.0 upgrade (PR linuxboot#1991)
Signed-off-by: Thierry Laurion <[email protected]>
tlaurion added a commit to tlaurion/heads that referenced this pull request Jan 5, 2026
…for 6.1.8 only

Remove duplication of EXTRA_FLAGS definition across kernel versions. Define
base flags once (-fdebug-prefix-map, -gno-record-gcc-switches), then
conditionally add -std=gnu11 only for kernel 6.1.8 which requires GCC 15.1
C23 compatibility workaround. Other kernel versions (4.14.62, 4.19.139,
5.4.69, 5.10.214, 6.6.16-openpower) compile without workaround flags.

Ref: GCC 15.1.0 upgrade (PR linuxboot#1991)

Signed-off-by: Thierry Laurion <[email protected]>
tlaurion added a commit to tlaurion/heads that referenced this pull request Jan 5, 2026
Upgrade from 2.03.23 (Nov 2023) to 2.03.25 (Jul 2024). The newer version
removes the libgen.h issue that required a GCC 15.1.0 workaround patch.

However, GCC 15.1.0's C23 mode enforces const qualifiers on stdin/stdout/stderr,
which breaks lvm2's reopen_standard_stream() calls. Port the working patch from
lvm2-2.03.23 in osresearch/heads master branch (commit 63290d6) to 2.03.25.

The patch wraps problematic memory allocation and log10() calls in #if 0 blocks
to disable them at compile-time, maintaining compatibility with musl-libc and
C23 standard enforcement.

Changes:
- Bump lvm2 from 2.03.23 to 2.03.25
- Update hash to 4bea6fd2e5af9cdb3e27b48b4efa8d89210d9bfa13df900e092e404720a59b1d
- Replace -Os with -Oz for space optimization
- Port lvm2-2.03.23.patch to lvm2-2.03.25.patch for C23 compatibility
- Remove obsolete lvm2-gcc-15.1-libgen.patch

Tested: EOL_x220-hotp-maximized board builds successfully with 182 KiB free CBFS

Ref: GCC 15.1.0 upgrade (PR linuxboot#1991)
Signed-off-by: Thierry Laurion <[email protected]>
@tlaurion tlaurion force-pushed the musl-cross-make_gcc_15.1.0-Optimized_for_space-Oz branch from f547ef2 to 90edf07 Compare January 5, 2026 21:11
- Update e2fsprogs from 1.47.0 to 1.47.2 (released January 2025)
- Remove GCC 15.1 workaround flag (-std=gnu11) as newer version improves C23 compatibility
- Disable debugging, backup tools, and optional features:
  - debugfs, imager, resizer, defrag (not needed for initrd)
  - uuidd, mmp, tdb (reduces dependencies)
  - backtrace, bmap-stats (debugging features)
  - nls, rpath, fuse2fs (unnecessary for minimal build)

Reduces build time and binary size while maintaining core mke2fs functionality

Signed-off-by: Thierry Laurion <[email protected]>
Upgrade from 5.1.16 (Jan 2022) to 5.3 (Jul 2025). The newer version doesn't
require patches - it already includes proper C header handling and the -std=gnu11
workaround is no longer needed thanks to upstream fixes.

Ref: GCC 15.1.0 upgrade (PR linuxboot#1991)
Signed-off-by: Thierry Laurion <[email protected]>
…for 6.1.8 only

Remove duplication of EXTRA_FLAGS definition across kernel versions. Define
base flags once (-fdebug-prefix-map, -gno-record-gcc-switches), then
conditionally add -std=gnu11 only for kernel 6.1.8 which requires GCC 15.1
C23 compatibility workaround. Other kernel versions (4.14.62, 4.19.139,
5.4.69, 5.10.214, 6.6.16-openpower) compile without workaround flags.

Ref: GCC 15.1.0 upgrade (PR linuxboot#1991)

Signed-off-by: Thierry Laurion <[email protected]>
Upgrade from 2.03.23 (Nov 2023) to 2.03.25 (Jul 2024). The newer version
removes the libgen.h issue that required a GCC 15.1.0 workaround patch.

However, GCC 15.1.0's C23 mode enforces const qualifiers on stdin/stdout/stderr,
which breaks lvm2's reopen_standard_stream() calls. Port the working patch from
lvm2-2.03.23 in osresearch/heads master branch (commit 63290d6) to 2.03.25.

The patch wraps problematic memory allocation and log10() calls in #if 0 blocks
to disable them at compile-time, maintaining compatibility with musl-libc and
C23 standard enforcement.

Changes:
- Bump lvm2 from 2.03.23 to 2.03.25
- Update hash to 4bea6fd2e5af9cdb3e27b48b4efa8d89210d9bfa13df900e092e404720a59b1d
- Replace -Os with -Oz for space optimization
- Port lvm2-2.03.23.patch to lvm2-2.03.25.patch for C23 compatibility
- Remove obsolete lvm2-gcc-15.1-libgen.patch

Tested: EOL_x220-hotp-maximized board builds successfully with 182 KiB free CBFS

Ref: GCC 15.1.0 upgrade (PR linuxboot#1991)
Signed-off-by: Thierry Laurion <[email protected]>
…ba, libassuan

Replaces version-specific patches with build system sed commands to simplify
version upgrades. Verified identical binary output with baseline.

Changes:
- libgcrypt-1.10.1: Remove patch, use sed for hardcode_into_libs
- libksba-1.6.3: Remove patch, use sed for hardcode_into_libs
- libassuan-2.5.5: Remove patch, use sed for hardcode_into_libs
- gpg2-2.4.0: Refactor patch to only contain functional code change (ttyfp behavior)
  Move cross_compiling=yes to sed in module for future version bumps
- All modules: Add TODO comments for version bump considerations

Sed patterns follow tpm2-tss convention (simple string matching without anchors).

Build verification: EOL_x220-hotp-maximized compiles successfully with 175 KiB
free CBFS space. All GPG2 toolstack libraries built correctly with -Oz optimization.

Signed-off-by: Thierry Laurion <[email protected]>
Prior PR marked the ROM target phony to force rebuilds. The new CBFS/IFD validation already runs after the coreboot build and downstream post-processing is guarded by up-to-date checks, so letting make track the actual output avoids unnecessary rebuilds while keeping validation intact.

Signed-off-by: Thierry Laurion <[email protected]>
@tlaurion tlaurion force-pushed the musl-cross-make_gcc_15.1.0-Optimized_for_space-Oz branch from 90edf07 to f6a4e38 Compare January 6, 2026 03:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant