-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
build-support/cc-wrapper: pass in non-existent --sysroot= to untangle… #210004
Conversation
… from libc I would like to add an extra `gcc` build step during linux bootstrap (NixOS#208412). This makes it early bootstrap compiler linked and targeted against `bootstrapTools` `glibc` including it's headers. Without this change `gcc`'s spec files always prefer `bootstrapTools` `glibc` for header search path (passed in as --with-native-system-header-dir=). We'can't override it with: - `-I` option as it gets stacked before gcc-specific headers, we need to keep glibc headers after gcc as gcc cleans namespace up for C standard by using #include_next and by undefining system macros. - `-idirafter` option as it gets appended after existing `glibc`-includes This `--sysroot=/nix/store/does/not/exist` hack allows us to remove existing `glibc` headers and add new ones with `-idirafter`. We use `cc-cflags-before` instead of `libc-cflags` to allow user to define their own `--sysroot=` (like `firefox` does). To keep it working prerequisite cross-symlink in gcc.libs is required: NixOS#209153
This commit broke uboot packages on staging-next. See https://hydra.nixos.org/eval/1789657?filter=uboot&compare=1789649.
|
Sounds plausible. The failure is not outright obvious:
Looking. |
yeah, include order did change and broke On FHS systems include order is:
(libc includes come before On
(libc includes come after Should be easy to workaround just for u-boot. I'll propose u-boot specific fix tomorrow morning. |
Proposed possible |
`ubootTools` build broke after NixOS#210004 where we started dropping default libc include path and switched to `-idirafter` way of specifying libc headers. Unfortunately the way it's implemented it injects -idirafter after user's flags, not before. That allows users to inject their paths before libc include paths, not after (as it would notmally happen). The change works it around for u-boot by pulling -idirafter libc flags before user's flags.
Also EDIT: also confirmed for packages: |
Will have a more detailed look in 1-2 hours to see how I broke |
False alarm. |
Proposed
Looking at |
Note: It was forgotten in non-lib output:
I'll think of a local |
Proposed Looking at |
Proposed Looking at |
More fallout:
|
…or clang After NixOS#210004 `usbmuxd2` started failing to build as: usbmuxd2-unstable> .../ld: cannot find -lstdc++fs: No such file or directory usbmuxd2-unstable> clang-11: error: linker command failed with exit code 1 (use -v to see invocation) This started happening because NixOS#210004 exposed a long-standing bug in `gcc` derivation: `cc.lib` is missing `libstdc++fs` library: $ find $(nix-build --no-link -A stdenv.cc.cc.lib) | fgrep libstdc | unnix /<<NIX>>/gcc-11.3.0-lib/lib/libstdc++fs.la /<<NIX>>/gcc-11.3.0-lib/lib/libstdc++.la /<<NIX>>/gcc-11.3.0-lib/lib/libstdc++.so.6.0.29 /<<NIX>>/gcc-11.3.0-lib/lib/libstdc++.so /<<NIX>>/gcc-11.3.0-lib/lib/libstdc++.so.6 It was not moved from `cc.out` output: $ find $(nix-build --no-link -A stdenv.cc.cc) | fgrep libstdc | unnix /<<NIX>>/gcc-11.3.0/lib/libstdc++.a /<<NIX>>/gcc-11.3.0/lib/libstdc++fs.a This change adds `cc` library lookup path back to `staging-next` until `gcc` is fixed.`
`ipxe` build broke after NixOS#210004 where we started dropping default libc include path and switched to `-idirafter` way of specifying libc headers. Unfortunately the way it's implemented it injects `-idirafter` after user's flags, not before. That allows users to inject their paths before libc include paths, not after (as it would notmally happen). The change works it around for `ipxe` by pulling `-idirafter` libc flags before user's flags.
`wimboot` build broke after NixOS#210004 where we started dropping default libc include path and switched to `-idirafter` way of specifying libc headers. Unfortunately the way it's implemented it injects `-idirafter` after user's flags, not before. That allows users to inject their paths before libc include paths, not after (as it would notmally happen). The change works it around for `wimboot` by pulling `-idirafter` libc flags before user's flags.
After NixOS#210004 `dmd` started failing build as: ld: warning: libm.so.6, needed by ./generated/linux/release/64/lib.so, not found (try using -rpath or -rpath-link) ld: /build/druntime/generated/linux/release/64/libdruntime.so: undefined reference to `log10@GLIBC_2.2.5' This happens because --sysroot=/nix/store/does/not/exist removes not just include headers by prefixing wrong path, but also removes RUNPATH dependencies of linked libraries. It's an unintended effect. Restore the build by reversing the effect with --sysroot=/.
On top of the above fixes for There are too many subtle changes that need to be handled one by one: library search paths, include search path order, bootstrap overrides and sequencing. |
…untangle from libc" This reverts commit 8c80bd0 ("build-support/cc-wrapper: pass in non-existent --sysroot= to untangle from libc"). This change was good in spirit: we caught a few genuine problems with `scons` based packages (`godot`, `fluxus`) and unexpected `-idirafter` includes in various boot loadres (`ipxe`, wimboot`): NixOS#210004 (comment) Unfortunately `--sysroot=` also has a negative impact on libary search order for DT_NEEDED libraries and RUNPATHs of linked libraries. This unexpectedly broke `dmd`, `d-seams`, `llvmPackages_rocm.compiler-rt`). An interesting case of unexpected breakage is `usbmuxd2` where the bug exposed incomplete library move on `libstdc++fs` in `gcc`. The library breakage is very non-intuitive (on top of already unusual layout of `cc-wrapper` driver). Let's revert this change for now. Once it lands we can undo `--sysroot=/` workarounds merged for `staging-next`.
After NixOS/nixpkgs#210004 `dmd` started failing build as: ld: warning: libm.so.6, needed by ./generated/linux/release/64/lib.so, not found (try using -rpath or -rpath-link) ld: /build/druntime/generated/linux/release/64/libdruntime.so: undefined reference to `log10@GLIBC_2.2.5' This happens because --sysroot=/nix/store/does/not/exist removes not just include headers by prefixing wrong path, but also removes RUNPATH dependencies of linked libraries. It's an unintended effect. Restore the build by reversing the effect with --sysroot=/.
After NixOS/nixpkgs#210004 `dmd` started failing build as: ld: warning: libm.so.6, needed by ./generated/linux/release/64/lib.so, not found (try using -rpath or -rpath-link) ld: /build/druntime/generated/linux/release/64/libdruntime.so: undefined reference to `log10@GLIBC_2.2.5' This happens because --sysroot=/nix/store/does/not/exist removes not just include headers by prefixing wrong path, but also removes RUNPATH dependencies of linked libraries. It's an unintended effect. Restore the build by reversing the effect with --sysroot=/.
… from libc
I would like to add an extra
gcc
build step during linux bootstrap (#208412). This makes it early bootstrap compiler linked and targeted againstbootstrapTools
glibc
including it's headers.Without this change
gcc
's spec files always preferbootstrapTools
glibc
for header search path (passed in as --with-native-system-header-dir=). We'can't override it with:-I
option as it gets stacked before gcc-specific headers, we need to keep glibc headers after gcc as gcc cleans namespace up for C standard by using #include_next and by undefining system macros.-idirafter
option as it gets appended after existingglibc
-includesThis
--sysroot=/nix/store/does/not/exist
hack allows us to remove existingglibc
headers and add new ones with-idirafter
.We use
cc-cflags-before
instead oflibc-cflags
to allow user to define their own--sysroot=
(likefirefox
does).To keep it working prerequisite cross-symlink in gcc.libs is required: #209153
Description of changes
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