diff options
-rw-r--r-- | pkgs/development/tools/rust/bindgen/default.nix | 15 | ||||
-rwxr-xr-x | pkgs/development/tools/rust/bindgen/wrapper.sh | 4 |
2 files changed, 11 insertions, 8 deletions
diff --git a/pkgs/development/tools/rust/bindgen/default.nix b/pkgs/development/tools/rust/bindgen/default.nix index 2c69ad9876ecb..0da7303a36fbc 100644 --- a/pkgs/development/tools/rust/bindgen/default.nix +++ b/pkgs/development/tools/rust/bindgen/default.nix @@ -1,4 +1,4 @@ -{ lib, fetchFromGitHub, rustPlatform, clang, llvmPackages_latest, rustfmt, writeTextFile +{ lib, fetchFromGitHub, rustPlatform, clang, rustfmt, writeTextFile , runtimeShell , bash }: @@ -19,19 +19,19 @@ rustPlatform.buildRustPackage rec { cargoSha256 = "sha256-zhENlrqj611RkKDvpDtDFWc58wfQVamkJnpe2nvRieE="; #for substituteAll - libclang = llvmPackages_latest.libclang.lib; + libclang = clang.cc.lib; # use the same version of clang for cxxincludes and libclang inherit bash; buildInputs = [ libclang ]; - propagatedBuildInputs = [ clang ]; # to populate NIX_CXXSTDLIB_COMPILE - - configurePhase = '' - export LIBCLANG_PATH="${libclang.lib}/lib" + preConfigure = '' + export LIBCLANG_PATH="${lib.getLib libclang}/lib" ''; postInstall = '' mv $out/bin/{bindgen,.bindgen-wrapped}; + export cincludes="$(< ${clang}/nix-support/cc-cflags) $(< ${clang}/nix-support/libc-cflags)" + export cxxincludes="$(< ${clang}/nix-support/libcxx-cxxflags)" substituteAll ${./wrapper.sh} $out/bin/bindgen chmod +x $out/bin/bindgen ''; @@ -66,6 +66,9 @@ rustPlatform.buildRustPackage rec { rust ffi declarations. As with most compiler related software, this will only work inside a nix-shell with the required libraries as buildInputs. + This version of bindgen is wrapped with the required compiler flags + required to find the c and c++ standard libary of the input clang + derivation. ''; homepage = "https://github.com/rust-lang/rust-bindgen"; license = with licenses; [ bsd3 ]; diff --git a/pkgs/development/tools/rust/bindgen/wrapper.sh b/pkgs/development/tools/rust/bindgen/wrapper.sh index 0b3e3cd4c1e03..60dc293d528e7 100755 --- a/pkgs/development/tools/rust/bindgen/wrapper.sh +++ b/pkgs/development/tools/rust/bindgen/wrapper.sh @@ -22,7 +22,7 @@ for e in "$@"; do done; cxxflags= if [[ $cxx -eq 1 ]]; then - cxxflags=$NIX_CXXSTDLIB_COMPILE + cxxflags="@cxxincludes@" fi; if [[ -n "$NIX_DEBUG" ]]; then set -x; @@ -30,7 +30,7 @@ fi; export LIBCLANG_PATH="@libclang@/lib" # shellcheck disable=SC2086 # cxxflags and NIX_CFLAGS_COMPILE should be word-split -exec -a "$0" @out@/bin/.bindgen-wrapped "$@" $sep $cxxflags $NIX_CFLAGS_COMPILE +exec -a "$0" @out@/bin/.bindgen-wrapped "$@" $sep $cxxflags @cincludes@ $NIX_CFLAGS_COMPILE # note that we add the flags after $@ which is incorrect. This is only for the sake # of simplicity. |