cc-wrapper: conditionalize the nonexistent sysroot hack#213738
Conversation
… 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 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: #209153
trofi
left a comment
There was a problem hiding this comment.
I don't think --sysroot=/nix/store/does/not/exist can be used as is without addressing library search paths and include search paths.
| touch "$out/nix-support/libc-ldflags" | ||
| echo "-B${libc_lib}${libc.libdir or "/lib/"}" >> $out/nix-support/libc-crt1-cflags | ||
| '' + optionalString enableNonExistentSysroot '' | ||
| echo "--sysroot=/nix/store/does/not/exist" >> $out/nix-support/cc-cflags-before |
There was a problem hiding this comment.
As stated in #213185 blanket --sysroot= changes library search path in transitive libraries. As a result we get linkage failures in dmd, d-seams, llvmPackages_rocm.compiler-rt. Conditional or not it's breaking real packages. The intent in the comment was only attempting to change header search path and not library search path.
For just headers there is an -isysroot flag. But it has it's own caveats as blanket --sysroot= also exposed failures in ipxe and wimboot. Those show that existing -idirafter sequence is incorrectly overridden in nixpkgs. It has to be fixed by chaning a priority.
There was a problem hiding this comment.
The conditional is only enabled for xgcc, which is never used to compile any of those packages.
There was a problem hiding this comment.
My suggestion would be to explore ways to add the flag locally to the place where it's intended to be used instead of changing the driver. I still think it's too heavy a hammer even for gcc.
| touch "$out/nix-support/libc-ldflags" | ||
| echo "-B${libc_lib}${libc.libdir or "/lib/"}" >> $out/nix-support/libc-crt1-cflags | ||
| '' + optionalString enableNonExistentSysroot '' | ||
| echo "--sysroot=/nix/store/does/not/exist" >> $out/nix-support/cc-cflags-before |
There was a problem hiding this comment.
My suggestion would be to explore ways to add the flag locally to the place where it's intended to be used instead of changing the driver. I still think it's too heavy a hammer even for gcc.
|
I think I have a solution that will make everybody happy: no patches to gcc and does not use nonexistent-sysroot at all. I'm running some test builds overnight and will clean it up in the morning, but the key insight is in: |
Description of changes
Things done
sandbox = trueset 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.shto update generated release notes