Cargo workspace and compiler settings


I have a (large-ish) project of about 20 library crates and 15 binaries. I'm considering moving this into a workspace and have read up on the documentation - but am slightly scared by the seeming lack of using different compiler flags:

In particular I have a few library crates that are very performance sensitivt - they are compiled at high optimization level and using wide avx instructions (sleef primitive math function also used - linking a c++ lib).

However - to save compilation time I do not want to compile all of the other lib crates and binaries using the same compiler settings.

To my question: Is it possible to sett different compiler flags for different crates in a workspace (it specifies that the profile* part is not respected from the sub crates) or do I have to keep using multiple crates outside a workspace to achieve this?


Thanks! So it is possible - but all the changes have to be done in the top level config file as I understand it?

No. See Configuration - The Cargo Book

Update: Well, for workspace project, yes.

At present, when being invoked from a workspace, Cargo does not read config files from crates within the workspace.

Yep - that's what I was refering to in the first place :slight_smile:
Thanks for your help - I will give the workspace a test

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.