Rollup merge of #116793 - WaffleLapkin:target_rules_the_backend, r=cjgillot

Allow targets to override default codegen backend

Implements https://github.com/rust-lang/compiler-team/issues/670.
This commit is contained in:
Jubilee 2024-03-11 09:29:32 -07:00 committed by GitHub
commit 86af4d25a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 117 additions and 59 deletions

View file

@ -2070,6 +2070,14 @@ pub struct TargetOptions {
/// Default number of codegen units to use in debug mode
pub default_codegen_units: Option<u64>,
/// Default codegen backend used for this target. Defaults to `None`.
///
/// If `None`, then `CFG_DEFAULT_CODEGEN_BACKEND` environmental variable captured when
/// compiling `rustc` will be used instead (or llvm if it is not set).
///
/// N.B. when *using* the compiler, backend can always be overriden with `-Zcodegen-backend`.
pub default_codegen_backend: Option<StaticCow<str>>,
/// Whether to generate trap instructions in places where optimization would
/// otherwise produce control flow that falls through into unrelated memory.
pub trap_unreachable: bool,
@ -2376,6 +2384,7 @@ impl Default for TargetOptions {
stack_probes: StackProbeType::None,
min_global_align: None,
default_codegen_units: None,
default_codegen_backend: None,
trap_unreachable: true,
requires_lto: false,
singlethread: false,