Rust tips is a user on octodon.social. You can follow them or interact with them if you have an account anywhere in the fediverse. If you don't, you can sign up here.
Rust tips @rust

Cargo build scripts (build.rs) need special care to support cross-compilation correctly.

Don't use `#[cfg(target…)]`/`cfg!(target=…)`, because all macros and constants in the source code are for the machine that does the compilation, which may be different from the architecture the code is cross-compiled for (e.g. macOS can build libraries for Android).

Instead, check values of `std::env::var("TARGET")`, `CARGO_CFG_TARGET_ARCH`, etc.

kazlauskas.me/entries/writing-

· Web · 1 · 0