Setting RUSTFLAGS globally?
⚓ Rust 📅 2026-02-04 👤 surdeus 👁️ 9Build Configuration - The Rust Performance Book
RUSTFLAGS="-C target-cpu=native" cargo build --release
works fine. But I am unable to set target-cpu=native globally in a configuration file. For example I tried a lot of variants like
$ cat ~/.cargo/config.toml
[target.x86_64-unknown-linux-gnu]
linker = "clang"
rustflags = ["-C", "link-arg=-fuse-ld=mold", "-C", "target-cpu=native"]
#[build]
#rustflags = ["-C", "target-cpu=native"]
#[build]
# Use a single absolute path for all build artifacts
#target-dir = "/home/stefan/.cargo/target_shared"
[profile.dev]
# One debuginfo file per dependency, to reduce file size of tests/examples.
# Note that this value is not supported on Windows.
# See https://doc.rust-lang.org/cargo/reference/profiles.html#split-debuginfo
#split-debuginfo="unpacked"
2 posts - 2 participants
🏷️ Rust_feed