17

Is it possible to specify specific profiles for members of a workspace? If I write a profile into the member Cargo.toml I get:

warning: profiles for the non root package will be ignored, specify profiles at the workspace root:

I also tried to put a specific profile into workspace root's Cargo.toml:

[profile.release]
opt-level = 3

[profile.release.hal]
# optimizer kills assembly code
opt-level = 1

However, it seems to be ignored too, as the applied options in the the verbose output show:

Running `rustc --crate-name hal src/hal/lib.rs --crate-type lib -C opt-level=3 --emit=dep-info,link [...]

Is there any other way beside avoiding workspaces at all?

Matthias
  • 8,018
  • 2
  • 27
  • 53
  • Could this be addressed by change in the source code e.g. adding `#[inline(never)]` instead of changing the opt-level? – kennytm Aug 21 '17 at 14:39
  • 1
    @kennytm: unfortunately not..The optimizer does much more than reallocating code, and Rust has no means to control optimization at function level. – Matthias Aug 21 '17 at 15:14

1 Answers1

10

This is now supported and stabilized since Rust 1.43:

[profile.release]
opt-level = 3

[profile.release.package.hal]
# optimizer kills assembly code
opt-level = 1

See: https://doc.rust-lang.org/cargo/reference/profiles.html#overrides

Alvin Wong
  • 12,210
  • 5
  • 51
  • 77