diff options
| author | Ralf Jung <post@ralfj.de> | 2020-09-20 15:51:48 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-20 15:51:48 +0200 |
| commit | c847eaa91dacf2a5b1f110142f930ea81a7ec2f3 (patch) | |
| tree | 900bb9354390697b563aded672dd228a2f4381bf /compiler/rustc_session/src | |
| parent | 39b9a25e60db0a3d22b115bdb3981607ea4c0737 (diff) | |
| parent | 48655c2d2ca8590c7627f32839ba921297290a1a (diff) | |
| download | rust-c847eaa91dacf2a5b1f110142f930ea81a7ec2f3.tar.gz rust-c847eaa91dacf2a5b1f110142f930ea81a7ec2f3.zip | |
Rollup merge of #76832 - khyperia:backend_target_override, r=eddyb
Let backends define custom targets Add a target_override hook that takes priority over builtin targets.
Diffstat (limited to 'compiler/rustc_session/src')
| -rw-r--r-- | compiler/rustc_session/src/config.rs | 9 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 3 |
2 files changed, 7 insertions, 5 deletions
diff --git a/compiler/rustc_session/src/config.rs b/compiler/rustc_session/src/config.rs index 3f12596a236..8d004675d7f 100644 --- a/compiler/rustc_session/src/config.rs +++ b/compiler/rustc_session/src/config.rs @@ -818,10 +818,11 @@ pub fn build_configuration(sess: &Session, mut user_cfg: CrateConfig) -> CrateCo user_cfg } -pub fn build_target_config(opts: &Options, error_format: ErrorOutputType) -> Config { - let target = Target::search(&opts.target_triple).unwrap_or_else(|e| { +pub fn build_target_config(opts: &Options, target_override: Option<Target>) -> Config { + let target_result = target_override.map_or_else(|| Target::search(&opts.target_triple), Ok); + let target = target_result.unwrap_or_else(|e| { early_error( - error_format, + opts.error_format, &format!( "Error loading target specification: {}. \ Use `--print target-list` for a list of built-in targets", @@ -835,7 +836,7 @@ pub fn build_target_config(opts: &Options, error_format: ErrorOutputType) -> Con "32" => 32, "64" => 64, w => early_error( - error_format, + opts.error_format, &format!( "target specification was invalid: \ unrecognized target-pointer-width {}", diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index 974f4c31bb6..ff67d3cb107 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1234,6 +1234,7 @@ pub fn build_session( diagnostics_output: DiagnosticOutput, driver_lint_caps: FxHashMap<lint::LintId, lint::Level>, file_loader: Option<Box<dyn FileLoader + Send + Sync + 'static>>, + target_override: Option<Target>, ) -> Session { // FIXME: This is not general enough to make the warning lint completely override // normal diagnostic warnings, since the warning lint can also be denied and changed @@ -1253,7 +1254,7 @@ pub fn build_session( DiagnosticOutput::Raw(write) => Some(write), }; - let target_cfg = config::build_target_config(&sopts, sopts.error_format); + let target_cfg = config::build_target_config(&sopts, target_override); let host_triple = TargetTriple::from_triple(config::host_triple()); let host = Target::search(&host_triple).unwrap_or_else(|e| { early_error(sopts.error_format, &format!("Error loading host specification: {}", e)) |
