Skip to content
Migrate to CARGO_ENCODED_RUSTFLAGS

Cargo introduced CARGO_ENCODED_RUSTFLAGS in rust-lang/cargo#9601 to make setting flags less error prone – it encodes arguments separated by 0x1f (ASCII Unit Separator), instead of white spaces (old RUSTFLAGS).

CARGO_ENCODED_RUSTFLAGS are preferred over the old RUSTFLAGS in cargo. For build scripts, cargo converts its RUSTFLAGS to CARGO_ENCODED_RUSTFLAGS. For unset RUSTFLAGS it is set to an empty string. Thus our build script would call cargo for building libhermit-rs with a set – but empty – CARGO_ENCODED_RUSTFLAGS, which takes precedence over our prepared RUSTFLAGS. Specifically this caused our -Zmutable-noalias=no flag to be ignored, causing the same network issue as #128 again.

This PR adjusts our build script to make direct use of CARGO_ENCODED_RUSTFLAGS, the new and preferred way of handling flags in build scripts. This causes our flags to be correctly handled again.