RUSTFLAGS via cargo

Hi,
When I compile using Raspbian I need to set
export RUSTFLAGS=-Ccodegen-units=1

I tried to add a section in Cargo.toml

[target.arm-unknown-linux-gnueabihf]
rustflags = ["-C","codegen-units=1"]

I also tried

[target.'cfg(all(target_arch="arm", target_os="linux"))']
rustflags = ["-C","codegen-units=1"]

I take the config from Cargo doc:

[target.thumbv7m-none-eabi]
linker = "arm-none-eabi-gcc"
runner = "my-emulator"
rustflags = ["…", "…"]

[target.'cfg(all(target_arch = "arm", target_os = "none"))']
runner = "my-arm-wrapper"
rustflags = ["…", "…"]

I always got a warning:
warning: unused manifest key: target.cfg(all(target_arch = "arm", target_os = "none")).rustflags

Any advice's ?

Thanks

These options need to go into a .cargo/config file (or $CARGO_HOME/config, see the first part on Cargo book - Configuration).

1 Like

You can also set codegen-units in profiles.

1 Like

Thanks I tried both and it works ! :+1: