Allow targets to override default codegen backend

This commit is contained in:
Maybe Waffle 2024-02-14 23:43:00 +00:00
parent ee9c7c940c
commit a03d19ef63
7 changed files with 130 additions and 46 deletions

View file

@ -2044,6 +2044,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,
@ -2350,6 +2358,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,