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*: force building a cross compiler if host and target platform differ #123419

Merged
merged 1 commit into from
May 17, 2021

Conversation

sternenseemann
Copy link
Member

gcc's configure system has the nasty habit (for us) of judging for
itself if it is building a cross compiler (or cross compiling), but on
the limited information of the build, host and target platforms' config
which only contains a subset of the information we encode in
stdenv.*Platform. The practical consequence was that prior to this
change building pkgsLLVM.buildPackages.gcc actually fails because it
refuses to use --with-headers with something it believes to not be a
cross compiler.

As a workaround we force the appropriate variable in the configure
script to always be yes regardless of its own conditional check.

At some point we probably should report this issue in some capacity, so
future gcc versions don't force us into workarounds like this and
acdc783.

Now the following works which failed pretty early previously (on staging):

nix-build -A pkgsLLVM.buildPackages.gcc
/nix/store/v3rrxn542209lqzwb4yhyj6zwi1shskb-x86_64-unknown-linux-gnu-stage-final-gcc-wrapper-10.3.0
Motivation for this change
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • 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 nixpkgs-review --run "nixpkgs-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.

gcc's configure system has the nasty habit (for us) of judging for
itself if it is building a cross compiler (or cross compiling), but on
the limited information of the build, host and target platforms' config
which only contains a subset of the information we encode in
`stdenv.*Platform`. The practical consequence was that prior to this
change building `pkgsLLVM.buildPackages.gcc` actually fails because it
refuses to use `--with-headers` with something it believes to not be a
cross compiler.

As a workaround we force the appropriate variable in the configure
script to always be `yes` regardless of its own conditional check.

At some point we probably should report this issue in some capacity, so
future gcc versions don't force us into workarounds like this and
acdc783.
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 10.rebuild-linux: 1 labels May 17, 2021
@Ericson2314
Copy link
Member

Nice! I had to refresh myself as to why the other GCC prefix PR didn't do the trick, but it makes total sense now that I read both. Thanks!

@sternenseemann
Copy link
Member Author

sternenseemann commented May 17, 2021

Nice! I had to refresh myself as to why the other GCC prefix PR didn't do the trick, but it makes total sense now that I read both. Thanks!

Exactly, the other PR did fix gccCrossStageStatic which did not pass --with-headers in the first place, so the issue fixed here never occured.

@Ericson2314 Ericson2314 merged commit 6ad0e5c into NixOS:master May 17, 2021
@sternenseemann sternenseemann deleted the gcc-native-cross branch May 17, 2021 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 10.rebuild-linux: 1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants