Skip to content

linux: non‐trivial builder clean‐ups - #571142

Merged
zowoq merged 5 commits into
staging-nixosfrom
wip-emily/push-wuzktvromrzp
Oct 10, 2026
Merged

zowoq merged 5 commits into
staging-nixosfrom
wip-emily/push-wuzktvromrzp

Conversation

@emilazy

@emilazy emilazy commented Oct 7, 2026

Copy link
Copy Markdown
Member

Clean up the kernel source unpacking and retained build tree in preparation for the image rebuild and deterministic module signing work.

Stacked on top of #571141.


This is part of the end‐to‐end NixOS boot security project, funded through NGI Fediversity Fund, a fund established by NLnet with financial support from the European Commission’s Next Generation Internet programme.

Things done

@nixpkgs-ci
nixpkgs-ci Bot requested review from a team, Atemu, AxerTheAxe, JerrySM64, eljamm, lovesegfault, moni-dz, pyrox0, thiagokokada, thoughtpolice and zzzsyyy and removed request for a team October 7, 2026 01:51
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1001-2500 This PR causes many rebuilds on Linux and should target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 6.topic: kernel The Linux kernel labels Oct 7, 2026
@nixpkgs-ci
nixpkgs-ci Bot requested a review from a team October 7, 2026 01:52
@emilazy
emilazy force-pushed the wip-emily/push-wuzktvromrzp branch from ea25ed1 to 6ebebc6 Compare October 7, 2026 05:03
@zowoq

zowoq commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

Seems to break some linuxPackages, e.g. zfs?

@emilazy
emilazy force-pushed the wip-emily/push-zormruotwwmw branch from 4bff6e6 to f64e61c Compare October 8, 2026 17:21
@emilazy
emilazy force-pushed the wip-emily/push-wuzktvromrzp branch from 6ebebc6 to 865e4a7 Compare October 8, 2026 17:21
@emilazy

emilazy commented Oct 8, 2026

Copy link
Copy Markdown
Member Author

Should be fixed now; KBUILD_OUTPUT was getting set to /build/build in $dev/lib/modules/…/build/Makefile.

I considered just building directly into the final build tree location (it also leaks into e.g. some Rust .rmeta files and the kernel’s debug information), which would simplify the builder logic, but it’d also slow down builds for people who configure a tmpfs Nix build directory; not sure if that’s worth it or not.

Base automatically changed from wip-emily/push-zormruotwwmw to staging-nixos October 9, 2026 00:22
@nixpkgs-ci nixpkgs-ci Bot closed this Oct 9, 2026
@nixpkgs-ci nixpkgs-ci Bot reopened this Oct 9, 2026

@nixpkgs-branch-check nixpkgs-branch-check Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The PR's base branch is set to staging-nixos, but this PR causes 1676 rebuilds.
It is therefore considered a mass rebuild.
Please change the base branch to the right base branch for your changes (probably staging).

@nixpkgs-ci nixpkgs-ci Bot added the 2.status: merge conflict This PR has merge conflicts with the target branch label Oct 9, 2026
This saves copying it after the build, and avoids issues relating
to the kernel build system recording the absolute directory of the
source tree and triggering unnecessary rebuilds when it changes.
`make clean` is [documented] to leave enough to build external modules,
which it almost does for our purposes (we also need to keep `vmlinux`
and `resolve_btfids`, and PowerPC is weird). We can avoid redundant
builds and simplify our packaging by using it and then moving the
entire build directory.

[documented]:
<https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Makefile?h=v7.2#n1982>

This also shrinks the `dev` output by dropping some intermediate
object files from `scripts/`.
This is only relevant when the `vmlinux` ELF target is used.

As before, we don’t strip the `vmlinux` in the `dev` output (which
makes it extremely huge and makes the stripping of the source tree
we do quite pointless, but that’s a matter for another day…),
as that’s a symlink since the previous commit.
The kernel has an explicit top‐level target for this file we can use
to catch the error more quickly.
@emilazy
emilazy force-pushed the wip-emily/push-wuzktvromrzp branch from 865e4a7 to cf4da14 Compare October 10, 2026 02:00
@emilazy

emilazy commented Oct 10, 2026

Copy link
Copy Markdown
Member Author

Fixed the merge conflict with #569786.

@nixpkgs-ci nixpkgs-ci Bot removed the 2.status: merge conflict This PR has merge conflicts with the target branch label Oct 10, 2026

@nixpkgs-branch-check nixpkgs-branch-check Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

The PR's base branch is set to staging-nixos, but this PR causes 1705 rebuilds.
It is therefore considered a mass rebuild.
Please change the base branch to the right base branch for your changes (probably staging).

