File tree 2 files changed +22
-1
lines changed
2 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -643,7 +643,7 @@ impl Default for Profile {
643
643
rpath : false ,
644
644
incremental : false ,
645
645
panic : PanicStrategy :: Unwind ,
646
- strip : Strip :: Resolved ( StripInner :: None ) ,
646
+ strip : Strip :: Deferred ( StripInner :: None ) ,
647
647
rustflags : vec ! [ ] ,
648
648
trim_paths : None ,
649
649
}
@@ -926,6 +926,15 @@ impl Strip {
926
926
Strip :: Resolved ( v) | Strip :: Deferred ( v) => v,
927
927
}
928
928
}
929
+
930
+ pub ( crate ) fn is_deferred ( & self ) -> bool {
931
+ matches ! ( self , Strip :: Deferred ( _) )
932
+ }
933
+
934
+ /// Reset to stripping debuginfo.
935
+ pub ( crate ) fn strip_debuginfo ( self ) -> Self {
936
+ Strip :: Resolved ( StripInner :: Named ( "debuginfo" . into ( ) ) )
937
+ }
929
938
}
930
939
931
940
impl PartialEq for Strip {
Original file line number Diff line number Diff line change @@ -657,6 +657,18 @@ fn traverse_and_share(
657
657
} ;
658
658
659
659
let mut profile = unit. profile . clone ( ) ;
660
+ if profile. strip . is_deferred ( ) {
661
+ // If strip was not manually set, and all dependencies of this unit together
662
+ // with this unit have debuginfo turned off, we enable debuginfo stripping.
663
+ // This will remove pre-existing debug symbols coming from the standard library.
664
+ if !profile. debuginfo . is_turned_on ( )
665
+ && new_deps
666
+ . iter ( )
667
+ . all ( |dep| !dep. unit . profile . debuginfo . is_turned_on ( ) )
668
+ {
669
+ profile. strip = profile. strip . strip_debuginfo ( ) ;
670
+ }
671
+ }
660
672
661
673
// If this is a build dependency, and it's not shared with runtime dependencies, we can weaken
662
674
// its debuginfo level to optimize build times. We do nothing if it's an artifact dependency,
You can’t perform that action at this time.
0 commit comments