build-helper/rust: define HOST_CC and HOST_CFLAGS

The cc-rs crate will try to guess the host compiler and use default
flags these are not specifically set. The default behavior is wrong in
Void cross-compilation environments. Explicitly define HOST_CC=gcc and
use innocuous HOST_CFLAGS=-O2 just to thwart the bad defaults.

Co-authored-by: Érico Rolim <erico.erc@gmail.com>
Co-authored-by: Andrew J. Hesford <ajh@sideband.org>

Closes: #28416.
This commit is contained in:
Andrew J. Hesford 2021-02-03 22:41:02 -05:00
parent b752f4de63
commit 2f5e5f1e5e

View file

@ -17,6 +17,12 @@ if [ "$CROSS_BUILD" ]; then
# [build]
# target = ${RUST_TARGET}
export CARGO_BUILD_TARGET="$RUST_TARGET"
# If cc-rs needs to build host binaries, it guesses the compiler and
# uses default (wrong) flags unless they are specified explicitly;
# innocuous flags are used here just to disable its defaults
export HOST_CC="gcc"
export HOST_CFLAGS="-O2"
else
unset CARGO_BUILD_TARGET
fi