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
106 changes: 88 additions & 18 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,36 +41,111 @@ 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"]
# Until CI is moved to using the dist profile (via `--dist-std`), dev and release should copy the
# settings in the dist profile
[profile.dev]
codegen-units = 1
debug = 1 # "limited"
rustflags = [
# Same as `profile.dist.rustflags`
"--check-cfg=cfg(feature,values(any()))",
"-Zunstable-options",
"-Cembed-bitcode=yes",
"-Zinline-mir",
Comment thread
adamgemmell marked this conversation as resolved.
"-Zinline-mir-preserve-debug",
Comment thread
bjorn3 marked this conversation as resolved.
"-Zmir-strip-debuginfo=locals-in-tiny-functions",
"-Cforce-frame-pointers=non-leaf",
]

[profile.release.package.panic_abort]
rustflags = ["-Cpanic=abort"]
[profile.release]
codegen-units = 1
debug = 1 # "limited"
rustflags = [
# Same as `profile.dist.rustflags`
"--check-cfg=cfg(feature,values(any()))",
"-Zunstable-options",
"-Cembed-bitcode=yes",
"-Zinline-mir",
"-Zinline-mir-preserve-debug",
"-Zmir-strip-debuginfo=locals-in-tiny-functions",
"-Cforce-frame-pointers=non-leaf",
]

# The "dist" profile is used by bootstrap for prebuilt libstd artifacts
# These settings ensure that the prebuilt artifacts support a variety of features
# in the user's profile.
# The "dist" profile is used by bootstrap when `--dist-std` is provided, and in the future will be
# used for all prebuilt standard library artifacts.
# These settings ensure that the prebuilt artifacts support a variety of features in the user's
# profile.
[profile.dist]
inherits = "release"
codegen-units = 1
debug = 1 # "limited"
rustflags = [
# `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()))",
# Sometimes bootstrap sets rustflags with unstable options, so we preemptively pass it
# here just in case.
"-Zunstable-options",
# `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",
# 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.
"-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",
"-Zmir-strip-debuginfo=locals-in-tiny-functions",
# Enable frame pointers
"-Cforce-frame-pointers=non-leaf",
]

# 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",
# Inherited from `profile.dev.rustflags`
"--check-cfg=cfg(feature,values(any()))",
"-Zunstable-options",
"-Cembed-bitcode=yes",
"-Zinline-mir",
"-Zinline-mir-preserve-debug",
"-Zmir-strip-debuginfo=locals-in-tiny-functions",
"-Cforce-frame-pointers=non-leaf",
]

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

[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",
"-Zunstable-options",
"-Cforce-frame-pointers=non-leaf",
]
Expand Down
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,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
7 changes: 4 additions & 3 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ impl CommandLineStep for Std {
}

target_deps.extend(self.copy_extra_objects(builder, &build_compiler, target));
let mode = if builder.sess.config.cmd.dist_std() { 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 @@ -252,7 +253,7 @@ impl CommandLineStep 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 @@ -265,7 +266,7 @@ impl CommandLineStep for Std {
let mut cargo = builder::Cargo::new(
builder,
build_compiler,
Mode::Std,
mode,
SourceType::InTree,
target,
Kind::Build,
Expand All @@ -285,7 +286,7 @@ impl CommandLineStep for Std {
let _guard = builder.msg(
Kind::Build,
format_args!("library artifacts{}", crate_description(&self.crates)),
Mode::Std,
mode,
build_compiler,
target,
);
Expand Down
7 changes: 4 additions & 3 deletions src/bootstrap/src/core/build_steps/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3385,7 +3385,7 @@ fn run_cargo_test<'a>(
) -> bool {
let compiler = cargo.compiler();
let stage = match cargo.mode() {
Mode::Std => compiler.stage,
Mode::Std | Mode::DistStd => compiler.stage,
_ => compiler.stage + 1,
};

Expand Down Expand Up @@ -3519,7 +3519,8 @@ impl CommandLineStep for Crate {
.map(|p| builder.crate_paths[&p.assert_single_path().path].clone())
.collect();

builder.ensure(Crate { build_compiler, target: run.target, mode: Mode::Std, crates });
let mode = if builder.sess.config.cmd.dist_std() { Mode::DistStd } else { Mode::Std };
builder.ensure(Crate { build_compiler, target: run.target, mode, crates });
}

/// Runs all unit tests plus documentation tests for a given crate defined
Expand Down Expand Up @@ -3603,7 +3604,7 @@ impl CommandLineStep for Crate {
};

match mode {
Mode::Std => {
Mode::Std | Mode::DistStd => {
if builder.kind == Kind::Miri {
// We can't use `std_cargo` as that uses `optimized-compiler-builtins` which
// needs host tools for the given target. This is similar to what `compile::Std`
Expand Down
Loading
Loading