-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Inconsistent handling of debug = 0 vs debug = false in profiles #12163
Comments
There are several issues behind this. First,
cargo/src/cargo/ops/cargo_compile/mod.rs Lines 690 to 692 in a6c0d43
Second,setting Before: cargo/src/cargo/core/profiles.rs Line 534 in d71aa2e
After: cargo/src/cargo/core/profiles.rs Lines 531 to 533 in a6c0d43
The third oneis also interesting. When Cargo figures out that it can turn off debuginfo for a build dependency (when it is not shared with runtime dependencies), it turns cargo/src/cargo/core/profiles.rs Lines 783 to 785 in a6c0d43
That means, as aforementioned, Cargo won't pass any diff --git a/src/cargo/core/profiles.rs b/src/cargo/core/profiles.rs
index afaf3fb4f..e3da43093 100644
--- a/src/cargo/core/profiles.rs
+++ b/src/cargo/core/profiles.rs
@@ -781,7 +781,10 @@ impl DebugInfo {
/// Reset to the lowest level: no debuginfo.
pub(crate) fn weaken(self) -> Self {
- DebugInfo::None
+ match self {
+ DebugInfo::None => DebugInfo::None,
+ _ => DebugInfo::Explicit(TomlDebugInfo::None),
+ }
}
} It was a mix of implicit stuff that made this "bug". For your case, if you run |
I missed this bug, sorry for the regression. @weihanglo I wonder why Debuginfo::None exists at all? Can cargo explicitly pass -C debuginfo=0 every time instead? that should avoid caching issues and seems simpler than the fix in your PR. |
Alternatively we could deserialize |
Both seems valid to me, especially the second one. I am not sure why |
BTW my PR is also simple in terms of code added. Just the matrix looks intimidating 😆 |
Problem
After upgrading quickwit-oss/quickwit to rust toolchain 1.69 we discovered that all crates with
edition = 2018
are getting recompiled when we runcargo run
immediately after a successful run ofcargo build
. Upon further investigation, we found thatcargo build
compiles 2018 edition crates with-C debuginfo=0
argument whilecargo run
omits this flag triggering a change of fingerprint and recompilation. Once we replaced the sectionwith
in Cargo.toml the recompilation issues disappeared.
Steps
Unfortunately, I wasn't able to reproduce that on a smaller project, but it is reproducible on a bigger project on Ubuntu 22.04. To reproduce:
protoc
andcmake
installed on your system. It is needed by some dependencies and can be installed by runningsudo apt install -y protobuf-compiler cmake
on ubuntugit clone https://github.com/quickwit-oss/quickwit.git
cd quickwit/quickwit
Cargo.toml
in a text editor and replacedebug = false
withdebug = 0
cargo clean
cargo build
cargo run
debug = 0
withdebug = false
, repeat steps 5-7, observe not recompilation on the step 7.Note: you don't have to wait for the step 6 to finish. Very early in the build it will try to compile the
unicode_ident
crate and incargo build
it will look something like thisBut in
cargo run
it will be compiled like this:The rest is basically just a fallout from this one other dependency recompilation. With
debug = false
the-C debuginfo=0
flag is not present in either builds.Possible Solution(s)
I suspect if might have been caused by the change in the debug value parsing in #11252 but I didn't have time to investigate further.
Notes
The issue is reproducible on
1.69.0
as well as onbeta
andnightly
. It is not reproducible on1.68.2
and below.Version
The text was updated successfully, but these errors were encountered: