Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zfs: strip debug symbols (closure size) #141942

Merged
merged 1 commit into from
Oct 17, 2021
Merged

zfs: strip debug symbols (closure size) #141942

merged 1 commit into from
Oct 17, 2021

Conversation

Mic92
Copy link
Member

@Mic92 Mic92 commented Oct 17, 2021

Since we enabled BTF the zfs module size became significantly larger due to included debug symbols.

Closure size changes on my system when upgrading:

initrd-linux: -12427.8 KiB
linux: -12419.3 KiB
nc2k9ym14spzz2pgq6hn84k8k9zgf686: ∅ → ε, +102451.2 KiB
nixos-system-turingmachine: 21.11.20211015.a2dcfa2 → 21.11.20211017.c6f77b7
visjwxsjqmh8c9lxnrxsw5w19zszflm6: ε → ∅, -102451.0 KiB
zfs-kernel: -12419.3 KiB

Fixes #140851

Motivation for this change
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

initrd-linux: -12427.8 KiB
linux: -12419.3 KiB
nc2k9ym14spzz2pgq6hn84k8k9zgf686: ∅ → ε, +102451.2 KiB
nixos-system-turingmachine: 21.11.20211015.a2dcfa2 → 21.11.20211017.c6f77b7
visjwxsjqmh8c9lxnrxsw5w19zszflm6: ε → ∅, -102451.0 KiB
zfs-kernel: -12419.3 KiB
@alyssais
Copy link
Member

How come the normal strip hook wasn't catching this?

@alyssais
Copy link
Member

Oh, I guess because it gets compressed?

Copy link
Member

@alyssais alyssais left a comment

Choose a reason for hiding this comment

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

Excellent, back down to the size it was before.

@Mic92 Mic92 merged commit 091567a into NixOS:master Oct 17, 2021
@Mic92 Mic92 deleted the zfs-size branch October 17, 2021 11:54
Comment on lines +143 to +146
postBuild = optionalString buildKernel ''
find . -name "*.ko" -print0 | xargs -0 -P$NIX_BUILD_CORES strip --strip-debug
'';

Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer a comment here explaining why this is necessary

@@ -140,6 +140,10 @@ let
"INSTALL_MOD_PATH=\${out}"
];

postBuild = optionalString buildKernel ''
find . -name "*.ko" -print0 | xargs -0 -P$NIX_BUILD_CORES strip --strip-debug
Copy link
Member

Choose a reason for hiding this comment

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

Is it guaranteed that NIX_BUILD_CORES will always be non-empty? Otherwise this might be better:

Suggested change
find . -name "*.ko" -print0 | xargs -0 -P$NIX_BUILD_CORES strip --strip-debug
find . -name "*.ko" -print0 | xargs -0 -P''${NIX_BUILD_CORES:-1} strip --strip-debug

Copy link
Member

Choose a reason for hiding this comment

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

@ju1m
Copy link
Contributor

ju1m commented Oct 28, 2021

AFAICS this PR has broken pkgsCross.armv7l-hf-multiplatform.linuxPackages_latest.zfs because strip cannot be found:

make[3]: Leaving directory '/nix/store/7vl0711545a8ayb1psgc18av6pszk4ya-linux-armv7l-unknown-linux-gnueabihf-5.14.14-dev/lib/modules/5.14.14/build'
make[2]: Leaving directory '/build/source/module'
make[2]: Entering directory '/build/source'
[ -x ./scripts/zfs-tests.sh ] && \
    ./scripts/zfs-tests.sh -c
Missing helper script common.sh
make[2]: [Makefile:1485: all-local] Error 1 (ignored)
make[2]: Leaving directory '/build/source'
make[1]: Leaving directory '/build/source'
xargs: strip: No such file or directory

@jonringer
Copy link
Contributor

strip should be present, if it's not, then that's more of an issue with pkgsCross.

@martinetd
Copy link
Member

This hardcodes strip but you should not use strip directly.
the kernel makefile defines $(STRIP) to $(CROSS)strip e.g. arm-linux-gnueabihf-strip

@ju1m
Copy link
Contributor

ju1m commented Oct 29, 2021

@martinetd thanks, using ${stdenv.cc.targetPrefix}strip works better:

$ du -hc $(readlink -e result)/**/*.ko*
5,0K    /nix/store/56ah9x6xr7g9gy8j03b2xwfjxclr640x-zfs-kernel-2.1.1-5.14.14-armv7l-unknown-linux-gnueabihf/lib/modules/5.14.14/extra/avl/zavl.ko.xz
97K     /nix/store/56ah9x6xr7g9gy8j03b2xwfjxclr640x-zfs-kernel-2.1.1-5.14.14-armv7l-unknown-linux-gnueabihf/lib/modules/5.14.14/extra/icp/icp.ko.xz
61K     /nix/store/56ah9x6xr7g9gy8j03b2xwfjxclr640x-zfs-kernel-2.1.1-5.14.14-armv7l-unknown-linux-gnueabihf/lib/modules/5.14.14/extra/lua/zlua.ko.xz
21K     /nix/store/56ah9x6xr7g9gy8j03b2xwfjxclr640x-zfs-kernel-2.1.1-5.14.14-armv7l-unknown-linux-gnueabihf/lib/modules/5.14.14/extra/nvpair/znvpair.ko.xz
37K     /nix/store/56ah9x6xr7g9gy8j03b2xwfjxclr640x-zfs-kernel-2.1.1-5.14.14-armv7l-unknown-linux-gnueabihf/lib/modules/5.14.14/extra/spl/spl.ko.xz
33K     /nix/store/56ah9x6xr7g9gy8j03b2xwfjxclr640x-zfs-kernel-2.1.1-5.14.14-armv7l-unknown-linux-gnueabihf/lib/modules/5.14.14/extra/unicode/zunicode.ko.xz
25K     /nix/store/56ah9x6xr7g9gy8j03b2xwfjxclr640x-zfs-kernel-2.1.1-5.14.14-armv7l-unknown-linux-gnueabihf/lib/modules/5.14.14/extra/zcommon/zcommon.ko.xz
809K    /nix/store/56ah9x6xr7g9gy8j03b2xwfjxclr640x-zfs-kernel-2.1.1-5.14.14-armv7l-unknown-linux-gnueabihf/lib/modules/5.14.14/extra/zfs/zfs.ko.xz
157K    /nix/store/56ah9x6xr7g9gy8j03b2xwfjxclr640x-zfs-kernel-2.1.1-5.14.14-armv7l-unknown-linux-gnueabihf/lib/modules/5.14.14/extra/zstd/zzstd.ko.xz
1,3M    total

I've submitted #143539 for merging that fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ZFS kernel modules have ballooned in size
7 participants