File tree 2 files changed +29
-7
lines changed 2 files changed +29
-7
lines changed Original file line number Diff line number Diff line change @@ -106,18 +106,21 @@ fn calculate(
106
106
} ;
107
107
// LTO can only be performed if *all* of the crate types support it.
108
108
// For example, a cdylib/rlib combination won't allow LTO.
109
- let can_not_lto_types = crate_types
109
+ let not_lto_types = crate_types
110
110
. iter ( )
111
111
. filter ( |ct| !ct. can_lto ( ) )
112
112
. map ( |ct| ct. as_str ( ) )
113
113
. collect :: < Vec < _ > > ( ) ;
114
- let all_lto_types = can_not_lto_types . len ( ) == 0 ;
114
+ let all_lto_types = not_lto_types . len ( ) == 0 ;
115
115
if !all_lto_types {
116
- bcx. config . shell ( ) . warn ( format ! (
117
- "LTO can only be performed if all of the crate types support it,\
118
- you have some crate types do not support LTO: {}",
119
- can_not_lto_types. join( "," ) ,
120
- ) ) ?;
116
+ if let profiles:: Lto :: Named ( _) | profiles:: Lto :: Bool ( _) = unit. profile . lto {
117
+ bcx. config . shell ( ) . warn ( format ! (
118
+ "LTO can only be performed if all of the crate types support it, \
119
+ package `{}` have some crate types do not support LTO: {}",
120
+ unit. pkg. name( ) ,
121
+ not_lto_types. join( "," ) ,
122
+ ) ) ?;
123
+ }
121
124
}
122
125
// Compute the LTO based on the profile, and what our parent requires.
123
126
let lto = if unit. target . for_host ( ) {
Original file line number Diff line number Diff line change @@ -624,6 +624,25 @@ fn dylib() {
624
624
. run ( ) ;
625
625
}
626
626
627
+ #[ cargo_test]
628
+ fn lto_with_unsupported_crate_types ( ) {
629
+ let p = project_with_dep ( "'dylib','rlib'" ) ;
630
+ p. cargo ( "build --release -v" )
631
+ . with_stderr_contains (
632
+ "\
633
+ [WARNING] LTO can only be performed if all of the crate types support it, \
634
+ package `bar` have some crate types do not support LTO: dylib,rlib
635
+ [WARNING] LTO can only be performed if all of the crate types support it, \
636
+ package `registry` have some crate types do not support LTO: lib
637
+ [WARNING] LTO can only be performed if all of the crate types support it, \
638
+ package `registry-shared` have some crate types do not support LTO: lib
639
+ [WARNING] LTO can only be performed if all of the crate types support it, \
640
+ package `registry-shared` have some crate types do not support LTO: lib
641
+ " ,
642
+ )
643
+ . run ( ) ;
644
+ }
645
+
627
646
#[ cargo_test]
628
647
fn test_profile ( ) {
629
648
Package :: new ( "bar" , "0.0.1" )
You can’t perform that action at this time.
0 commit comments