-
-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
gcc: enable stripping for cross-compilers #182513
Conversation
Since 1ac5398 "*-wrapper; Switch from `infixSalt` to `suffixSalt`" (2020) 'TARGET_' prefix (and infix) is no more. '_FOR_TARGET' suffix is the only used suffix for target-specific tools and flags. Use that in stip instead of always-empty variable.
We will also need to run
|
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.
Some textual comments at least
1347a53
to
9ed7f3a
Compare
Fixed with setup-hooks/strip.sh: run RANLIB on static archives after stripping |
I decided to do a few more things:
|
9ed7f3a
to
9146f12
Compare
Tested on |
|
||
preFixup = '' | ||
# Populate most delicated lib/ part of stripDebugList{,Target} | ||
updateDebugListPaths() { |
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.
Did you put this into a function so that it can be re-used later in some other phase? If so I think we should use a hook instead.
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.
The function should be used only here. I used function only for local oldOpts="$(shopt -p nullglob)"
variable scoping.
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.
Would a subshell also scope it?
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.
Function's main effect is to extend variables used by a pkgs/build-support/setup-hooks/strip.sh
:
stripDebugList="$stripDebugList ''${hostFiles[*]}"
stripDebugListTarget="$stripDebugListTarget ''${targetFiles[*]}"
Thus subshell would need to be applied selectively on a subset of the function's code.
This change mimics existing strip{All,Debug}List variables to allow special stripping directories just for Target. The primary use case in mind is gcc where package has to install both host and target ELFs. They have to be stripped by their own strip tools accordingly. Co-authored-by: Rick van Schijndel <Mindavi@users.noreply.github.com> Co-authored-by: Sandro <sandro.jaeckel@gmail.com>
'strip' does not normally preserve archive index in .a files. This usually causes linking failures against static libs like: $ nix build --no-link -f. pkgsCross.mingw32.re2c > ...-i686-w64-mingw32-binutils-2.38/bin/i686-w64-mingw32-ld: /nix/store/...-i686-w64-mingw32-stage-final-gcc-13.0.0-lib/i686-w64-mingw32/lib/libstdc++.dll.a: error adding symbols: archive has no index; run ranlib to add one We restore the index by running ranlib explicitly.
With explicit support for distinction between Host and Target strip paths we can now safely strip ELF binaries with their according strip tools without fear of damaging binaries due to architecture mismatch. Closure size change for `pkgsCross.mingwW64.gcc12Stdenv.cc.cc`: # before: $ nix path-info -Sh $(nix-build -A pkgsCross.mingwW64.gcc12Stdenv.cc.cc) | unnix /<<NIX>>/x86_64-w64-mingw32-stage-final-gcc-debug-12.1.0 2.5G # after: $ nix path-info -Sh $(nix-build -A pkgsCross.mingwW64.gcc12Stdenv.cc.cc) | unnix /<<NIX>>/x86_64-w64-mingw32-stage-final-gcc-12.1.0 1.5G
a0a86b1
to
eece5d0
Compare
Description of changes
With explicit support for distinction between Host and Target libraries
we can now safely strip ELF binaries with their according strip tools
without fear of damaging binaries due to architecture mismatch (most
frequent on arm).
Closure size change for
pkgsCross.mingwW64.gcc12Stdenv.cc.cc
:Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)nixos/doc/manual/md-to-db.sh
to update generated release notes