cargo-features = ["profile-rustflags"]

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

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

[profile.release.package.compiler_builtins]
# For compiler-builtins we always use a high number of codegen units.
# The goal here is to place every single intrinsic into its own object
# file to avoid symbol clashes with the system libgcc if possible. Note
# that this number doesn't actually produce this many object files, we
# just don't create more than this number of object files.
#
# It's a bit of a bummer that we have to pass this here, unfortunately.
# Ideally this would be specified through an env var to Cargo so Cargo
# knows how many CGUs are for this specific crate, but for now
# per-crate configuration isn't specifiable in the environment.
codegen-units = 10000

# These dependencies of the standard library implement symbolication for
# backtraces on most platforms. Their debuginfo causes both linking to be slower
# (more data to chew through) and binaries to be larger without really all that
# much benefit. This section turns them all to down to have no debuginfo which
# helps to improve link times a little bit.
[profile.release.package]
addr2line.debug = 0
addr2line.opt-level = "s"
adler2.debug = 0
gimli.debug = 0
gimli.opt-level = "s"
miniz_oxide.debug = 0
miniz_oxide.opt-level = "s"
# `opt-level = "s"` for `object` led to a size regression when tried previously
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.release.package.panic_abort]
rustflags = ["-Cpanic=abort"]

# 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.
[profile.dist]
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.
    "-Cembed-bitcode=yes",
    # Enable frame pointers
    "-Zunstable-options",
    "-Cforce-frame-pointers=non-leaf",
]

[profile.dist.package.panic_abort]
rustflags = [
    "-Cpanic=abort",
    "-Cembed-bitcode=yes",
    "-Zunstable-options",
    "-Cforce-frame-pointers=non-leaf",
]

[patch.crates-io]
# See comments in `library/rustc-std-workspace-core/README.md` for what's going on here
rustc-std-workspace-core = { path = 'rustc-std-workspace-core' }
rustc-std-workspace-alloc = { path = 'rustc-std-workspace-alloc' }
rustc-std-workspace-std = { path = 'rustc-std-workspace-std' }
