Clarify the behavior of rust.codegen-backends
This commit is contained in:
parent
929b3bb4c3
commit
ca6e367e19
5 changed files with 33 additions and 16 deletions
|
|
@ -740,11 +740,19 @@
|
|||
# result (broken, compiling, testing) into this JSON file.
|
||||
#rust.save-toolstates = <none> (path)
|
||||
|
||||
# This is an array of the codegen backends that will be compiled for the rustc
|
||||
# that's being compiled. The default is to only build the LLVM codegen backend,
|
||||
# and currently the only standard options supported are `"llvm"`, `"cranelift"`
|
||||
# and `"gcc"`. The first backend in this list will be used as default by rustc
|
||||
# when no explicit backend is specified.
|
||||
# This array serves three distinct purposes:
|
||||
# - Backends in this list will be automatically compiled and included in the sysroot of each
|
||||
# rustc compiled by bootstrap.
|
||||
# - The first backend in this list will be configured as the **default codegen backend** by each
|
||||
# rustc compiled by bootstrap. In other words, if the first backend is e.g. cranelift, then when
|
||||
# we build a stage 1 rustc, it will by default compile Rust programs using the Cranelift backend.
|
||||
# This also means that stage 2 rustc would get built by the Cranelift backend.
|
||||
# - Running `x dist` (without additional arguments, or with `--include-default-paths`) will produce
|
||||
# a dist component/tarball for the Cranelift backend if it is included in this array.
|
||||
#
|
||||
# Note that the LLVM codegen backend is special and will always be built and distributed.
|
||||
#
|
||||
# Currently, the only standard options supported here are `"llvm"`, `"cranelift"` and `"gcc"`.
|
||||
#rust.codegen-backends = ["llvm"]
|
||||
|
||||
# Indicates whether LLD will be compiled and made available in the sysroot for rustc to execute, and
|
||||
|
|
|
|||
|
|
@ -2190,7 +2190,7 @@ impl Step for Assemble {
|
|||
let _codegen_backend_span =
|
||||
span!(tracing::Level::DEBUG, "building requested codegen backends").entered();
|
||||
|
||||
for backend in builder.config.codegen_backends(target_compiler.host) {
|
||||
for backend in builder.config.enabled_codegen_backends(target_compiler.host) {
|
||||
// FIXME: this is a horrible hack used to make `x check` work when other codegen
|
||||
// backends are enabled.
|
||||
// `x check` will check stage 1 rustc, which copies its rmetas to the stage0 sysroot.
|
||||
|
|
|
|||
|
|
@ -1406,7 +1406,7 @@ impl Step for CraneliftCodegenBackend {
|
|||
let clif_enabled_by_default = run
|
||||
.builder
|
||||
.config
|
||||
.codegen_backends(run.builder.host_target)
|
||||
.enabled_codegen_backends(run.builder.host_target)
|
||||
.contains(&CodegenBackendKind::Cranelift);
|
||||
run.alias("rustc_codegen_cranelift").default_condition(clif_enabled_by_default)
|
||||
}
|
||||
|
|
@ -1437,7 +1437,7 @@ impl Step for CraneliftCodegenBackend {
|
|||
return None;
|
||||
}
|
||||
|
||||
let mut tarball = Tarball::new(builder, &"rustc-codegen-cranelift", &target.triple);
|
||||
let mut tarball = Tarball::new(builder, "rustc-codegen-cranelift", &target.triple);
|
||||
tarball.set_overlay(OverlayKind::RustcCodegenCranelift);
|
||||
tarball.is_preview(true);
|
||||
tarball.add_legal_and_readme_to("share/doc/rustc_codegen_cranelift");
|
||||
|
|
|
|||
|
|
@ -3478,7 +3478,11 @@ impl Step for CodegenCranelift {
|
|||
return;
|
||||
}
|
||||
|
||||
if !builder.config.codegen_backends(run.target).contains(&CodegenBackendKind::Cranelift) {
|
||||
if !builder
|
||||
.config
|
||||
.enabled_codegen_backends(run.target)
|
||||
.contains(&CodegenBackendKind::Cranelift)
|
||||
{
|
||||
builder.info("cranelift not in rust.codegen-backends. skipping");
|
||||
return;
|
||||
}
|
||||
|
|
@ -3605,7 +3609,7 @@ impl Step for CodegenGCC {
|
|||
return;
|
||||
}
|
||||
|
||||
if !builder.config.codegen_backends(run.target).contains(&CodegenBackendKind::Gcc) {
|
||||
if !builder.config.enabled_codegen_backends(run.target).contains(&CodegenBackendKind::Gcc) {
|
||||
builder.info("gcc not in rust.codegen-backends. skipping");
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1977,19 +1977,24 @@ impl Config {
|
|||
.unwrap_or(self.profiler)
|
||||
}
|
||||
|
||||
pub fn codegen_backends(&self, target: TargetSelection) -> &[CodegenBackendKind] {
|
||||
/// Returns codegen backends that should be:
|
||||
/// - Built and added to the sysroot when we build the compiler.
|
||||
/// - Distributed when `x dist` is executed (if the codegen backend has a dist step).
|
||||
pub fn enabled_codegen_backends(&self, target: TargetSelection) -> &[CodegenBackendKind] {
|
||||
self.target_config
|
||||
.get(&target)
|
||||
.and_then(|cfg| cfg.codegen_backends.as_deref())
|
||||
.unwrap_or(&self.rust_codegen_backends)
|
||||
}
|
||||
|
||||
pub fn jemalloc(&self, target: TargetSelection) -> bool {
|
||||
self.target_config.get(&target).and_then(|cfg| cfg.jemalloc).unwrap_or(self.jemalloc)
|
||||
/// Returns the codegen backend that should be configured as the *default* codegen backend
|
||||
/// for a rustc compiled by bootstrap.
|
||||
pub fn default_codegen_backend(&self, target: TargetSelection) -> Option<CodegenBackendKind> {
|
||||
self.enabled_codegen_backends(target).first().cloned()
|
||||
}
|
||||
|
||||
pub fn default_codegen_backend(&self, target: TargetSelection) -> Option<CodegenBackendKind> {
|
||||
self.codegen_backends(target).first().cloned()
|
||||
pub fn jemalloc(&self, target: TargetSelection) -> bool {
|
||||
self.target_config.get(&target).and_then(|cfg| cfg.jemalloc).unwrap_or(self.jemalloc)
|
||||
}
|
||||
|
||||
pub fn rpath_enabled(&self, target: TargetSelection) -> bool {
|
||||
|
|
@ -2004,7 +2009,7 @@ impl Config {
|
|||
}
|
||||
|
||||
pub fn llvm_enabled(&self, target: TargetSelection) -> bool {
|
||||
self.codegen_backends(target).contains(&CodegenBackendKind::Llvm)
|
||||
self.enabled_codegen_backends(target).contains(&CodegenBackendKind::Llvm)
|
||||
}
|
||||
|
||||
pub fn llvm_libunwind(&self, target: TargetSelection) -> LlvmLibunwind {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue