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
96 changes: 75 additions & 21 deletions library/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,12 @@ cargo-features = ["profile-rustflags"]

[workspace]
resolver = "1"
members = [
"std",
"sysroot",
"coretests",
"alloctests",
]
members = ["std", "sysroot", "coretests", "alloctests"]

exclude = [
# stdarch has its own Cargo workspace
"stdarch",
"windows_link"
# stdarch has its own Cargo workspace
"stdarch",
"windows_link",
]

[profile.release.package.compiler_builtins]
Expand Down Expand Up @@ -46,13 +41,43 @@ object.debug = 0
rustc-demangle.debug = 0
rustc-demangle.opt-level = "s"

# panic_abort must always be compiled with panic=abort, even when the rest of the
# sysroot is panic=unwind.
[profile.dev.package.panic_abort]
rustflags = ["-Cpanic=abort"]
[profile.dev]
rustflags = [
# `profile.lto=off` implies `-Cembed-bitcode=no`, but unconditionally embedding
# bitcode is necessary for when users enable LTO.
# Required until Cargo can re-build the standard library based on the value
# of `profile.lto` in the user's profile.
"-Cembed-bitcode=yes",
Comment thread
adamgemmell marked this conversation as resolved.
# `std`, `alloc` and `core` imports some dependencies by #[path] (like
# backtrace, core_simd, std_float, ...), those dependencies have their own
# features but cargo isn't involved in the #[path] process and so cannot pass the
# complete list of features, so for that reason we don't enable checking of
# features for std crates.
"--check-cfg=cfg(feature,values(any()))",
# Always enable inlining MIR when building the standard library.
# Without this flag, MIR inlining is disabled when incremental compilation is enabled.
# That causes some mir-opt tests which inline functions from the standard library to
# break when incremental compilation is enabled. So this overrides the "no inlining
# during incremental builds" heuristic for the standard library.
"-Zunstable-options",
Comment thread
adamgemmell marked this conversation as resolved.
"-Zinline-mir",
# Similarly, we need to keep debug info for functions inlined into other std functions,
# even if we're not going to output debuginfo for the crate we're currently building,
# so that it'll be available when downstream consumers of std try to use it.
"-Zinline-mir-preserve-debug",
Comment thread
bjorn3 marked this conversation as resolved.
"-Zmir_strip_debuginfo=locals-in-tiny-functions",
Comment thread
adamgemmell marked this conversation as resolved.
]

[profile.release.package.panic_abort]
rustflags = ["-Cpanic=abort"]
[profile.release]
rustflags = [
# Same as `profile.dev.rustflags`
"-Cembed-bitcode=yes",
"--check-cfg=cfg(feature,values(any()))",
"-Zunstable-options",
"-Zinline-mir",
"-Zinline-mir-preserve-debug",
"-Zmir_strip_debuginfo=locals-in-tiny-functions",
]

# The "dist" profile is used by bootstrap for prebuilt libstd artifacts
# These settings ensure that the prebuilt artifacts support a variety of features
Expand All @@ -62,21 +87,50 @@ inherits = "release"
codegen-units = 1
debug = 1 # "limited"
rustflags = [
# `profile.lto=off` implies `-Cembed-bitcode=no`, but unconditionally embedding
# bitcode is necessary for when users enable LTO.
# Required until Cargo can re-build the standard library based on the value
# of `profile.lto` in the user's profile.
# Inherited from `profile.release.rustflags`
"-Cembed-bitcode=yes",
"--check-cfg=cfg(feature,values(any()))",
"-Zinline-mir",
"-Zinline-mir-preserve-debug",
"-Zmir_strip_debuginfo=locals-in-tiny-functions",

# Enable frame pointers
"-Zunstable-options",
"-Cforce-frame-pointers=non-leaf",
]

[profile.dist.package.panic_abort]

# panic_abort must always be compiled with panic=abort, even when the rest of the
# sysroot is panic=unwind.
[profile.dev.package.panic_abort]
rustflags = [
"-Cpanic=abort",
"-Cembed-bitcode=yes",
"--check-cfg=cfg(feature,values(any()))",
"-Zinline-mir",
"-Zinline-mir-preserve-debug",
"-Zmir-strip-debuginfo=locals-in-tiny-functions",
]

[profile.release.package.panic_abort]
rustflags = [
"-Cpanic=abort",
"-Cembed-bitcode=yes",
"--check-cfg=cfg(feature,values(any()))",
"-Zunstable-options",
"-Zinline-mir",
"-Zinline-mir-preserve-debug",
"-Zmir_strip_debuginfo=locals-in-tiny-functions",
]

[profile.dist.package.panic_abort]
rustflags = [
"-Cpanic=abort",
# Inherited from `profile.dist.rustflags`
"-Cembed-bitcode=yes",
"--check-cfg=cfg(feature,values(any()))",
"-Zinline-mir",
"-Zinline-mir-preserve-debug",
"-Zmir_strip_debuginfo=locals-in-tiny-functions",
"-Cforce-frame-pointers=non-leaf",
]

