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