diff options
author | Guillaume Girol <symphorien+git@xlumurb.eu> | 2022-02-03 12:00:00 +0000 |
---|---|---|
committer | Guillaume Girol <symphorien+git@xlumurb.eu> | 2022-02-03 12:00:00 +0000 |
commit | 7283e2dd066ef6b330fde65476da192fa92e77e1 (patch) | |
tree | ca6f2bbc793c267df1a3f80d456247c9fef6ce20 /pkgs/development/tools/rust | |
parent | efeefb2af1469a5d1f0ae7ca8f0dfd9bb87d5cfb (diff) | |
download | nixpkgs-7283e2dd066ef6b330fde65476da192fa92e77e1.tar nixpkgs-7283e2dd066ef6b330fde65476da192fa92e77e1.tar.gz nixpkgs-7283e2dd066ef6b330fde65476da192fa92e77e1.tar.bz2 nixpkgs-7283e2dd066ef6b330fde65476da192fa92e77e1.tar.lz nixpkgs-7283e2dd066ef6b330fde65476da192fa92e77e1.tar.xz nixpkgs-7283e2dd066ef6b330fde65476da192fa92e77e1.tar.zst nixpkgs-7283e2dd066ef6b330fde65476da192fa92e77e1.zip |
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.
Diffstat (limited to 'pkgs/development/tools/rust')
-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 2c69ad9876e..0da7303a36f 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 0b3e3cd4c1e..60dc293d528 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. |