rust-bindgen: fix c++ includes

NIX_CXXSTDLIB_COMPILE has been removed in https://github.com/NixOS/nixpkgs/pull/85189
and https://github.com/NixOS/nixpkgs/pull/85189#commitcomment-40987154
remommends using the files in ${clang}/nix-support to find the correct
flags to pass to libclang.

+11 -8
+9 -6
pkgs/development/tools/rust/bindgen/default.nix
··· 1 - { lib, fetchFromGitHub, rustPlatform, clang, llvmPackages_latest, rustfmt, writeTextFile 1 + { lib, fetchFromGitHub, rustPlatform, clang, rustfmt, writeTextFile 2 2 , runtimeShell 3 3 , bash 4 4 }: ··· 19 19 cargoSha256 = "sha256-zhENlrqj611RkKDvpDtDFWc58wfQVamkJnpe2nvRieE="; 20 20 21 21 #for substituteAll 22 - libclang = llvmPackages_latest.libclang.lib; 22 + libclang = clang.cc.lib; # use the same version of clang for cxxincludes and libclang 23 23 inherit bash; 24 24 25 25 buildInputs = [ libclang ]; 26 26 27 - propagatedBuildInputs = [ clang ]; # to populate NIX_CXXSTDLIB_COMPILE 28 - 29 - configurePhase = '' 30 - export LIBCLANG_PATH="${libclang.lib}/lib" 27 + preConfigure = '' 28 + export LIBCLANG_PATH="${lib.getLib libclang}/lib" 31 29 ''; 32 30 33 31 postInstall = '' 34 32 mv $out/bin/{bindgen,.bindgen-wrapped}; 33 + export cincludes="$(< ${clang}/nix-support/cc-cflags) $(< ${clang}/nix-support/libc-cflags)" 34 + export cxxincludes="$(< ${clang}/nix-support/libcxx-cxxflags)" 35 35 substituteAll ${./wrapper.sh} $out/bin/bindgen 36 36 chmod +x $out/bin/bindgen 37 37 ''; ··· 66 66 rust ffi declarations. 67 67 As with most compiler related software, this will only work 68 68 inside a nix-shell with the required libraries as buildInputs. 69 + This version of bindgen is wrapped with the required compiler flags 70 + required to find the c and c++ standard libary of the input clang 71 + derivation. 69 72 ''; 70 73 homepage = "https://github.com/rust-lang/rust-bindgen"; 71 74 license = with licenses; [ bsd3 ];
+2 -2
pkgs/development/tools/rust/bindgen/wrapper.sh
··· 22 22 done; 23 23 cxxflags= 24 24 if [[ $cxx -eq 1 ]]; then 25 - cxxflags=$NIX_CXXSTDLIB_COMPILE 25 + cxxflags="@cxxincludes@" 26 26 fi; 27 27 if [[ -n "$NIX_DEBUG" ]]; then 28 28 set -x; ··· 30 30 export LIBCLANG_PATH="@libclang@/lib" 31 31 # shellcheck disable=SC2086 32 32 # cxxflags and NIX_CFLAGS_COMPILE should be word-split 33 - exec -a "$0" @out@/bin/.bindgen-wrapped "$@" $sep $cxxflags $NIX_CFLAGS_COMPILE 33 + exec -a "$0" @out@/bin/.bindgen-wrapped "$@" $sep $cxxflags @cincludes@ $NIX_CFLAGS_COMPILE 34 34 # note that we add the flags after $@ which is incorrect. This is only for the sake 35 35 # of simplicity. 36 36