maint: Ask GCC for system headers
In the previous update commit, the Nix `cc.version` didn't match the in-output directory name anymore, causing a build failure. By asking GCC properly, we are robust against such discrepancies. The script isn't great, relying on GCC "log" output specifics, but it seems that the GCC output has been like this for a while, and the lines before and after seem to be intentional about their purpose... (cherry picked from commit 68f928555660cb914105b0ad668d6cadc25223e9)
This commit is contained in:
parent
d693957c1a
commit
32136109fc
3 changed files with 28 additions and 8 deletions
15
rust/nci.nix
15
rust/nci.nix
|
|
@ -13,6 +13,11 @@
|
|||
nativeBuildInputs = [
|
||||
pkgs.pkg-config
|
||||
];
|
||||
# bindgen uses clang to generate bindings, but it doesn't know where to
|
||||
# find our stdenv cc's headers, so when it's gcc, we need to tell it.
|
||||
postConfigure = lib.optionalString pkgs.stdenv.cc.isGNU ''
|
||||
source ${./bindgen-gcc.sh}
|
||||
'';
|
||||
# Prepare the environment for Nix to work.
|
||||
# Nix does not provide a suitable environment for running itself in
|
||||
# the sandbox - not by default. We configure it to use a relocated store.
|
||||
|
|
@ -46,13 +51,9 @@
|
|||
null # don't set the variable
|
||||
else
|
||||
lib.makeLibraryPath [ pkgs.buildPackages.llvmPackages.clang-unwrapped ];
|
||||
BINDGEN_EXTRA_CLANG_ARGS =
|
||||
if pkgs.stdenv.cc.isClang then
|
||||
null # don't set the variable
|
||||
else
|
||||
"-I${pkgs.stdenv.cc.libc.dev}/include"
|
||||
+ " -I${lib.getDev pkgs.stdenv.cc.cc}/lib/gcc/${pkgs.stdenv.hostPlatform.config}/${pkgs.stdenv.cc.cc.version}/include"
|
||||
;
|
||||
} // lib.optionalAttrs pkgs.stdenv.cc.isGNU {
|
||||
# Avoid cc wrapper, because we only need to add the compiler/"system" dirs
|
||||
NIX_CC_UNWRAPPED = "${pkgs.stdenv.cc.cc}/bin/gcc";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue