From 6b832b53320bbecd556804dff270ad50a3ee122d Mon Sep 17 00:00:00 2001 From: Sergei Trofimovich Date: Sat, 28 Jan 2023 16:29:08 +0000 Subject: [PATCH] build-support/cc-wrapper: revert "pass in non-existent --sysroot= to untangle from libc" This reverts commit 8c80bd08b7e39229947d55104d1871f5066437d9 ("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`): https://github.com/NixOS/nixpkgs/pull/210004#issuecomment-1407162693 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`. --- pkgs/build-support/cc-wrapper/default.nix | 7 ------- 1 file changed, 7 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 33df804d5efec01..2f3b2d8e378860b 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -343,18 +343,11 @@ stdenv.mkDerivation { # compile, because it uses "#include_next " to find the # limits.h file in ../includes-fixed. To remedy the problem, # another -idirafter is necessary to add that directory again. - # - # We use --sysroot=/nix/store/does/not/exist to drop embedded default - # path to glibc headers gcc was built against. Without it -idirafter - # only appends to the list and outdated glibc headers end up being - # used. 'cc-cflags-before' is used to allow user's --sysroot= option - # to override our default. + optionalString (libc != null) ('' touch "$out/nix-support/libc-cflags" touch "$out/nix-support/libc-ldflags" echo "-B${libc_lib}${libc.libdir or "/lib/"}" >> $out/nix-support/libc-crt1-cflags '' + optionalString (!(cc.langD or false)) '' - echo "--sysroot=/nix/store/does/not/exist" >> $out/nix-support/cc-cflags-before echo "-idirafter ${libc_dev}${libc.incdir or "/include"}" >> $out/nix-support/libc-cflags '' + optionalString (isGNU && (!(cc.langD or false))) '' for dir in "${cc}"/lib/gcc/*/*/include-fixed; do