-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
Binaries are not stripped #21667
Comments
I believe this is only a problem/confusion in the output from |
@vcunat, no, those binaries are not stripped. Using #!/usr/bin/env nix-shell
#!nix-shell -i bash -p binutils file hello
cp -L $(which hello) .
chmod 755 hello
du -h hello
file hello
strip hello
du -h hello
file hello And this is the output: 32K hello
hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /nix/store/8lbpq1vmajrbnc96xhv84r87fa4wvfds-glibc-2.24/lib/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, not stripped
24K hello
hello: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /nix/store/8lbpq1vmajrbnc96xhv84r87fa4wvfds-glibc-2.24/lib/ld-linux-x86-64.so.2, for GNU/Linux 2.6.32, stripped Seems to be the case with all the binaries - not just hello. I just looked at |
Possibly. So far we've only been stripping debugging symbols ( For standalone executables a full strip might work, but libraries would get unusable by that AFAIK. See https://github.com/NixOS/nixpkgs/blob/master/pkgs/build-support/setup-hooks/strip.sh |
I should have looked at the source first.... Maybe @peti remembers why the "strip all" commit was reverted? Offhand it seems like running |
The history of the previous patch is in #15087. |
makepkg from archlinux has a robust implementation to strip binaries: https://git.archlinux.org/pacman.git/tree/scripts/libmakepkg/tidy/strip.sh.in It also take care of libraries and static binaries. |
I have just tried doing a rebuild of xfce with the following patch applied and it launches nicely in a VM: diff --git a/pkgs/build-support/setup-hooks/strip.sh b/pkgs/build-support/setup-hooks/strip.sh
index 6860c9b9cb..7e0098a36c 100644
--- a/pkgs/build-support/setup-hooks/strip.sh
+++ b/pkgs/build-support/setup-hooks/strip.sh
@@ -4,14 +4,14 @@ fixupOutputHooks+=(_doStrip)
_doStrip() {
if [ -z "$dontStrip" ]; then
- stripDebugList=${stripDebugList:-lib lib32 lib64 libexec bin sbin}
+ stripDebugList=${stripDebugList:-lib lib32 lib64}
if [ -n "$stripDebugList" ]; then
- stripDirs "$stripDebugList" "${stripDebugFlags:--S}"
+ stripDirs "$stripDebugList" "${stripDebugFlags:---strip-debug --strip-unneeded}"
fi
- stripAllList=${stripAllList:-}
+ stripAllList=${stripAllList:-libexec bin sbin}
if [ -n "$stripAllList" ]; then
- stripDirs "$stripAllList" "${stripAllFlags:--s}"
+ stripDirs "$stripAllList" "${stripAllFlags:---strip-all}"
fi
fi
} |
I would use |
You could also argue that executables belong in bin and libraries in lib and if that's not the case, that's a packaging bug. Unless I rebuild the entire repo I obviously cannot be sure, but isn't getting xfce running enough to show that it works? And we save quite some space (10% for the binaries in my limited testing). |
There's a PR for improving how we apply strip. #15339. |
|
@layus has clearly put in a lot more effort than me but what's your preferred approach @vcunat? This is truly a minor thing, but in any kind of shell scripting I generally use the long form of parameters passed to programs - it's far easier to remember what's going on when you're looking at it 6 months later. |
This issue and #15339 are somewhat orthogonal. #15339 ensures that we strip every file without restriction. This issue proposes to change the way we strip the current files. They are both useful, and should even be merged together to avoid two mass rebuilds. Yours is a concern of package size, and mine of closure size. Nix uses stripping to remove references to build inputs. From that point of view, stripping with As long as you do not --strip-all the shared objects, all should be fine. That being said, you will find most of the annoying packages on a server, not on a desktop. |
My preferred approach? I liked that strip-everything PR, I think, but I always feel compelled to review things thoroughly and unfortunately I like many more things than I'm able to catch (timely and at all). EDIT: and yes, I also thought these to be orthogonal :-) (I originally thought this is thread of that old PR.) |
What’s the current state of play of this and related issues ? |
Thank you for your contributions. This has been automatically marked as stale because it has had no activity for 180 days. If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity. Here are suggestions that might help resolve this more quickly:
|
I marked this as stale due to inactivity. → More info |
Issue description
I don't know if I'm missing something obvious, but the binaries are not stripped and according to the manual they should be:
hello
doesn't setdontStrip
but still the binary is not stripped:I checked on
nixos-unstable
andnixos-16.09
.Steps to reproduce
nix-env -i hello file -L $(which hello)
Technical details
The text was updated successfully, but these errors were encountered: