about summary refs log tree commit diff
path: root/pkgs/build-support/cc-wrapper
diff options
context:
space:
mode:
authorSergei Trofimovich <slyich@gmail.com>2023-01-14 08:18:56 +0000
committerGitHub <noreply@github.com>2023-01-14 08:18:56 +0000
commit67a3a14f240c8f2a0175b4af7f905acd57987716 (patch)
tree3e857e80b7852f4a49c3b6ef68dca8821939b6e6 /pkgs/build-support/cc-wrapper
parent1bc0b7ad629850c64226a2a9a364d7f1ef57c6e6 (diff)
parent8c80bd08b7e39229947d55104d1871f5066437d9 (diff)
Merge pull request #210004 from trofi/cc-fake-sysroot
build-support/cc-wrapper: pass in non-existent --sysroot= to untangle…
Diffstat (limited to 'pkgs/build-support/cc-wrapper')
-rw-r--r--pkgs/build-support/cc-wrapper/default.nix7
1 files changed, 7 insertions, 0 deletions
diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix
index 33455efd5258b..44db6d3fc529b 100644
--- a/pkgs/build-support/cc-wrapper/default.nix
+++ b/pkgs/build-support/cc-wrapper/default.nix
@@ -332,11 +332,18 @@ stdenv.mkDerivation {
     # compile, because it uses "#include_next <limits.h>" 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