Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion compiler/rustc_interface/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,16 @@ pub(crate) fn check_abi_required_features(sess: &Session) {
}

pub static STACK_SIZE: OnceLock<usize> = 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
Expand Down
30 changes: 21 additions & 9 deletions src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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
Comment thread
jieyouxu marked this conversation as resolved.
// 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");
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::{
Expand Down
1 change: 1 addition & 0 deletions src/ci/github-actions/jobs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading