Multiple target "categories" in config.toml

⚓ Rust    📅 2025-12-19    👤 surdeus    👁️ 5      

surdeus

Let's say I have the following config.toml:

[build]
jobs = 17 # 2N+1 where 2 is number of cores
incremental = true
# May need to run `cargo install sccache`
rustc-wrapper = "sccache"

[profile.release]
opt-level = 3 # All optimizations!
debug = 0 # No debug info
strip = "symbols"
lto = "fat"

I can then build this with cargo build --release.
I'm aware I could also add a target entry to build, e.g.

[build]
jobs = 17 # 2N+1 where 2 is number of cores
incremental = true
# May need to run `cargo install sccache`
rustc-wrapper = "sccache" # Might need to change to full path for windows
target = ["foo", "bar"]

However, I'd like to have certain targets only build for release builds. How I thought I could do this would be something like:

[build]
jobs = 17 # 2N+1 where 2 is number of cores
incremental = true
# May need to run `cargo install sccache`
rustc-wrapper = "sccache" # Might need to change to full path for windows
[build.release] # Set different build options for release?
jobs = 17
rustc-wrapper = "sccache"
target = [  "aarch64-apple-darwin", "aarch64-pc-windows-gnullvm"]

Similar to how you have profile and profile.release. This does not work however.
Is there a way to achieve what I'm seeking in the config.toml file? I'm aware I could probably use something like a makefile, but I'd prefer not to if there is a more elegant inbuilt way.

1 post - 1 participant

Read full topic

🏷️ Rust_feed