common/build-helper/rust.sh: fix cross for bindgen

When using a build.rs script to dynamically generate bindgen bindings
at build-time, it will run on the host, and by default bindgen will
generate bindings for the host arch/libc instead of the target.
To generate the bindings on cross, we need to use BINDGEN_EXTRA_CLANG_ARGS
to specify the proper sysroot and include path for the target.
These arguments are not used for anything other than bindgen's clang
invocation.
This commit is contained in:
classabbyamp 2022-02-23 23:55:47 -05:00 committed by Echo
parent 4a1c88223f
commit 191bf2460d

View file

@ -23,6 +23,9 @@ if [ "$CROSS_BUILD" ]; then
# innocuous flags are used here just to disable its defaults
export HOST_CC="gcc"
export HOST_CFLAGS="-O2"
# Crates that use bindgen via build.rs are not cross-aware unless these are set
export BINDGEN_EXTRA_CLANG_ARGS="--sysroot=${XBPS_CROSS_BASE} -I${XBPS_CROSS_BASE}/usr/include"
else
unset CARGO_BUILD_TARGET
fi