@zowoq zowoq left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, also built the nsresourced nixosTest, a couple of aarch64 native and riscv cross kernels.

@nixpkgs-ci nixpkgs-ci Bot added 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. labels Oct 10, 2026
@zowoq
zowoq added this pull request to the merge queue Oct 10, 2026
Merged via the queue into staging-nixos with commit 72d6c69 Oct 10, 2026
33 checks passed
@zowoq
zowoq deleted the wip-emily/push-wuzktvromrzp branch October 10, 2026 23:33
@zowoq

zowoq commented Oct 10, 2026

Copy link
Copy Markdown
Contributor

The PR's base branch is set to staging-nixos, but this PR causes 1705 rebuilds. It is therefore considered a mass rebuild. Please change the base branch to the right base branch for your changes (probably staging).

I'll add an exemption for this. #572634

@OPNA2608

OPNA2608 commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Bisecting FTBFS of pkgsCross.ppc64-elfv1.linux (and linux on powerpc64-linux natively) brought me here. That platform uses vmlinux as its kernel target.

42f4cc3 fails on:

cp -rL ../scripts/gdb/ $dev/lib/modules/${modDirVersion}/build/scripts

…, ignoring that one because the next commit dropped that line.

Since 739a9b2 (b47137a does not fix this):

error: cycle detected in build of '/nix/store/ga0j9kg7dvi28kfj52zmrxd2wnnvyz3n-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55.drv' in the references of output 'dev' from output 'out'.

       Shown below are the files inside the outputs leading to the cycle:
       /nix/store/mmahy9czaj2rpcbbrqbsw4746r61f34c-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev
       └───lib/modules/6.18.55/build/vmlinux: …32.so.1.LINUX_2.6.15./nix/store/7l8ir6f5l5gpsm6mw6l22xpkqx8k6w9w-linux-powerpc64-unknown-linux-g…
           → /nix/store/7l8ir6f5l5gpsm6mw6l22xpkqx8k6w9w-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55
           └───vmlinux: …#!#$""""!!"!#"!"...../nix/store/mmahy9czaj2rpcbbrqbsw4746r61f34c-linux-powerpc64-unknown-linux-g…
               → /nix/store/mmahy9czaj2rpcbbrqbsw4746r61f34c-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev

And then at some later point, specifically pkgsCross.ppc64-elfv1.linux regressed further - some BTFIDS step errors out due to an endian mismatch between buildPlatform & hostPlatform. Bisecting that one next…

Comment on lines +327 to +331
# Apply the equivalent of upstream commit
# dda135077ecc9f15c407f094dcfe7800376be867 to older versions to
# avoid cyclic output dependency issues when building
# uncompressed kernel images.
+ lib.optionalString (lib.versionOlder version "7.0") " --remap-path-prefix=${placeholder "dev"}/lib/modules/${modDirVersion}/source/= --remap-path-scope=macro"

This comment was marked as outdated.

@OPNA2608

Copy link
Copy Markdown
Contributor
↪ strings /nix/var/nix/b/13znmgr9hk3s2gbylin96zv2b3/b/tmp.x3KPXAgSPi/vmlinux.out | grep lib/modules/6.18.55/source | head -n5
/nix/store/4fkgwzyj526q4a9hmvdg5c48x3d39bwr-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/arch/powerpc/purgatory/trampoline_64.S

This one seems to come from purgatory.ro, a binary that gets linked & embedded into the .rodata section.

https://github.com/torvalds/linux/blob/067c5c24cef23d913b67eaaf71ae67e7169a6620/arch/powerpc/purgatory/Makefile#L12

# AS      arch/powerpc/purgatory/trampoline_64.o
  /nix/store/r3lpagsqjj41m6sdrykvshcyp15p9p79-powerpc64-unknown-linux-gnuabielfv1-gcc-16.2.0/bin/powerpc64-unknown-linux-gnuabielfv1-gcc -Wp,-MMD,arch/powerpc/purgatory/.trampoline_64.o.d -nostdinc -I/nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/arch/powerpc/include -I./arch/powerpc/include/generated -I/nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/include -I./include -I/nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi -I/nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/include/uapi -I./include/generated/uapi -include /nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/include/linux/compiler-version.h -include /nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/include/linux/kconfig.h -D__KERNEL__ -mbig-endian -m64 -I /nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/arch/powerpc -DHAVE_AS_ATHIGH=1 -fmacro-prefix-map=/nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/= -D__ASSEMBLY__ -fno-PIE -m64 -mcpu=power4 -mabi=elfv2 -mbig-endian -g -Wa,--fatal-warnings -I/nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/arch/powerpc/purgatory -Iarch/powerpc/purgatory    -DKBUILD_MODFILE='"arch/powerpc/purgatory/trampoline_64"' -DKBUILD_MODNAME='"trampoline_64"' -D__KBUILD_MODNAME=kmod_trampoline_64 -c -o arch/powerpc/purgatory/trampoline_64.o /nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/arch/powerpc/purgatory/trampoline_64.S 
