Skip to content

gcc: drop include-fixed/bits/statx.h#225595

Merged
1 commit merged intoNixOS:stagingfrom
trofi:gcc-no-statx-fix
Apr 11, 2023
Merged

gcc: drop include-fixed/bits/statx.h#225595
1 commit merged intoNixOS:stagingfrom
trofi:gcc-no-statx-fix

Conversation

@trofi
Copy link
Contributor

@trofi trofi commented Apr 10, 2023

At least on armv7l-linux bootstrapTools fixed version of bits/statx.h breaks the header:
#209870 (comment)

Drop the header along with other already cleaned ones.

Description of changes
Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

At least on armv7l-linux bootstrapTools fixed version of bits/statx.h
breaks the header:
    NixOS#209870 (comment)

Drop the header along with other already cleaned ones.
@trofi trofi requested a review from matthewbauer as a code owner April 10, 2023 16:12
@trofi trofi mentioned this pull request Apr 10, 2023
4 tasks
@trofi trofi requested a review from misuzu April 10, 2023 16:13
Copy link
Contributor

@misuzu misuzu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure why it works, but it works!

@ofborg ofborg bot added 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch. 10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. labels Apr 10, 2023
@trofi
Copy link
Contributor Author

trofi commented Apr 10, 2023

Yeah, it's a bit tricky. Here is now I understand it:

What is fixincludes

In a steady state to build basic software you need a compiler (say, gcc) and libc (headers and libraries, say glibc).

In the best case gcc can parse and use glibc as is. In practice libc can come from the vendor and might be tailored to vendor's proprietary compiler. libc can use some fancy extensions that gcc does not understand for various reasons.

To work around that fact gcc generates so called "fixed includes" to be able to work on top of such mildly incompatible libcs. gcc uses fixincludes script with a bunch of heuristics. It's idea is to copy libc's header to gcc's own include path and slightly mangle it there.

How fixincludes breaks

On glibc there is very small amount of mangling happening. Usually glibc Just Works. But there are rare cases where it does not: when glibc is very old and gcc is very new. Or the other way around.

What is worse fixincludes is not very robust: it happily generates invalid headers (as in this case).

What is even worse is that nixpkgs swaps libc from under gcc during bootstrap:

  1. gcc is built against glibc from bootstrap seed archive (usually ancient glibc). fixincludes are generated against ancient glibc.
  2. glibc is built against gcc from [1.], then glibc is swapped in stdenv without gcc rebuild. This makes fixincludes` stale.
  3. gcc is rebuilt against new glibc, fixincludes are generated against new glibc

[1.] and [2.] are the most fragile parts: they depend on glibc version both in bootstrapTools and in nipkgs. Those are different for different architectures in nixpkgs (it's a major pain).

Our breakage happens around [1.]: new gcc generates invalid fixincludes against ancient glibc. As a result we can't built a bunch of programs that try to use <statx.h> header.

The fix effectively throws away some of the invalid fixincludes and uses unmodified headers as is.

@trofi trofi requested a review from a user April 10, 2023 19:31
@ghost
Copy link

ghost commented Apr 11, 2023

Reviewing now. If this works then it is a much better idea than regenerating the bootstrapFiles.

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you so much for tracking this down, @trofi!

I confirmed this fixes pkgsCross.armv7l-hf-multiplatform.stdenv.__bootPackages.stdenv.__bootPackages.stdenv.__bootPackages.xz.

I have a few other builds running to make sure this doesn't cause problems anywhere else but I doubt that will happen.

@ghost ghost merged commit e199e42 into NixOS:staging Apr 11, 2023
@trofi trofi deleted the gcc-no-statx-fix branch April 11, 2023 18:21
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 501+ This PR causes many rebuilds on Darwin and should normally target the staging branches. 10.rebuild-darwin: 5001+ This PR causes many rebuilds on Darwin and must target the staging branches. 10.rebuild-linux: 501+ This PR causes many rebuilds on Linux and should normally target the staging branches. 10.rebuild-linux: 5001+ This PR causes many rebuilds on Linux and must target the staging branches. 10.rebuild-linux-stdenv This PR causes stdenv to rebuild on Linux and must target a staging branch.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants