-
-
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: pass --with-build-sysroot=/ #181943
gcc: pass --with-build-sysroot=/ #181943
Conversation
To clarify:
... meaning Just want to make sure nobody reading along is thinking |
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.
Thank you for sorting this out, @trofi.
This is such a "spooky action at a distance" that we really ought to force gcc's build to fail if it cannot find the glibc headers. Do you know if there is a configure option we can pass to gcc to prevent it from silently disabling features instead of reporting an error?
Okay, I think this is starting to make sense now. I need to run a bunch of builds overnight; assuming those all go well, and we can explain why this was a problem for powerpc64le but not for mips64el, I'll close #181802 in favor of this. Unfortunately that means we will need to wait for Hydra to rebuild with it and then post a new bootstrap-files to |
I've verified that this PR fixes the stack-protector issue in stdenv on powerpc64le, so I've closed #181802. I've also rebuilt using a version of this PR which removes the I'm also re-running the bootstrap on mips64el just to make sure nothing broke. That may take a day or two unfortunately. |
This bootstrap completed successfully. |
48eb0a5
to
6313761
Compare
5be8205
to
dd12158
Compare
187eb0b
to
5503be6
Compare
Found |
5503be6
to
d5d6724
Compare
One more change: Dropped mingw special case for no-libc build. Before the change we passed both |
Without this change cross-built gcc fails to detect stack protector style: $ nix log -f pkgs/stdenv/linux/make-bootstrap-tools-cross.nix powerpc64le.bootGCC | fgrep __stack_chk_fail checking __stack_chk_fail in target C library... no checking __stack_chk_fail in target C library... no It happens because gcc treats search paths differently: https://gcc.gnu.org/git/?p=gcc.git;a=blob;f=gcc/configure.ac;h=446747311a6aec3c810ad6aa4190f7bd383b94f7;hb=HEAD#l2458 if test x$host != x$target || test "x$TARGET_SYSTEM_ROOT" != x || test x$build != x$host || test "x$with_build_sysroot" != x; then ... if test "x$with_build_sysroot" != "x"; then target_header_dir="${with_build_sysroot}${native_system_header_dir}" elif test "x$with_sysroot" = x; then target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-include" elif test "x$with_sysroot" = xyes; then target_header_dir="${test_exec_prefix}/${target_noncanonical}/sys-root${native_system_header_dir}" else target_header_dir="${with_sysroot}${native_system_header_dir}" fi else target_header_dir=${native_system_header_dir} fi By passing --with-build-sysroot=/ we trick cross-case to use `target_header_dir="${with_sysroot}${native_system_header_dir}"` which makes it equivalent to non-cross `target_header_dir="${with_build_sysroot}${native_system_header_dir}"` Tested the following setups: - cross-compiler without libc headers (powerpc64le-static) - cross-compiler with libc headers (powerpc64le-debug) - cross-build compiler with libc headers (powerpc64le bootstrapTools) Before the change only 2 of 3 compilers detected libc headers. After the change all 3 compilers detected libc headers. For darwin we silently ignore '-syslibroot //' argument as it does not introduce impurities. While at it dropped mingw special case for no-libc build. Before the change we passed both '--without-headers --with-native-system-headers-dir' for no-libc gcc-static builds. This tricked darwin builds to find sys/sdt.h and fail inhibid_libc builds. Now all targets avoid passing native headers for gcc-static builds. While at it fixed correct headers passing to --with-native-system-headers-dir= in host != target case: we were passing host's headers where intention was to pass target's headers. Noticed the mismatch as a build failure on pkgsCross.powernv.stdenv.cc on darwin where `sys/sdt.h` is present in host's headers (libSystem) but not target's headers (`glibc`). Co-authored-by: Adam Joseph <[email protected]>
d5d6724
to
34636ef
Compare
While at it fixed correct headers passing to |
Should be ready now. I tested a few things:
All cases seem to work and detect target libc features. |
This is a very nicely done fix. I love the attention to not just making sure things work, but making sure things work for the same reasons across both cross and native. Thanks!! |
Thank you! There is one minor fallout: not-quite-cross case of |
Without this change cross-built gcc fails to detect stack protector style:
It happens because gcc treats search paths differently:
By passing --with-sysroot=/ we trick cross-case to use
target_header_dir="${with_sysroot}${native_system_header_dir}"
which makes it equivalent to non-cross
target_header_dir=${native_system_header_dir}
Tested the following setups:
Before the change only 2 of 3 compilers detected libc headers.
After the change all 3 compilers detected libc headers.
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