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

GCC Cross Compiler Strip #109295

Open
teburd opened this issue Jan 13, 2021 · 11 comments
Open

GCC Cross Compiler Strip #109295

teburd opened this issue Jan 13, 2021 · 11 comments
Labels
0.kind: bug Something is broken 6.topic: cross-compilation Building packages on a different platform than they will be used on

Comments

@teburd
Copy link
Contributor

teburd commented Jan 13, 2021

Describe the bug
Currently cross compiler toolchains using gcc set dontStrip = true. This leads to larger closures, especially for C++ projects targeting other architectures using musl as the libc.

To Reproduce
Steps to reproduce the behavior:

  1. build any software with crossSystem set to a different target arch, see gcc has -debug added, and all debug symbols
  2. If you choose musl and build a C++ project you'll see the unexpected closure contained glib through the debug symbols and musl -dev package containing scripts pointing to bash which needs glibc.

Expected behavior

  1. Only build -debug variant when override is set
  2. Not have stray references to glibc from musl-dev (this can be done by setting dontPatchShebangs in musl's build)

Additional context
The root of the problem seems to stem from strip.sh using the same strip binary for both libraries and binaries, where in a cross compiler toolchain what probably should happen is the target strip should be used against libraries, and the host strip should be used against binaries.

Notify maintainers
@Synthetica9

@teburd teburd added the 0.kind: bug Something is broken label Jan 13, 2021
@veprbl veprbl added the 6.topic: cross-compilation Building packages on a different platform than they will be used on label Jan 13, 2021
@teburd
Copy link
Contributor Author

teburd commented Jan 13, 2021

I'm happy to sponsor a fix for this if its reasonable!

@teburd
Copy link
Contributor Author

teburd commented Jan 21, 2021

@matthewbauer thought you might be interested in this one

@matthewbauer
Copy link
Member

Yeah! So I can definitely merge #108060, but you're right that it doesn't actually strip true cross-compilation.

@Ericson2314 originally introduced the TARGET_STRIP & STRIP distinction. It's possible we can just set "stripped" always to true, but I would want to make sure we aren't running "strip" on the wrong things.

@Ericson2314
Copy link
Member

Yeah TARGET_STRIP & STRIP was something I made for this purpose, but never found time to put it at the test. At this point, I rather invest in the real solution which is building GCC itself and the target libraries separately. This will improve and simplify things on so many levels.

@stale
Copy link

stale bot commented Jul 26, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 26, 2021
@teburd
Copy link
Contributor Author

teburd commented Jul 27, 2021

Not stale

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 27, 2021
@stale
Copy link

stale bot commented Apr 30, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Apr 30, 2022
@teburd
Copy link
Contributor Author

teburd commented May 2, 2022

Not Stale, Still Relevant

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label May 2, 2022
@Mindavi
Copy link
Contributor

Mindavi commented Jun 24, 2022

I thought this was done to prevent broken binaries, since (IIRC correctly) ARM binaries were sometimes broken when stripped. But maybe the situation has improved?

@minijackson
Copy link
Member

So I tried cross-compiling a minimal all-stripped armv7l NixOS image and tested it a bit on a Raspberry PI 2, and it boots and works without any issue. Note that comments in compilers' default.nix state:

Strip kills static libs of other archs (hence no cross)

I'm not sure how to test that.

@trofi
Copy link
Contributor

trofi commented Jul 22, 2022

Possible fix for cross-compiler stripping: #182513

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: cross-compilation Building packages on a different platform than they will be used on
Projects
None yet
Development

No branches or pull requests

7 participants