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.
|
# result (broken, compiling, testing) into this JSON file.
|
||||||
#rust.save-toolstates = <none> (path)
|
#rust.save-toolstates = <none> (path)
|
||||||
|
|
||||||
# This is an array of the codegen backends that will be compiled for the rustc
|
# This array serves three distinct purposes:
|
||||||
# that's being compiled. The default is to only build the LLVM codegen backend,
|
# - Backends in this list will be automatically compiled and included in the sysroot of each
|
||||||
# and currently the only standard options supported are `"llvm"`, `"cranelift"`
|
# rustc compiled by bootstrap.
|
||||||
# and `"gcc"`. The first backend in this list will be used as default by rustc
|
# - The first backend in this list will be configured as the **default codegen backend** by each
|
||||||
# when no explicit backend is specified.
|
# 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"]
|
#rust.codegen-backends = ["llvm"]
|
||||||
|
|
||||||
# Indicates whether LLD will be compiled and made available in the sysroot for rustc to execute, and
|
# 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 =
|
let _codegen_backend_span =
|
||||||
span!(tracing::Level::DEBUG, "building requested codegen backends").entered();
|
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
|
// FIXME: this is a horrible hack used to make `x check` work when other codegen
|
||||||
// backends are enabled.
|
// backends are enabled.
|
||||||
// `x check` will check stage 1 rustc, which copies its rmetas to the stage0 sysroot.
|
// `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
|
let clif_enabled_by_default = run
|
||||||
.builder
|
.builder
|
||||||
.config
|
.config
|
||||||
.codegen_backends(run.builder.host_target)
|
.enabled_codegen_backends(run.builder.host_target)
|
||||||
.contains(&CodegenBackendKind::Cranelift);
|
.contains(&CodegenBackendKind::Cranelift);
|
||||||
run.alias("rustc_codegen_cranelift").default_condition(clif_enabled_by_default)
|
run.alias("rustc_codegen_cranelift").default_condition(clif_enabled_by_default)
|
||||||
}
|
}
|
||||||
|
|
@ -1437,7 +1437,7 @@ impl Step for CraneliftCodegenBackend {
|
||||||
return None;
|
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.set_overlay(OverlayKind::RustcCodegenCranelift);
|
||||||
tarball.is_preview(true);
|
tarball.is_preview(true);
|
||||||
tarball.add_legal_and_readme_to("share/doc/rustc_codegen_cranelift");
|
tarball.add_legal_and_readme_to("share/doc/rustc_codegen_cranelift");
|
||||||
|
|
|
||||||
|
|
@ -3478,7 +3478,11 @@ impl Step for CodegenCranelift {
|
||||||
return;
|
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");
|
builder.info("cranelift not in rust.codegen-backends. skipping");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -3605,7 +3609,7 @@ impl Step for CodegenGCC {
|
||||||
return;
|
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");
|
builder.info("gcc not in rust.codegen-backends. skipping");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1977,19 +1977,24 @@ impl Config {
|
||||||
.unwrap_or(self.profiler)
|
.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
|
self.target_config
|
||||||
.get(&target)
|
.get(&target)
|
||||||
.and_then(|cfg| cfg.codegen_backends.as_deref())
|
.and_then(|cfg| cfg.codegen_backends.as_deref())
|
||||||
.unwrap_or(&self.rust_codegen_backends)
|
.unwrap_or(&self.rust_codegen_backends)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn jemalloc(&self, target: TargetSelection) -> bool {
|
/// Returns the codegen backend that should be configured as the *default* codegen backend
|
||||||
self.target_config.get(&target).and_then(|cfg| cfg.jemalloc).unwrap_or(self.jemalloc)
|
/// 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> {
|
pub fn jemalloc(&self, target: TargetSelection) -> bool {
|
||||||
self.codegen_backends(target).first().cloned()
|
self.target_config.get(&target).and_then(|cfg| cfg.jemalloc).unwrap_or(self.jemalloc)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn rpath_enabled(&self, target: TargetSelection) -> bool {
|
pub fn rpath_enabled(&self, target: TargetSelection) -> bool {
|
||||||
|
|
@ -2004,7 +2009,7 @@ impl Config {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn llvm_enabled(&self, target: TargetSelection) -> bool {
|
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 {
|
pub fn llvm_libunwind(&self, target: TargetSelection) -> LlvmLibunwind {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue