Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions compiler/rustc_interface/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,16 @@ pub(crate) struct MultipleOutputTypesToStdout;
#[diag(
"target feature `{$feature}` must be {$enabled} to ensure that the ABI of the current target can be implemented correctly"
)]
#[note(
"this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
)]
#[note("for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>")]
pub(crate) struct AbiRequiredTargetFeature<'a> {
pub feature: &'a str,
pub enabled: &'a str,
#[note(
"this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!"
)]
#[note(
"for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>"
)]
pub fcw: bool,
}

#[derive(Diagnostic)]
Expand Down
30 changes: 25 additions & 5 deletions compiler/rustc_interface/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ use rustc_span::edition::Edition;
use rustc_span::source_map::SourceMapInputs;
use rustc_span::{SessionGlobals, Symbol, sym};
use rustc_structures::CrateType;
use rustc_target::spec::Target;
use rustc_target::spec::{Arch, Target};
use tracing::info;

use crate::diagnostics;
Expand Down Expand Up @@ -107,16 +107,36 @@ pub(crate) fn check_abi_required_features(sess: &Session) {
);
}

// Make this a hard error on ARM since starting with LLVM24, the backend will otherwise
// emit a (less friendly) hard error.
let hard_error = matches!(sess.target.arch, Arch::Arm);

for feature in abi_feature_constraints.required {
if !sess.internal_target_features.contains(&Symbol::intern(feature)) {
sess.dcx()
.emit_warn(diagnostics::AbiRequiredTargetFeature { feature, enabled: "enabled" });
let diag = diagnostics::AbiRequiredTargetFeature {
feature,
enabled: "enabled",
fcw: !hard_error,
};
if hard_error {
sess.dcx().emit_err(diag);
} else {
sess.dcx().emit_warn(diag);
}
}
}
for feature in abi_feature_constraints.incompatible {
if sess.internal_target_features.contains(&Symbol::intern(feature)) {
sess.dcx()
.emit_warn(diagnostics::AbiRequiredTargetFeature { feature, enabled: "disabled" });
let diag = diagnostics::AbiRequiredTargetFeature {
feature,
enabled: "disabled",
fcw: !hard_error,
};
if hard_error {
sess.dcx().emit_err(diag);
} else {
sess.dcx().emit_warn(diag);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
warning: target feature `fpregs` must be enabled to ensure that the ABI of the current target can be implemented correctly
|
= note: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #116344 <https://github.com/rust-lang/rust/issues/116344>
error: target feature `fpregs` must be enabled to ensure that the ABI of the current target can be implemented correctly

warning: 1 warning emitted
error: aborting due to 1 previous error

Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,20 @@
//@[arm] compile-flags: --target=armv8r-none-eabihf -Ctarget-cpu=cortex-r4
//@[arm] needs-llvm-components: arm

// LLVM 24 refuses to compile ARM minicore due to mismatched target features.
// FIXME(#161276): With LLVM rejecting this, we should make Rust's own warning an error.
//@[arm] max-llvm-major-version: 23
// On x86 this is just a warning.
//@[x86] check-pass
//@[arm] check-fail

// For now this is just a warning.
//@ build-pass
//@ ignore-backends: gcc
//@ add-minicore
// Don't inherit the target-cpu above for minicore, to avoid errors when building that.
//@ minicore-compile-flags: -Ctarget-cpu=generic

#![feature(no_core)]
#![no_core]

extern crate minicore;
use minicore::*;

//~? WARN must be enabled to ensure that the ABI of the current target can be implemented correctly
//[x86]~? WARN must be enabled to ensure that the ABI of the current target can be implemented correctly
//[arm]~? ERROR must be enabled to ensure that the ABI of the current target can be implemented correctly
Loading