-
-
Notifications
You must be signed in to change notification settings - Fork 14.3k
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
Just strip everything by default, fully tested version :-) #15339
Conversation
@@ -26,8 +26,8 @@ stdenv.mkDerivation { | |||
|
|||
buildInputs = [ gmp mpfr libmpc zlib ]; | |||
|
|||
# Make sure we don't strip the libraries in lib/gcc/avr. | |||
stripDebugList= [ "bin" "avr/bin" "libexec" ]; | |||
# Make sure we don't strip the libraries in lib/gcc/avr and in avr/lib. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we have a comment that explains why they shouldn't be stripped? Currently it just says the same as the definition below does
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because if stripped linking with them tends to fail, presumably because there are some functionally relevant symbols there. Can't say more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess @domenkozar's point was that the comment should say that. As it is, the comment just repeats what's written below it anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My experience is that *.o files in avr/lib make strip fail because their format is not recognised.
Only avr-strip could possibly recognise these. I will update the patch to reflect this.
Later, it may be a good idea to strip these files with avr-strip.
@ambrop72, does it make sense to you ?
Anyway, I will update the comment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@layus IIRC, I wrote that original dontStripList, not because it failed to strip, but because to broke the toolchain. Actually my experience is that "strip" doesn't particularly care about the CPU architecture, it can strip symbols from "other" architectures.
cc @edolstra |
I've got a problem in |
Ah, I think it has problems when an output is just a file directly, not a directory as usual. It tries to strip that non-ELF file and fails. |
Hmm, this is the intended behavior, except for the failing part obviously. What is the error produced by strip on that file? Also, are you sure it does not fail because of patchElf? This is the main drawback of this patch. It tries to strip everything but may fail. It replaces false positives by false negatives... |
It might be something else. No error is printed. |
Example log:
|
I have found that adding "set -x" to the preFixup hook of the derivation is very useful, but I guess you already know that. But the ultimate trick is {
# ...
preFixup = ''
set -x
export PS4='+(''${BASH_SOURCE}:''${LINENO}): ''${FUNCNAME[0]:+''${FUNCNAME[0]}(): }'
'';
} (source : http://stackoverflow.com/questions/17804007/how-to-show-line-number-when-executing-bash-script) |
Yes, I use |
Ok, I just pushed a fixup for the wrong I wont be available this weekend, and the fix has not been tested. Feel free to use it or just wait till Monday for me to test it properly. Thanks for looking into this anyway. |
This way of adding null byte seems not to work, judging from |
e2e3876
to
b2e5072
Compare
I fixed the remaining issues:
Could it be the last iteration? I hope so :-). |
@vcunat, could you give it another try ? |
if [ -n "$stripAllList" ]; then | ||
stripDirs "$stripAllList" "${stripAllFlags:--s}" | ||
if [ -n "${stripAllList:-}" ]; then | ||
stripDirs "${stripAllList:-}" "${stripAllFlags:--s}" | ||
fi | ||
fi | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nitpick: in _doStrip
I would change all :-
to -
, so that people can explicitly define those variables as empty without being overridden back to the default values. (Yes, one could define them as " "
, but it seems nicer to allow empty string as well.)
Note that otherwise e.g. the first if
will always fire, as *
is used whenever the expansion could be empty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does an empty string mean ? Strip everything or nothing ?
For now, passing an empty string to stripDirs strips nothing because it is interpreted as a gob pattern. This is why "" is replaced by "*".
If you want to disable stripping, why not use dontStrip ?
My fear is that if the variable is defined for some reason, or remains (say, from another output), the result may not be expected by the user.
I may however remove the useless if
. Would that suit you ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed the if in bda09f6.
085b004
to
bda09f6
Compare
@vcunat I just rebased everything and fixed some merge conflict. I know this is getting tedious, but could you give it another try ? |
Yeah, I'm sorry for that. This summer I've got way too many things to do and slight health problems atop. |
How about not stripping everything by default, and instead calculating dependencies on stripped binaries but keeping the originals? So build time dependencies will not be part of the dependency graph that way, hopefully. |
That's something completely different than what's addressed by this PR, as I remember it. I'm sorry, I've been swamped by other nixpkgs issues, neglecting especially more work-intensive tickets like this one. |
@wmertens Not a bad idea, but this is a drastic change in the assumptions on the nix store. Dependencies are defined as the references to the nix-store contained in the package. Changing that is way beyond the scope of this PR.
@vcunat This PR is cpu-intensive, not really work-intensive :-). Would you mind staging it again ? or dedicating a separate hydra branch to this one. I have tested as much as I could with my limited tools. I am still trying to install hydra on my server. Its tougher than one would expect :-). The issue is still present. On my current system, I get
At least mariadb, php and apache should not depend on the gcc command/wrapper. |
Run strip of each file and discard expected failure types. Also default to stripping the entire output.
We did this for 2.2 (cc61d31) but lost this for 2.4. This reduces the Apache closure size from 312 MiB to 102 MiB (primarily by getting rid of -dev outputs).
What's the status of this PR? |
I believe the status is that... I've been swamped and this "cosmetic" change (improving "only" logs) got left behind; I just haven't managed to properly review it. |
(triage) Is anyone still working or willing to work on this PR? I'd guess other people than @vcunat are able to review it? |
@FRidh @Ekleog see discussion #23648
So, it isn't an easy merge, requires time and patience. cc @infinisil |
Just closing old PRs that are too work-intensive. I guess #23648 (comment) got it quite right ;-). |
This is the same PR as #15087, but fully tested and modified to take into account the discovered bugs.
Stdenv now supports the
dontStripPath
attribute which is the black-list version of the formerstripDebugList
andstripAllList
(maintained for compatibility).These three variables now support bash globbing, as explained in the updated manual.
stripDebugList = [ "bin" "lib/libpretty.so" "modules/*.so" ]
are three valid expressions, expanded under$prefix/
.It appears that this PR can break stuff. Sometimes strip will fail with slightly different error messages than the expected ones. It seems to come from its structure, where the file type is recognised and handled by a custom handler, which in turn may fail with custom errors that we cannot (and dont want to) catch. For these cases, we will need to update the derivation wit a
dontStripList
argument. The only example of this I have encountered is swig. Some template text file presumably looks like one of the supported binary formats, but truncated. The error message is quite different from the basic truncation error.A similar issue occurred with go which ships sample binaries for testing purposes. These are allegedly ELF's, but not to
strip
's liking.Finally, I could not resist the pleasure of removing some superfluous stripDebugList's :-).
The build is successful for
nix-build -A samba -A go -A flashplayer -A mesa_noglu -A apacheHttpd -A syslinux -A avrgcclibc
, which is already a good panel of derivations. (Well, at least it takes a few hours on my quad-core, and at least one hour for gcc alone.) (BTW, the build is not successful for nss, but it's not my fault, it comes from d71a485#commitcomment-17408979, which in turn calls for a refactoring of mystripDirs
function into a generic wrapper for find, but let's leave this for later.)Closes #14821, #14822, #14823, #14824.