Target Specific Profile Options

Is there a way to have target specific profile options.

I work on a project which has support for both WASM and C-FFI and it would
be grate if there is a way to set opt-level=2 for the dev and test profile for
only the wasm32 target architecture.

This is needed as running the tests on wasm without opt-level=2 takes
roughly 20times longer on the other hand always setting the opt-level=2 for
dev and test profiles slows down the "normal" non-wasm testing by ~20%.

Currently I kinda work around this by settings export CARGO_PROFILE_DEV_OPT_LEVEL="2"; export CARGO_PROFILE_TEST_OPT_LEVEL="2" when working on the WASM bindings,
but it's easy to forget and then wonder why your command seem to hang.

There's an open issue about this: Per-target profiles? · Issue #4897 · rust-lang/cargo · GitHub

1 Like