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:
parent
4a1c88223f
commit
191bf2460d
1 changed files with 3 additions and 0 deletions
|
@ -23,6 +23,9 @@ if [ "$CROSS_BUILD" ]; then
|
||||||
# innocuous flags are used here just to disable its defaults
|
# innocuous flags are used here just to disable its defaults
|
||||||
export HOST_CC="gcc"
|
export HOST_CC="gcc"
|
||||||
export HOST_CFLAGS="-O2"
|
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
|
else
|
||||||
unset CARGO_BUILD_TARGET
|
unset CARGO_BUILD_TARGET
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Reference in a new issue