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.
This commit is contained in:
@@ -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 ];
|
||||
|
||||
@@ -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.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user