-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Selective Enabling/Disabling optimizations at a crate/file/function level #32
Comments
Two nightly features that may be of interest: cargo profile overrides:
# the `image` crate will be compiled with -Copt-level=3
[profile.dev.overrides.image]
opt-level = 3 and
e.g. |
This didn't work for me. Minimum reproducible example (but maybe I'm doing something wrong!): |
I did more investigation on this. The MRE now demonstrates that depending on the optimization level of the caller, the function in the upstream crate may not be optimized. It makes me think I'm getting both debug and release versions of that crate linked into the binary. There is a tracking issue here (rust-lang/rust#48683) for the feature. Maybe I'm doing this incorrectly, or my expectations of what should happen aren't right, but it seems like the feature is broken. |
An update for anyone watching this.. I opened an issue here: rust-lang/rust#63484. It seems like generics do not play well with profile overrides (and in my case, I was hoping for nphysics to be optimized, and nearly everything in that library is generic. I also saw that the embark rust ecosystem repo had a bug open for this as well: So main issues for profile overrides are:
|
I think that |
Profile overrides is set to be stabilized in 1.41 (rust-lang/cargo#7591) In practice, |
Many C++ compilers allow disabling the optimizer for a span of code with a #pragma. I can think of a few use-cases, but there may be others:
If this functionality does not exist (or is not yet stable), and others here agree that it's worth pursuing, it might be worth raising this with the core rust team so that they know it's of interest to us.
If it does exist, then it may be worth trying to share more broadly that this is possible.
The text was updated successfully, but these errors were encountered: