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

chromium: Strip with --strip-unneeded to reduce binary size. #64427

Closed
wants to merge 1 commit into from

Conversation

ambrop72
Copy link
Contributor

@ambrop72 ambrop72 commented Jul 7, 2019

Motivation for this change

I noticed that the size of chromium-unwrapped derivation (323 MiB) is much more than the size of google-chrome-stable (207 MiB). The majority of this difference comes from the binary size (232 MiB vs 142 MiB). I found that stripping with --strip-unneeded (instead of --strip-debug / -S which is the default in the strip hook) reduces the derivation size to 258 MiB and the binary size to 168 MiB (which is still larger than in google-chrome-stable though).

I could not find an explanation regarding what --strip-unneeded removes in addition to debug symbols (does anyone know?), but the browser still works. It might make sense to consider stripping this way by default for all packages.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@7c6f434c
Copy link
Member

7c6f434c commented Jul 8, 2019 via email

@cleverca22
Copy link
Contributor

cleverca22 commented Jul 8, 2019

https://github.com/cleverca22/thermostat_firmware/blob/master/Makefile#L24-L29
https://github.com/cleverca22/thermostat_firmware/blob/master/Makefile#L55-L56
these are some commands i was using back when every single byte in my ELF file mattered, and i needed to know where it was all going
if you revert back to the x86 version of the tools (size, nmandobjdump`), you could get a report of where all of the size within each chromium binary is going, and where they differ

@ambrop72
Copy link
Contributor Author

ambrop72 commented Jul 8, 2019

Found this:
https://www.technovelty.org/linux/stripping-shared-libraries.html
https://www.debian.org/doc/debian-policy/ch-files.html#binaries

Apparently, --strip-unneeded is the right thing to do for both libraries and executables. I haven't managed to figure out what extra stuff gets stripped compared to --strip-debug though.

I'm going to change the default to --strip-unneeded and do a rebuild of my system to see if anything breaks and how it affects the closure size.

@ambrop72
Copy link
Contributor Author

Closing in favor of #64540.

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.

None yet

4 participants