File tree 1 file changed +9
-0
lines changed
1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -2184,6 +2184,12 @@ pub fn build_session_options_and_crate_config(
2184
2184
TargetTriple :: from_triple ( host_triple ( ) )
2185
2185
} ;
2186
2186
let opt_level = {
2187
+ // The `-O` and `-C opt-level` flags specify the same setting, so we want to be able
2188
+ // to use them interchangeably. However, because they're technically different flags,
2189
+ // we need to work out manually which should take precedence if both are supplied (i.e.
2190
+ // the rightmost flag). We do this by finding the (rightmost) position of both flags and
2191
+ // comparing them. Note that if a flag is not found, its position will be `None`, which
2192
+ // always compared less than `Some(_)`.
2187
2193
let max_o = matches. opt_positions ( "O" ) . into_iter ( ) . max ( ) ;
2188
2194
let max_c = matches. opt_strs_pos ( "C" ) . into_iter ( ) . flat_map ( |( i, s) | {
2189
2195
if let Some ( "opt-level" ) = s. splitn ( 2 , '=' ) . next ( ) {
@@ -2216,6 +2222,9 @@ pub fn build_session_options_and_crate_config(
2216
2222
}
2217
2223
}
2218
2224
} ;
2225
+ // The `-g` and `-C debuginfo` flags specify the same setting, so we want to be able
2226
+ // to use them interchangeably. See the note above (regarding `-O` and `-C opt-level`)
2227
+ // for more details.
2219
2228
let debug_assertions = cg. debug_assertions . unwrap_or ( opt_level == OptLevel :: No ) ;
2220
2229
let max_g = matches. opt_positions ( "g" ) . into_iter ( ) . max ( ) ;
2221
2230
let max_c = matches. opt_strs_pos ( "C" ) . into_iter ( ) . flat_map ( |( i, s) | {
You can’t perform that action at this time.
0 commit comments