Expand Down
6 changes: 3 additions & 3 deletions src/bootstrap/src/core/build_steps/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Step for Std {
builder.config.cmd.kind(),
);

std_cargo(builder, target, &mut cargo, &self.crates);
std_cargo(builder, Mode::Std, target, &mut cargo, &self.crates);
if matches!(builder.config.cmd, Subcommand::Fix) {
// By default, cargo tries to fix all targets. Tell it not to fix tests until we've added `test` to the sysroot.
cargo.arg("--lib");
Expand Down Expand Up @@ -137,7 +137,7 @@ impl Step for Std {
Kind::Check,
);

std_cargo(builder, target, &mut cargo, &self.crates);
std_cargo(builder, Mode::Std, target, &mut cargo, &self.crates);

let stamp =
build_stamp::libstd_stamp(builder, build_compiler, target).with_prefix("check-test");
Expand Down Expand Up @@ -511,7 +511,7 @@ pub fn prepare_compiler_for_check(
std_rmeta_sysroot = prepare_std(builder, build_compiler, target);
build_compiler
}
Mode::Std => {
Mode::Std | Mode::DistStd => {
// When checking std stage N, we want to do it with the stage N compiler
// Note: we don't need to build the host stdlib here, because when compiling std, the
// stage 0 stdlib is used to compile build scripts and proc macros.
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/clippy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ impl Step for Std {
Kind::Clippy,
);

std_cargo(builder, target, &mut cargo, &self.crates);
std_cargo(builder, Mode::Std, target, &mut cargo, &self.crates);

let _guard = builder.msg(
Kind::Clippy,
Expand Down
12 changes: 7 additions & 5 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ impl Step for Std {
}

target_deps.extend(self.copy_extra_objects(builder, &build_compiler, target));
let mode = if builder.kind == Kind::Dist { Mode::DistStd } else { Mode::Std };

// We build a sysroot for mir-opt tests using the same trick that Miri does: A check build
// with -Zalways-encode-mir. This frees us from the need to have a target linker, and the
Expand All @@ -251,7 +252,7 @@ impl Step for Std {
let mut cargo = builder::Cargo::new_for_mir_opt_tests(
builder,
build_compiler,
Mode::Std,
mode,
SourceType::InTree,
target,
Kind::Check,
Expand All @@ -264,12 +265,12 @@ impl Step for Std {
let mut cargo = builder::Cargo::new(
builder,
build_compiler,
Mode::Std,
mode,
SourceType::InTree,
target,
Kind::Build,
);
std_cargo(builder, target, &mut cargo, &self.crates);
std_cargo(builder, mode, target, &mut cargo, &self.crates);
cargo
};

Expand All @@ -284,7 +285,7 @@ impl Step for Std {
let _guard = builder.msg(
Kind::Build,
format_args!("library artifacts{}", crate_description(&self.crates)),
Mode::Std,
mode,
build_compiler,
target,
);
Expand Down Expand Up @@ -526,6 +527,7 @@ fn compiler_rt_for_profiler(builder: &Builder<'_>) -> PathBuf {
/// and such.
pub fn std_cargo(
builder: &Builder<'_>,
mode: Mode,
target: TargetSelection,
cargo: &mut Cargo,
crates: &[String],
Expand Down Expand Up @@ -687,7 +689,7 @@ pub fn std_cargo(
}
}

if builder.config.rust_lto == RustcLto::Off {
if mode != Mode::DistStd && builder.config.rust_lto == RustcLto::Off {
cargo.rustflag("-Clto=off");
}

Expand Down
4 changes: 2 additions & 2 deletions src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1011,9 +1011,9 @@ impl Step for Analysis {
}

let src = builder
.stage_out(compiler, Mode::Std)
.stage_out(compiler, Mode::DistStd)
.join(target)
.join(builder.cargo_dir(Mode::Std))
.join(builder.cargo_dir(Mode::DistStd))
.join("deps")
.join("save-analysis");

Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -815,7 +815,7 @@ fn doc_std(
Kind::Doc,
);

compile::std_cargo(builder, target, &mut cargo, requested_crates);
compile::std_cargo(builder, Mode::Std, target, &mut cargo, requested_crates);
cargo
.arg("--no-deps")
.arg("--target-dir")
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3313,7 +3313,7 @@ impl Step for Crate {
.arg("--manifest-path")
.arg(builder.src.join("library/sysroot/Cargo.toml"));
} else {
compile::std_cargo(builder, target, &mut cargo, &[]);
compile::std_cargo(builder, Mode::Std, target, &mut cargo, &[]);
}
}
Mode::Rustc => {
Expand Down
Loading
Loading