Skip to content

Commit baaf8da

Browse files
committed
Auto merge of #142443 - matthiaskrgr:rollup-l1l6d0v, r=matthiaskrgr
Rollup of 9 pull requests Successful merges: - rust-lang/rust#128425 (Make `missing_fragment_specifier` an unconditional error) - rust-lang/rust#135927 (retpoline and retpoline-external-thunk flags (target modifiers) to enable retpoline-related target features) - rust-lang/rust#140770 (add `extern "custom"` functions) - rust-lang/rust#142176 (tests: Split dont-shuffle-bswaps along opt-levels and arches) - rust-lang/rust#142248 (Add supported asm types for LoongArch32) - rust-lang/rust#142267 (assert more in release in `rustc_ast_lowering`) - rust-lang/rust#142274 (Update the stdarch submodule) - rust-lang/rust#142276 (Update dependencies in `library/Cargo.lock`) - rust-lang/rust#142308 (Upgrade `object`, `addr2line`, and `unwinding` in the standard library) Failed merges: - rust-lang/rust#140920 (Extract some shared code from codegen backend target feature handling) r? `@ghost` `@rustbot` modify labels: rollup try-job: aarch64-apple try-job: x86_64-msvc-1 try-job: x86_64-gnu try-job: dist-i586-gnu-i586-i686-musl try-job: test-various
2 parents f5c6288 + 3766fb2 commit baaf8da

File tree

4 files changed

+15
-40
lines changed

4 files changed

+15
-40
lines changed

messages.ftl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ codegen_gcc_unknown_ctarget_feature_prefix =
22
unknown feature specified for `-Ctarget-feature`: `{$feature}`
33
.note = features must begin with a `+` to enable or `-` to disable it
44
5-
codegen_gcc_forbidden_ctarget_feature =
6-
target feature `{$feature}` cannot be toggled with `-Ctarget-feature`: {$reason}
7-
85
codegen_gcc_unwinding_inline_asm =
96
GCC backend does not support unwinding from inline asm
107
@@ -26,10 +23,6 @@ codegen_gcc_unknown_ctarget_feature =
2623
.possible_feature = you might have meant: `{$rust_feature}`
2724
.consider_filing_feature_request = consider filing a feature request
2825
29-
codegen_gcc_unstable_ctarget_feature =
30-
unstable feature specified for `-Ctarget-feature`: `{$feature}`
31-
.note = this feature is not stably supported; its behavior can change in the future
32-
3326
codegen_gcc_missing_features =
3427
add the missing features in a `target_feature` attribute
3528

src/abi.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,16 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
239239
pub fn conv_to_fn_attribute<'gcc>(conv: CanonAbi, arch: &str) -> Option<FnAttribute<'gcc>> {
240240
let attribute = match conv {
241241
CanonAbi::C | CanonAbi::Rust => return None,
242+
CanonAbi::RustCold => FnAttribute::Cold,
243+
// Functions with this calling convention can only be called from assembly, but it is
244+
// possible to declare an `extern "custom"` block, so the backend still needs a calling
245+
// convention for declaring foreign functions.
246+
CanonAbi::Custom => return None,
242247
CanonAbi::Arm(arm_call) => match arm_call {
243248
ArmCall::CCmseNonSecureCall => FnAttribute::ArmCmseNonsecureCall,
244249
ArmCall::CCmseNonSecureEntry => FnAttribute::ArmCmseNonsecureEntry,
245250
ArmCall::Aapcs => FnAttribute::ArmPcs("aapcs"),
246251
},
247-
CanonAbi::RustCold => FnAttribute::Cold,
248252
CanonAbi::GpuKernel => {
249253
if arch == "amdgpu" {
250254
FnAttribute::GcnAmdGpuHsaKernel

src/errors.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,6 @@ pub(crate) struct UnknownCTargetFeature<'a> {
1717
pub rust_feature: PossibleFeature<'a>,
1818
}
1919

20-
#[derive(Diagnostic)]
21-
#[diag(codegen_gcc_unstable_ctarget_feature)]
22-
#[note]
23-
pub(crate) struct UnstableCTargetFeature<'a> {
24-
pub feature: &'a str,
25-
}
26-
27-
#[derive(Diagnostic)]
28-
#[diag(codegen_gcc_forbidden_ctarget_feature)]
29-
pub(crate) struct ForbiddenCTargetFeature<'a> {
30-
pub feature: &'a str,
31-
pub enabled: &'a str,
32-
pub reason: &'a str,
33-
}
34-
3520
#[derive(Subdiagnostic)]
3621
pub(crate) enum PossibleFeature<'a> {
3722
#[help(codegen_gcc_possible_feature)]

src/gcc_util.rs

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ use rustc_codegen_ssa::errors::TargetFeatureDisableOrEnable;
55
use rustc_data_structures::fx::FxHashMap;
66
use rustc_data_structures::unord::UnordSet;
77
use rustc_session::Session;
8+
use rustc_session::features::{StabilityExt, retpoline_features_by_flags};
89
use rustc_target::target_features::RUSTC_SPECIFIC_FEATURES;
910
use smallvec::{SmallVec, smallvec};
1011

11-
use crate::errors::{
12-
ForbiddenCTargetFeature, PossibleFeature, UnknownCTargetFeature, UnknownCTargetFeaturePrefix,
13-
UnstableCTargetFeature,
14-
};
12+
use crate::errors::{PossibleFeature, UnknownCTargetFeature, UnknownCTargetFeaturePrefix};
13+
14+
fn gcc_features_by_flags(sess: &Session) -> Vec<&str> {
15+
let mut features: Vec<&str> = Vec::new();
16+
retpoline_features_by_flags(sess, &mut features);
17+
features
18+
}
1519

1620
/// The list of GCC features computed from CLI flags (`-Ctarget-cpu`, `-Ctarget-feature`,
1721
/// `--target` and similar).
@@ -45,7 +49,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
4549

4650
// Compute implied features
4751
let mut all_rust_features = vec![];
48-
for feature in sess.opts.cg.target_feature.split(',') {
52+
for feature in sess.opts.cg.target_feature.split(',').chain(gcc_features_by_flags(sess)) {
4953
if let Some(feature) = feature.strip_prefix('+') {
5054
all_rust_features.extend(
5155
UnordSet::from(sess.target.implied_target_features(feature))
@@ -94,18 +98,7 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
9498
sess.dcx().emit_warn(unknown_feature);
9599
}
96100
Some(&(_, stability, _)) => {
97-
if let Err(reason) = stability.toggle_allowed() {
98-
sess.dcx().emit_warn(ForbiddenCTargetFeature {
99-
feature,
100-
enabled: if enable { "enabled" } else { "disabled" },
101-
reason,
102-
});
103-
} else if stability.requires_nightly().is_some() {
104-
// An unstable feature. Warn about using it. (It makes little sense
105-
// to hard-error here since we just warn about fully unknown
106-
// features above).
107-
sess.dcx().emit_warn(UnstableCTargetFeature { feature });
108-
}
101+
stability.verify_feature_enabled_by_flag(sess, enable, feature);
109102
}
110103
}
111104

0 commit comments

Comments
 (0)