From 2f5e5f1e5e223f62f6a59ec06c438001391630bf Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Wed, 3 Feb 2021 22:41:02 -0500 Subject: [PATCH] build-helper/rust: define HOST_CC and HOST_CFLAGS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Co-authored-by: Andrew J. Hesford Closes: #28416. --- common/build-helper/rust.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/build-helper/rust.sh b/common/build-helper/rust.sh index 6fcd3bd7d9e..431cb5f0fd4 100644 --- a/common/build-helper/rust.sh +++ b/common/build-helper/rust.sh @@ -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