# cmd_gen_symversions_S arch/powerpc/purgatory/trampoline_64.o
  if /nix/store/wzsyzdz8c331f5p385qrhwxl9iq96p4q-powerpc64-unknown-linux-gnuabielfv1-gcc-wrapper-16.2.0/bin/powerpc64-unknown-linux-gnuabielfv1-nm arch/powerpc/purgatory/trampoline_64.o 2>/dev/null | grep -q ' __export_symbol_'; then { echo "#include <linux/kernel.h>" ; echo "#include <linux/string.h>" ; echo "#include <asm/asm-prototypes.h>" ; /nix/store/wzsyzdz8c331f5p385qrhwxl9iq96p4q-powerpc64-unknown-linux-gnuabielfv1-gcc-wrapper-16.2.0/bin/powerpc64-unknown-linux-gnuabielfv1-nm arch/powerpc/purgatory/trampoline_64.o | sed -n 's/.* __export_symbol_\(.*\)/EXPORT_SYMBOL(\1);/p' ; } | /nix/store/r3lpagsqjj41m6sdrykvshcyp15p9p79-powerpc64-unknown-linux-gnuabielfv1-gcc-16.2.0/bin/powerpc64-unknown-linux-gnuabielfv1-gcc -E -D__GENKSYMS__ -Wp,-MMD,arch/powerpc/purgatory/.trampoline_64.o.d -nostdinc -I/nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/arch/powerpc/include -I./arch/powerpc/include/generated -I/nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/include -I./include -I/nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/arch/powerpc/include/uapi -I./arch/powerpc/include/generated/uapi -I/nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/include/uapi -I./include/generated/uapi -include /nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/include/linux/compiler-version.h -include /nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/include/linux/kconfig.h -include /nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/include/linux/compiler_types.h -D__KERNEL__ -mbig-endian -m64 -I /nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/arch/powerpc -DHAVE_AS_ATHIGH=1 -fmacro-prefix-map=/nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/= -std=gnu11 -fshort-wchar -funsigned-char -fno-common -fno-PIE -fno-strict-aliasing -msoft-float -mtraceback=no -mabi=elfv2 -mcmodel=medium -mno-pointers-to-nested-functions -mlong-double-128 -mcpu=power4 -mtune=power10 -mno-prefixed -mno-pcrel -mno-altivec -mno-vsx -mno-mma -fno-asynchronous-unwind-tables -mno-string -mbig-endian -fno-delete-null-pointer-checks -O2 -fno-allow-store-data-races -fstack-protector-strong -ftrivial-auto-var-init=zero -fzero-init-padding-bits=all -fno-stack-clash-protection -pg -fmin-function-alignment=4 -fstrict-flex-arrays=3 -fno-strict-overflow -fno-stack-check -fconserve-stack -fno-builtin-wcslen -Wall -Wextra -Wundef -Werror=implicit-function-declaration -Werror=implicit-int -Werror=return-type -Werror=strict-prototypes -Wno-format-security -Wno-trigraphs -Wno-frame-address -Wno-address-of-packed-member -Wmissing-declarations -Wmissing-prototypes -Wframe-larger-than=2048 -Wno-main -Wno-dangling-pointer -Wvla-larger-than=1 -Wno-pointer-sign -Wcast-function-type -Wno-unterminated-string-initialization -Wno-array-bounds -Wno-stringop-overflow -Wno-alloc-size-larger-than -Wimplicit-fallthrough=5 -Werror=date-time -Werror=incompatible-pointer-types -Werror=designated-init -Wenum-conversion -Wunused -Wno-unused-but-set-variable -Wno-unused-const-variable -Wno-packed-not-aligned -Wno-format-overflow -Wno-format-truncation -Wno-stringop-truncation -Wno-override-init -Wno-missing-field-initializers -Wno-type-limits -Wno-shift-negative-value -Wno-maybe-uninitialized -Wno-sign-compare -Wno-unused-parameter -g -DGCC_PLUGINS -mstack-protector-guard=tls -mstack-protector-guard-reg=r13 -mstack-protector-guard-offset=1144 -Werror -Wa,--fatal-warnings -I/nix/store/kdqiifrni8yqq7lkv1515cnn5sm6j8gw-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55-dev/lib/modules/6.18.55/source/arch/powerpc/purgatory -Iarch/powerpc/purgatory    -DKBUILD_MODFILE='"arch/powerpc/purgatory/trampoline_64"' -DKBUILD_BASENAME='"trampoline_64"' -DKBUILD_MODNAME='"trampoline_64"' -D__KBUILD_MODNAME=kmod_trampoline_64 -xc - | ./scripts/genksyms/genksyms    >> arch/powerpc/purgatory/.trampoline_64.o.cmd; fi
