-
-
Notifications
You must be signed in to change notification settings - Fork 14.4k
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: provide both native and cross forms of gcc.libs libraries #209153
Conversation
I would like to use --sysroot=/nix/store/does/not/exist hack for both `gcc` and `clang` drivers to remove default include (and library) search paths when we override them with libc. For `gcc` it works as is. But for `clang` it also drops some of `gcc` search paths`. Let'sconsider 2 lookups. Successful lookup (no `--sysroot`): $ printf "int main(){}" | clang++ -x c++ - -Wl,--verbose |& grep -F stdc++ attempt to open /nix/store/...-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/libstdc++.so failed attempt to open /nix/store/...-gcc-11.3.0-lib/x86_64-unknown-linux-gnu/lib/libstdc++.so failed attempt to open /nix/store/...-clang-11.1.0-lib/lib/libstdc++.so failed attempt to open /nix/store/...-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/libstdc++.so failed attempt to open /nix/store/...-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/../../../../lib64/libstdc++.so failed /nix/store/...-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/../../../../lib64/libstdc++.a Failed lookup (has `--sysroot`): $ printf "int main(){}" | clang++ --sysroot=/does/not/exist -x c++ - -Wl,--verbose |& grep -F stdc++ attempt to open /nix/store/...-gcc-11.3.0/lib/gcc/x86_64-unknown-linux-gnu/11.3.0/libstdc++.so failed attempt to open /nix/store/...-gcc-11.3.0-lib/x86_64-unknown-linux-gnu/lib/libstdc++.so failed attempt to open /nix/store/...-clang-11.1.0-lib/lib/libstdc++.so failed attempt to open /nix/store/...-gcc-11.3.0/lib64/gcc/x86_64-unknown-linux-gnu/11.3.0/libstdc++.so failed /nix/store/...-binutils-2.39/bin/ld: cannot find -lstdc++: No such file or directory Note how `clang` starts the search roughly from `gcc-11.3.0-lib/x86_64-unknown-linux-gnu/lib` in both cases. I think it's our preferred location for both native and cross cases. The change adds such a symlink: `gcc-11.3.0-lib` -> `gcc-11.3.0-lib/x86_64-unknown-linux-gnu`
3a83f8d
to
2c931bd
Compare
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.
LGTM.
… 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 reverts commit 2c931bd. The NixOS#209153 reverted --sysroot=/ change as it broke other astects of library search paths. While it might still be useful to pull in gcc libraries when non-standard --sysroot= is passed there are no meaningful use cases of it in `nixpkgs` yet. Let's revert it for now.
@@ -203,6 +203,17 @@ preInstall() { | |||
ln -s lib "$out/${targetConfig}/lib32" | |||
ln -s lib "${!outputLib}/${targetConfig}/lib32" | |||
fi | |||
|
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.
We should migrate this eventually to the normal nix phases and share those between all gcc.
There seems to be also a good chunk of other copy pasted code. Not sure how easily we could group that into a shared file and if it would just reduce readability a lot. Maybe we could also use version ranges when something is not supposed to be done for every gcc version.
I would like to use --sysroot=/nix/store/does/not/exist hack for both
gcc
andclang
drivers to remove default include (and library) search paths when we override them with libc.For
gcc
it works as is. But forclang
it also drops some ofgcc
search paths`. Let'sconsider 2 lookups.Successful lookup (no
--sysroot
):Failed lookup (has
--sysroot
):Note how
clang
starts the search roughly fromgcc-11.3.0-lib/x86_64-unknown-linux-gnu/lib
in both cases. I think it's our preferred location for both native and cross cases.The change adds such a symlink:
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