@@ -352,7 +352,7 @@ top_level_options!(
352352 actually_rustdoc: bool [ TRACKED ] ,
353353
354354 // Number of object files/codegen units to produce on the backend
355- codegen_units : usize [ UNTRACKED ] ,
355+ cli_forced_codegen_units : Option < usize > [ UNTRACKED ] ,
356356 }
357357) ;
358358
@@ -505,7 +505,7 @@ pub fn basic_options() -> Options {
505505 unstable_features : UnstableFeatures :: Disallow ,
506506 debug_assertions : true ,
507507 actually_rustdoc : false ,
508- codegen_units : 1 ,
508+ cli_forced_codegen_units : None ,
509509 }
510510}
511511
@@ -1711,48 +1711,6 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
17111711
17121712 let incremental = debugging_opts. incremental . as_ref ( ) . map ( |m| PathBuf :: from ( m) ) ;
17131713
1714- let codegen_units = codegen_units. unwrap_or_else ( || {
1715- match opt_level {
1716- // If we're compiling at `-O0` then default to 16 codegen units.
1717- // The number here shouldn't matter too too much as debug mode
1718- // builds don't rely on performance at all, meaning that lost
1719- // opportunities for inlining through multiple codegen units is
1720- // a non-issue.
1721- //
1722- // Note that the high number here doesn't mean that we'll be
1723- // spawning a large number of threads in parallel. The backend
1724- // of rustc contains global rate limiting through the
1725- // `jobserver` crate so we'll never overload the system with too
1726- // much work, but rather we'll only be optimizing when we're
1727- // otherwise cooperating with other instances of rustc.
1728- //
1729- // Rather the high number here means that we should be able to
1730- // keep a lot of idle cpus busy. By ensuring that no codegen
1731- // unit takes *too* long to build we'll be guaranteed that all
1732- // cpus will finish pretty closely to one another and we should
1733- // make relatively optimal use of system resources
1734- //
1735- // Another note worth mentioning here, however, is that this number
1736- // isn't *too* high. When codegen units are increased that means we
1737- // currently have to codegen `#[inline]` functions into each codegen
1738- // unit, which means the more codegen units we're using the more we
1739- // may be generating. In other words, increasing codegen units may
1740- // increase the overall work the compiler does. If we don't have
1741- // enough cores to make up for this loss then increasing the number
1742- // of codegen units could become an overall loss!
1743- //
1744- // As a result we choose a hopefully conservative value 16, which
1745- // should be more than the number of cpus of most hardware compiling
1746- // Rust but also not too much for 2-4 core machines to have too much
1747- // loss of compile time.
1748- OptLevel :: No => 16 ,
1749-
1750- // All other optimization levels default use one codegen unit,
1751- // the historical default in Rust for a Long Time.
1752- _ => 1 ,
1753- }
1754- } ) ;
1755-
17561714 ( Options {
17571715 crate_types,
17581716 optimize : opt_level,
@@ -1777,7 +1735,7 @@ pub fn build_session_options_and_crate_config(matches: &getopts::Matches)
17771735 unstable_features : UnstableFeatures :: from_environment ( ) ,
17781736 debug_assertions,
17791737 actually_rustdoc : false ,
1780- codegen_units,
1738+ cli_forced_codegen_units : codegen_units,
17811739 } ,
17821740 cfg)
17831741}
0 commit comments