@@ -440,19 +440,15 @@ impl ProfileMaker {
440
440
profile. codegen_units = None ;
441
441
442
442
// For build dependencies, we usually don't need debuginfo, and
443
- // removing it will compile faster, much like the default opt-level
444
- // of 0 is chosen for faster builds. However, that can conflict with
443
+ // removing it will compile faster. However, that can conflict with
445
444
// a unit graph optimization, reusing units that are shared between
446
445
// build dependencies and runtime dependencies: when the runtime
447
446
// target is the same as the build host, we only need to build a
448
447
// dependency once and reuse the results, instead of building twice.
449
- // If we then also change the default debuginfo level for build
450
- // dependencies, we can lose the sharing: build dependencies will be
451
- // built without debuginfo, while runtime dependencies require it by
452
- // default. So we allow cargo to weaken the debuginfo level: only if
453
- // there is not sharing already, will we disable debuginfo: if there
454
- // is no sharing, we will use the preferred value, and if there is
455
- // sharing we will use the explicit value set.
448
+ // We defer the choice of the debuginfo level until we can check if
449
+ // a unit is shared. If that's the case, we'll use the deferred value
450
+ // below so the unit can be reused, otherwise we can avoid emitting
451
+ // the unit's debuginfo.
456
452
if let Some ( debuginfo) = profile. debuginfo . to_option ( ) {
457
453
profile. debuginfo = DebugInfo :: Deferred ( debuginfo) ;
458
454
}
@@ -726,9 +722,10 @@ impl Profile {
726
722
}
727
723
}
728
724
729
- /// The debuginfo level in a given profile. This is semantically an
730
- /// `Option<u32>`, and should be used as so via the `to_option` method for all
731
- /// intents and purposes:
725
+ /// The debuginfo level setting.
726
+ ///
727
+ /// This is semantically an `Option<u32>`, and should be used as so via the
728
+ /// [DebugInfo::to_option] method for all intents and purposes:
732
729
/// - `DebugInfo::None` corresponds to `None`
733
730
/// - `DebugInfo::Explicit(u32)` and `DebugInfo::Deferred` correspond to
734
731
/// `Option<u32>::Some`
@@ -742,16 +739,19 @@ impl Profile {
742
739
/// the unit is only built once and the unit graph is still optimized.
743
740
#[ derive( Debug , Copy , Clone ) ]
744
741
pub enum DebugInfo {
745
- /// No debuginfo
742
+ /// No debuginfo level was set.
746
743
None ,
747
- /// A debuginfo level that is explicitly set.
744
+ /// A debuginfo level that is explicitly set, by a profile or a user .
748
745
Explicit ( u32 ) ,
749
746
/// For internal purposes: a deferred debuginfo level that can be optimized
750
- /// away but has a default value otherwise.
751
- /// Behaves like `Explicit` in all situations except when dependencies are
752
- /// shared between build dependencies and runtime dependencies. The former
753
- /// case can be optimized, in all other situations this level value will be
754
- /// the one to use.
747
+ /// away, but has this value otherwise.
748
+ ///
749
+ /// Behaves like `Explicit` in all situations except for the default build
750
+ /// dependencies profile: whenever a build dependency is not shared with
751
+ /// runtime dependencies, this level is weakened to a lower level that is
752
+ /// faster to build (see [DebugInfo::weaken]).
753
+ ///
754
+ /// In all other situations, this level value will be the one to use.
755
755
Deferred ( u32 ) ,
756
756
}
757
757
0 commit comments