diff options
| author | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2023-04-25 15:48:53 +0300 |
|---|---|---|
| committer | Vadim Petrochenkov <vadim.petrochenkov@gmail.com> | 2023-05-29 19:58:11 +0300 |
| commit | b0ce4164f09be1221d004c4b84e49bdcbf973194 (patch) | |
| tree | b796caaaca796de99a220ccecbfcd2e7d92749a8 /compiler/rustc_session | |
| parent | 2013ccc218a488768ad6b647dd8ecc293e7847b4 (diff) | |
| download | rust-b0ce4164f09be1221d004c4b84e49bdcbf973194.tar.gz rust-b0ce4164f09be1221d004c4b84e49bdcbf973194.zip | |
linker: Report linker flavors incompatible with the current target
Previously they would be reported as link time errors about unknown linker options
Diffstat (limited to 'compiler/rustc_session')
| -rw-r--r-- | compiler/rustc_session/messages.ftl | 4 | ||||
| -rw-r--r-- | compiler/rustc_session/src/errors.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_session/src/session.rs | 7 |
3 files changed, 19 insertions, 0 deletions
diff --git a/compiler/rustc_session/messages.ftl b/compiler/rustc_session/messages.ftl index 5a0b8f9f73c..4897bd8d5da 100644 --- a/compiler/rustc_session/messages.ftl +++ b/compiler/rustc_session/messages.ftl @@ -27,6 +27,10 @@ session_feature_gate_error = {$explain} session_file_is_not_writeable = output file {$file} is not writeable -- check its permissions session_hexadecimal_float_literal_not_supported = hexadecimal float literal is not supported + +session_incompatible_linker_flavor = linker flavor `{$flavor}` is incompatible with the current target + .note = compatible flavors are: {$compatible_list} + session_incorrect_cgu_reuse_type = CGU-reuse for `{$cgu_user_name}` is `{$actual_reuse}` but should be {$at_least -> [one] {"at least "} diff --git a/compiler/rustc_session/src/errors.rs b/compiler/rustc_session/src/errors.rs index 546c0fa8e03..4a3e668da11 100644 --- a/compiler/rustc_session/src/errors.rs +++ b/compiler/rustc_session/src/errors.rs @@ -422,3 +422,11 @@ pub fn report_lit_error(sess: &ParseSess, err: LitError, lit: token::Lit, span: pub struct OptimisationFuelExhausted { pub msg: String, } + +#[derive(Diagnostic)] +#[diag(session_incompatible_linker_flavor)] +#[note] +pub struct IncompatibleLinkerFlavor { + pub flavor: &'static str, + pub compatible_list: String, +} diff --git a/compiler/rustc_session/src/session.rs b/compiler/rustc_session/src/session.rs index bbe52dbced0..1eb54cee5a1 100644 --- a/compiler/rustc_session/src/session.rs +++ b/compiler/rustc_session/src/session.rs @@ -1675,6 +1675,13 @@ fn validate_commandline_args_with_session_available(sess: &Session) { if sess.opts.unstable_opts.instrument_xray.is_some() && !sess.target.options.supports_xray { sess.emit_err(errors::InstrumentationNotSupported { us: "XRay".to_string() }); } + + if let Some(flavor) = sess.opts.cg.linker_flavor { + if let Some(compatible_list) = sess.target.linker_flavor.check_compatibility(flavor) { + let flavor = flavor.desc(); + sess.emit_err(errors::IncompatibleLinkerFlavor { flavor, compatible_list }); + } + } } /// Holds data on the current incremental compilation session, if there is one. |
