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