From 191bf2460de73f3fb3541bb75a6c3656bd6b3d6c Mon Sep 17 00:00:00 2001 From: classabbyamp Date: Wed, 23 Feb 2022 23:55:47 -0500 Subject: [PATCH] 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. --- common/build-helper/rust.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/build-helper/rust.sh b/common/build-helper/rust.sh index 431cb5f0fd..798083709c 100644 --- a/common/build-helper/rust.sh +++ b/common/build-helper/rust.sh @@ -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