diff --git a/compiler/rustc_interface/src/util.rs b/compiler/rustc_interface/src/util.rs index 23b152bd57240..4c28160c1082c 100644 --- a/compiler/rustc_interface/src/util.rs +++ b/compiler/rustc_interface/src/util.rs @@ -121,7 +121,16 @@ pub(crate) fn check_abi_required_features(sess: &Session) { } pub static STACK_SIZE: OnceLock = OnceLock::new(); -pub const DEFAULT_STACK_SIZE: usize = 16 * 1024 * 1024; +pub const DEFAULT_STACK_SIZE: usize = { + let mut base = 16; + + // Increase size by 50% with larger pointers + if size_of::<*const ()>() > 4 { + base += base / 2; + } + + base * 1024 * 1024 +}; fn init_stack_size(early_dcx: &EarlyDiagCtxt) -> usize { // Obey the environment setting or default diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index b67d1b1bd49e7..31c5fd52c09a6 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -19,7 +19,7 @@ use crate::core::build_steps::toolstate::ToolState; use crate::core::build_steps::{compile, llvm}; use crate::core::builder::{ self, Builder, Cargo as CargoCommand, CommandLineStep, Kind, RunConfig, ShouldRun, Step, - StepMetadata, apply_pgo, cargo_profile_var, + StepMetadata, apply_pgo, }; use crate::core::compiler::Compiler; use crate::core::config::{Allocator, DebuginfoLevel, RustcLto, TargetSelection}; @@ -126,14 +126,26 @@ impl Step for ToolBuild { if is_lto_stage(&self.build_compiler) && (self.mode == Mode::ToolRustcPrivate || self.path == "src/tools/cargo") { - let lto = match builder.config.rust_lto { - RustcLto::Off => Some("off"), - RustcLto::Thin => Some("thin"), - RustcLto::Fat => Some("fat"), - RustcLto::ThinLocal => None, - }; - if let Some(lto) = lto { - cargo.env(cargo_profile_var("LTO", &builder.config, self.mode), lto); + // We don't use Cargo's LTO setting here to workaround https://github.com/rust-lang/cargo/issues/14575 + // FIXME: Move back to Cargo profiles which were done + // before PR #128947 once rust-lang/cargo#14575 is fixed + if let RustcLto::Thin | RustcLto::Fat = builder.config.rust_lto { + // Since using LTO for optimizing dylibs is currently experimental, + // we need to pass -Zdylib-lto since proc macros are dylibs. + cargo.rustflag("-Zdylib-lto"); + cargo.rustflag("-Cembed-bitcode=yes"); + } + match builder.config.rust_lto { + RustcLto::Thin => { + cargo.rustflag("-Clto=thin"); + } + RustcLto::Fat => { + cargo.rustflag("-Clto=fat"); + } + RustcLto::ThinLocal => { /* Do nothing, this is the default */ } + RustcLto::Off => { + cargo.rustflag("-Clto=off"); + } } } diff --git a/src/bootstrap/src/core/builder/mod.rs b/src/bootstrap/src/core/builder/mod.rs index 6f30f3b56f8b8..1ccf427b5299f 100644 --- a/src/bootstrap/src/core/builder/mod.rs +++ b/src/bootstrap/src/core/builder/mod.rs @@ -13,7 +13,7 @@ use clap::ValueEnum; #[cfg(feature = "tracing")] use tracing::instrument; -pub(crate) use self::cargo::{Cargo, apply_pgo, cargo_profile_var}; +pub(crate) use self::cargo::{Cargo, apply_pgo}; use crate::core::build_steps::compile::{Std, StdLink, looks_like_codegen_backend}; use crate::core::build_steps::tool::RustcPrivateCompilers; use crate::core::build_steps::{ diff --git a/src/ci/github-actions/jobs.yml b/src/ci/github-actions/jobs.yml index 08121a9a693b7..71073e8a455e3 100644 --- a/src/ci/github-actions/jobs.yml +++ b/src/ci/github-actions/jobs.yml @@ -801,6 +801,7 @@ auto: --target=x86_64-pc-windows-msvc --enable-full-tools --enable-profiler + --set rust.lto=thin --set rust.codegen-units=1 SCRIPT: python x.py build --set rust.debug=true opt-dist && PGO_HOST=x86_64-pc-windows-msvc ./build/x86_64-pc-windows-msvc/stage1-tools-bin/opt-dist windows-ci -- python x.py dist bootstrap --include-default-paths DIST_REQUIRE_ALL_TOOLS: 1