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 @@ -2184,6 +2184,12 @@ pub fn build_session_options_and_crate_config(
21842184 TargetTriple :: from_triple ( host_triple ( ) )
21852185 } ;
21862186 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(_)`.
21872193 let max_o = matches. opt_positions ( "O" ) . into_iter ( ) . max ( ) ;
21882194 let max_c = matches. opt_strs_pos ( "C" ) . into_iter ( ) . flat_map ( |( i, s) | {
21892195 if let Some ( "opt-level" ) = s. splitn ( 2 , '=' ) . next ( ) {
@@ -2216,6 +2222,9 @@ pub fn build_session_options_and_crate_config(
22162222 }
22172223 }
22182224 } ;
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.
22192228 let debug_assertions = cg. debug_assertions . unwrap_or ( opt_level == OptLevel :: No ) ;
22202229 let max_g = matches. opt_positions ( "g" ) . into_iter ( ) . max ( ) ;
22212230 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