# cmd_gen_order arch/powerpc/purgatory/modules.order
  {  :; } > arch/powerpc/purgatory/modules.order
# LD      arch/powerpc/purgatory/purgatory.ro
  /nix/store/q641f5lysgganlbs5ljqgf57zwgp8bxs-powerpc64-unknown-linux-gnuabielfv1-binutils-2.46/bin/powerpc64-unknown-linux-gnuabielfv1-ld -EB -m elf64ppc -z noexecstack --no-warn-rwx-segments  -e purgatory_start -r --no-undefined arch/powerpc/purgatory/trampoline_64.o -o arch/powerpc/purgatory/purgatory.ro

Extracting that from vmlinux and running it through file & objdump shows:

/dev/shm/vmlinux-purgatory.ro: ELF 64-bit MSB relocatable, 64-bit PowerPC or cisco 7500, Unspecified or Power ELF V1 ABI, version 1 (SYSV), with debug_info, not stripped
Contents of section .debug_str:
 0000 2f6e6978 2f73746f 72652f34 666b6777  /nix/store/4fkgw
 0010 7a796a35 32367134 6139686d 76646735  zyj526q4a9hmvdg5
 0020 63343878 33643339 6277722d 6c696e75  c48x3d39bwr-linu
 0030 782d706f 77657270 6336342d 756e6b6e  x-powerpc64-unkn
 0040 6f776e2d 6c696e75 782d676e 75616269  own-linux-gnuabi
 0050 656c6676 312d362e 31382e35 352d6465  elfv1-6.18.55-de
 0060 762f6c69 622f6d6f 64756c65 732f362e  v/lib/modules/6.
 0070 31382e35 352f736f 75726365 2f617263  18.55/source/arc
 0080 682f706f 77657270 632f7075 72676174  h/powerpc/purgat
 0090 6f72792f 7472616d 706f6c69 6e655f36  ory/trampoline_6
 00a0 342e5300 2f627569 6c642f62 75696c64  4.S./build/build
 00b0 00474e55 20415320 322e3436 00        .GNU AS 2.46.   
Contents of section .debug_line_str:
 0000 2f627569 6c642f62 75696c64 002f6e69  /build/build./ni
 0010 782f7374 6f72652f 34666b67 777a796a  x/store/4fkgwzyj
 0020 35323671 34613968 6d766467 35633438  526q4a9hmvdg5c48
 0030 78336433 39627772 2d6c696e 75782d70  x3d39bwr-linux-p
 0040 6f776572 70633634 2d756e6b 6e6f776e  owerpc64-unknown
 0050 2d6c696e 75782d67 6e756162 69656c66  -linux-gnuabielf
 0060 76312d36 2e31382e 35352d64 65762f6c  v1-6.18.55-dev/l
 0070 69622f6d 6f64756c 65732f36 2e31382e  ib/modules/6.18.
 0080 35352f73 6f757263 652f6172 63682f70  55/source/arch/p
 0090 6f776572 70632f70 75726761 746f7279  owerpc/purgatory
 00a0 00747261 6d706f6c 696e655f 36342e53  .trampoline_64.S
 00b0 00                                   .               

Same issue with the embedded 32-bit & 64-bit vDSO solibs:

/dev/shm/vmlinux-vdso32.so.1: ELF 32-bit MSB shared object, PowerPC or cisco 4500, version 1 (SYSV), dynamically linked, with debug_info, not stripped
/dev/shm/vmlinux-vdso64.so.1: ELF 64-bit MSB shared object, 64-bit PowerPC or cisco 7500, OpenPOWER ELF V2 ABI, version 1 (SYSV), dynamically linked, with debug_info, not stripped

And those also have a reference to $out:

Dynamic Section:
  SONAME               linux-vdso32.so.1
  RUNPATH              /nix/store/d6rgyr2332lzadx8phxvijvc3mdwkx7k-linux-powerpc64-unknown-linux-gnuabielfv1-6.18.55/lib

@OPNA2608

Copy link
Copy Markdown
Contributor

Also affects powerpc64le-linux (pkgsCross.powernv), which is maybe a tiny bit more relevant to ppl, and avoids that endianness mismatch error on current master when doing a cross build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: kernel The Linux kernel 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 1001-2500 This PR causes many rebuilds on Linux and should target the staging branches. 10.rebuild-nixos-tests This PR causes rebuilds for all NixOS tests and should normally target the staging branches. 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants