-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
cargo build
and run
use inconsistent debug flags for proc-macro crates
#12457
Comments
What if you run |
It behaves as |
Thanks for the reply! Just had a look at the repro. There are things contributing to this “expected” behavior.
See this section from Cargo book for more :) |
That's not how it works in my env though...
But you're right that it's less about I'd expect Another data point here: this affects only crates within the workspace. For example, if I replace dependency on [dependencies]
serde = { version = "1", features = ["derive"] } then |
Sorry that's my mistake. I've updated my previous comment. In summary, it is
Your observation is absolutely correct and expected.
|
Thank you very much for this report. Just want to add it might create problems in software that attempts to "build dependencies only" as a separate step to use it for caching purposes. I was able to pin-point it to |
I'm not sure there is anything to do here, since it sounds like this is behaving as intended. |
While the original report is about differences between run and build, there's something else wrong that is not |
Closing as it is expected behavior. And thanks, worth noting the workaround :)
|
Problem
cargo build
passes debuginfo flags to rustc when compiling proc-macro crates indev
profile, whilecargo run
does not.Different flags cause unnecessary recompilation, since crate compilations have different metadata hashes. For example, if a workspace has a custom derive macros defined and a lot a binaries, it is not possible to run
cargo build
to compile all the binaries first, then run them as needed usingcargo run
without recompiling everything.I'd expect
cargo build
andcargo run
to use the same rustc flags for crates when compiling with the same profile.Steps
Use the attached
cargo-example.zip
cargo build --verbose
cargo run --bin foo --verbose
Look for
-C debuginfo=2
Possible Solution(s)
As a workaround, I disable debuginfo for build dependencies explicitly:
With this, proc-macro crates are consistently built without debuginfo in
dev
profile and do not cause recompilation.Notes
Reproduces since
nightly-2023-02-09
Appears to be related to
Version
The text was updated successfully, but these errors were encountered: