Skip to content

Commit db67f59

Browse files
authored
Merge pull request #800 from rust-lang/sync_from_rust_2025_11_13
Sync from rust 2025/11/13
2 parents f25ac1d + 4767bbf commit db67f59

File tree

12 files changed

+110
-95
lines changed

12 files changed

+110
-95
lines changed

.github/workflows/release.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ jobs:
7272
git config --global user.name "User"
7373
./y.sh prepare
7474
75+
- name: Add more failing tests (some panic and debuginfo tests fail)
76+
run: cat tests/failing-lto-tests.txt >> tests/failing-ui-tests.txt
77+
7578
- name: Run tests
7679
run: |
7780
# FIXME(antoyo): we cannot enable LTO for stdarch tests currently because of some failing LTO tests using proc-macros.

build_system/src/test.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,7 @@ where
10651065
&test_dir,
10661066
&"--compiletest-rustc-args",
10671067
&rustc_args,
1068+
&"--bypass-ignore-backends",
10681069
];
10691070

10701071
if run_ignored_tests {

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
[toolchain]
2-
channel = "nightly-2025-11-04"
2+
channel = "nightly-2025-11-13"
33
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

src/abi.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ use rustc_middle::ty::layout::LayoutOf;
1212
#[cfg(feature = "master")]
1313
use rustc_session::config;
1414
use rustc_target::callconv::{ArgAttributes, CastTarget, FnAbi, PassMode};
15+
#[cfg(feature = "master")]
16+
use rustc_target::spec::Arch;
1517

1618
use crate::builder::Builder;
1719
use crate::context::CodegenCx;
@@ -238,7 +240,7 @@ impl<'gcc, 'tcx> FnAbiGccExt<'gcc, 'tcx> for FnAbi<'tcx, Ty<'tcx>> {
238240
}
239241

240242
#[cfg(feature = "master")]
241-
pub fn conv_to_fn_attribute<'gcc>(conv: CanonAbi, arch: &str) -> Option<FnAttribute<'gcc>> {
243+
pub fn conv_to_fn_attribute<'gcc>(conv: CanonAbi, arch: &Arch) -> Option<FnAttribute<'gcc>> {
242244
let attribute = match conv {
243245
CanonAbi::C | CanonAbi::Rust => return None,
244246
CanonAbi::RustCold => FnAttribute::Cold,
@@ -251,15 +253,11 @@ pub fn conv_to_fn_attribute<'gcc>(conv: CanonAbi, arch: &str) -> Option<FnAttrib
251253
ArmCall::CCmseNonSecureEntry => FnAttribute::ArmCmseNonsecureEntry,
252254
ArmCall::Aapcs => FnAttribute::ArmPcs("aapcs"),
253255
},
254-
CanonAbi::GpuKernel => {
255-
if arch == "amdgpu" {
256-
FnAttribute::GcnAmdGpuHsaKernel
257-
} else if arch == "nvptx64" {
258-
FnAttribute::NvptxKernel
259-
} else {
260-
panic!("Architecture {} does not support GpuKernel calling convention", arch);
261-
}
262-
}
256+
CanonAbi::GpuKernel => match arch {
257+
&Arch::AmdGpu => FnAttribute::GcnAmdGpuHsaKernel,
258+
&Arch::Nvptx64 => FnAttribute::NvptxKernel,
259+
arch => panic!("Arch {arch} does not support GpuKernel calling convention"),
260+
},
263261
// TODO(antoyo): check if those AVR attributes are mapped correctly.
264262
CanonAbi::Interrupt(interrupt_kind) => match interrupt_kind {
265263
InterruptKind::Avr => FnAttribute::AvrSignal,

src/attributes.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
99
#[cfg(feature = "master")]
1010
use rustc_middle::mir::TerminatorKind;
1111
use rustc_middle::ty;
12+
#[cfg(feature = "master")]
13+
use rustc_target::spec::Arch;
1214

1315
use crate::context::CodegenCx;
1416
use crate::gcc_util::to_gcc_features;
@@ -70,7 +72,7 @@ fn inline_attr<'gcc, 'tcx>(
7072
InlineAttr::Hint => Some(FnAttribute::Inline),
7173
InlineAttr::Force { .. } => Some(FnAttribute::AlwaysInline),
7274
InlineAttr::Never => {
73-
if cx.sess().target.arch != "amdgpu" {
75+
if cx.sess().target.arch != Arch::AmdGpu {
7476
Some(FnAttribute::NoInline)
7577
} else {
7678
None
@@ -153,8 +155,8 @@ pub fn from_fn_attrs<'gcc, 'tcx>(
153155
.join(",");
154156
if !target_features.is_empty() {
155157
#[cfg(feature = "master")]
156-
match cx.sess().target.arch.as_ref() {
157-
"x86" | "x86_64" | "powerpc" => {
158+
match cx.sess().target.arch {
159+
Arch::X86 | Arch::X86_64 | Arch::PowerPC => {
158160
func.add_attribute(FnAttribute::Target(&target_features))
159161
}
160162
// The target attribute is not supported on other targets in GCC.

src/base.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ use rustc_middle::mir::mono::Visibility;
1515
use rustc_middle::ty::TyCtxt;
1616
use rustc_session::config::DebugInfo;
1717
use rustc_span::Symbol;
18-
use rustc_target::spec::RelocModel;
1918
#[cfg(feature = "master")]
2019
use rustc_target::spec::SymbolVisibility;
20+
use rustc_target::spec::{Arch, RelocModel};
2121

2222
use crate::builder::Builder;
2323
use crate::context::CodegenCx;
@@ -117,7 +117,7 @@ pub fn compile_codegen_unit(
117117
.map(|string| &string[1..])
118118
.collect();
119119

120-
if !disabled_features.contains("avx") && tcx.sess.target.arch == "x86_64" {
120+
if !disabled_features.contains("avx") && tcx.sess.target.arch == Arch::X86_64 {
121121
// NOTE: we always enable AVX because the equivalent of llvm.x86.sse2.cmp.pd in GCC for
122122
// SSE2 is multiple builtins, so we use the AVX __builtin_ia32_cmppd instead.
123123
// FIXME(antoyo): use the proper builtins for llvm.x86.sse2.cmp.pd and similar.

src/builder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1079,7 +1079,7 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
10791079
OperandValue::Ref(place.val)
10801080
};
10811081

1082-
OperandRef { val, layout: place.layout }
1082+
OperandRef { val, layout: place.layout, move_annotation: None }
10831083
}
10841084

10851085
fn write_operand_repeatedly(

src/debuginfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use crate::context::CodegenCx;
1919
pub(super) const UNKNOWN_LINE_NUMBER: u32 = 0;
2020
pub(super) const UNKNOWN_COLUMN_NUMBER: u32 = 0;
2121

22-
impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> {
22+
impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods<'tcx> for Builder<'a, 'gcc, 'tcx> {
2323
// FIXME(eddyb) find a common convention for all of the debuginfo-related
2424
// names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
2525
fn dbg_var_addr(

src/gcc_util.rs

Lines changed: 49 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use gccjit::Context;
33
use rustc_codegen_ssa::target_features;
44
use rustc_data_structures::smallvec::{SmallVec, smallvec};
55
use rustc_session::Session;
6+
use rustc_target::spec::Arch;
67

78
fn gcc_features_by_flags(sess: &Session, features: &mut Vec<String>) {
89
target_features::retpoline_features_by_flags(sess, features);
@@ -11,7 +12,7 @@ fn gcc_features_by_flags(sess: &Session, features: &mut Vec<String>) {
1112

1213
/// The list of GCC features computed from CLI flags (`-Ctarget-cpu`, `-Ctarget-feature`,
1314
/// `--target` and similar).
14-
pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<String> {
15+
pub(crate) fn global_gcc_features(sess: &Session) -> Vec<String> {
1516
// Features that come earlier are overridden by conflicting features later in the string.
1617
// Typically we'll want more explicit settings to override the implicit ones, so:
1718
//
@@ -36,27 +37,18 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
3637
features.extend(sess.target.features.split(',').filter(|v| !v.is_empty()).map(String::from));
3738

3839
// -Ctarget-features
39-
target_features::flag_to_backend_features(
40-
sess,
41-
diagnostics,
42-
|feature| to_gcc_features(sess, feature),
43-
|feature, enable| {
44-
// We run through `to_gcc_features` when
45-
// passing requests down to GCC. This means that all in-language
46-
// features also work on the command line instead of having two
47-
// different names when the GCC name and the Rust name differ.
48-
features.extend(
49-
to_gcc_features(sess, feature)
50-
.iter()
51-
.flat_map(|feat| to_gcc_features(sess, feat).into_iter())
52-
.map(
53-
|feature| {
54-
if !enable { format!("-{}", feature) } else { feature.to_string() }
55-
},
56-
),
57-
);
58-
},
59-
);
40+
target_features::flag_to_backend_features(sess, |feature, enable| {
41+
// We run through `to_gcc_features` when
42+
// passing requests down to GCC. This means that all in-language
43+
// features also work on the command line instead of having two
44+
// different names when the GCC name and the Rust name differ.
45+
features.extend(
46+
to_gcc_features(sess, feature)
47+
.iter()
48+
.flat_map(|feat| to_gcc_features(sess, feat).into_iter())
49+
.map(|feature| if !enable { format!("-{}", feature) } else { feature.to_string() }),
50+
);
51+
});
6052

6153
gcc_features_by_flags(sess, &mut features);
6254

@@ -65,44 +57,47 @@ pub(crate) fn global_gcc_features(sess: &Session, diagnostics: bool) -> Vec<Stri
6557

6658
// To find a list of GCC's names, check https://gcc.gnu.org/onlinedocs/gcc/Function-Attributes.html
6759
pub fn to_gcc_features<'a>(sess: &Session, s: &'a str) -> SmallVec<[&'a str; 2]> {
68-
let arch = if sess.target.arch == "x86_64" { "x86" } else { &*sess.target.arch };
6960
// cSpell:disable
70-
match (arch, s) {
61+
match (&sess.target.arch, s) {
7162
// FIXME: seems like x87 does not exist?
72-
("x86", "x87") => smallvec![],
73-
("x86", "sse4.2") => smallvec!["sse4.2", "crc32"],
74-
("x86", "pclmulqdq") => smallvec!["pclmul"],
75-
("x86", "rdrand") => smallvec!["rdrnd"],
76-
("x86", "bmi1") => smallvec!["bmi"],
77-
("x86", "cmpxchg16b") => smallvec!["cx16"],
78-
("x86", "avx512vaes") => smallvec!["vaes"],
79-
("x86", "avx512gfni") => smallvec!["gfni"],
80-
("x86", "avx512vpclmulqdq") => smallvec!["vpclmulqdq"],
63+
(&Arch::X86 | &Arch::X86_64, "x87") => smallvec![],
64+
(&Arch::X86 | &Arch::X86_64, "sse4.2") => smallvec!["sse4.2", "crc32"],
65+
(&Arch::X86 | &Arch::X86_64, "pclmulqdq") => smallvec!["pclmul"],
66+
(&Arch::X86 | &Arch::X86_64, "rdrand") => smallvec!["rdrnd"],
67+
(&Arch::X86 | &Arch::X86_64, "bmi1") => smallvec!["bmi"],
68+
(&Arch::X86 | &Arch::X86_64, "cmpxchg16b") => smallvec!["cx16"],
69+
(&Arch::X86 | &Arch::X86_64, "avx512vaes") => smallvec!["vaes"],
70+
(&Arch::X86 | &Arch::X86_64, "avx512gfni") => smallvec!["gfni"],
71+
(&Arch::X86 | &Arch::X86_64, "avx512vpclmulqdq") => smallvec!["vpclmulqdq"],
8172
// NOTE: seems like GCC requires 'avx512bw' for 'avx512vbmi2'.
82-
("x86", "avx512vbmi2") => smallvec!["avx512vbmi2", "avx512bw"],
73+
(&Arch::X86 | &Arch::X86_64, "avx512vbmi2") => {
74+
smallvec!["avx512vbmi2", "avx512bw"]
75+
}
8376
// NOTE: seems like GCC requires 'avx512bw' for 'avx512bitalg'.
84-
("x86", "avx512bitalg") => smallvec!["avx512bitalg", "avx512bw"],
85-
("aarch64", "rcpc2") => smallvec!["rcpc-immo"],
86-
("aarch64", "dpb") => smallvec!["ccpp"],
87-
("aarch64", "dpb2") => smallvec!["ccdp"],
88-
("aarch64", "frintts") => smallvec!["fptoint"],
89-
("aarch64", "fcma") => smallvec!["complxnum"],
90-
("aarch64", "pmuv3") => smallvec!["perfmon"],
91-
("aarch64", "paca") => smallvec!["pauth"],
92-
("aarch64", "pacg") => smallvec!["pauth"],
77+
(&Arch::X86 | &Arch::X86_64, "avx512bitalg") => {
78+
smallvec!["avx512bitalg", "avx512bw"]
79+
}
80+
(&Arch::AArch64, "rcpc2") => smallvec!["rcpc-immo"],
81+
(&Arch::AArch64, "dpb") => smallvec!["ccpp"],
82+
(&Arch::AArch64, "dpb2") => smallvec!["ccdp"],
83+
(&Arch::AArch64, "frintts") => smallvec!["fptoint"],
84+
(&Arch::AArch64, "fcma") => smallvec!["complxnum"],
85+
(&Arch::AArch64, "pmuv3") => smallvec!["perfmon"],
86+
(&Arch::AArch64, "paca") => smallvec!["pauth"],
87+
(&Arch::AArch64, "pacg") => smallvec!["pauth"],
9388
// Rust ties fp and neon together. In GCC neon implicitly enables fp,
9489
// but we manually enable neon when a feature only implicitly enables fp
95-
("aarch64", "f32mm") => smallvec!["f32mm", "neon"],
96-
("aarch64", "f64mm") => smallvec!["f64mm", "neon"],
97-
("aarch64", "fhm") => smallvec!["fp16fml", "neon"],
98-
("aarch64", "fp16") => smallvec!["fullfp16", "neon"],
99-
("aarch64", "jsconv") => smallvec!["jsconv", "neon"],
100-
("aarch64", "sve") => smallvec!["sve", "neon"],
101-
("aarch64", "sve2") => smallvec!["sve2", "neon"],
102-
("aarch64", "sve2-aes") => smallvec!["sve2-aes", "neon"],
103-
("aarch64", "sve2-sm4") => smallvec!["sve2-sm4", "neon"],
104-
("aarch64", "sve2-sha3") => smallvec!["sve2-sha3", "neon"],
105-
("aarch64", "sve2-bitperm") => smallvec!["sve2-bitperm", "neon"],
90+
(&Arch::AArch64, "f32mm") => smallvec!["f32mm", "neon"],
91+
(&Arch::AArch64, "f64mm") => smallvec!["f64mm", "neon"],
92+
(&Arch::AArch64, "fhm") => smallvec!["fp16fml", "neon"],
93+
(&Arch::AArch64, "fp16") => smallvec!["fullfp16", "neon"],
94+
(&Arch::AArch64, "jsconv") => smallvec!["jsconv", "neon"],
95+
(&Arch::AArch64, "sve") => smallvec!["sve", "neon"],
96+
(&Arch::AArch64, "sve2") => smallvec!["sve2", "neon"],
97+
(&Arch::AArch64, "sve2-aes") => smallvec!["sve2-aes", "neon"],
98+
(&Arch::AArch64, "sve2-sm4") => smallvec!["sve2-sm4", "neon"],
99+
(&Arch::AArch64, "sve2-sha3") => smallvec!["sve2-sha3", "neon"],
100+
(&Arch::AArch64, "sve2-bitperm") => smallvec!["sve2-bitperm", "neon"],
106101
(_, s) => smallvec![s],
107102
}
108103
// cSpell:enable

src/lib.rs

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313
* TODO(antoyo): remove the patches.
1414
*/
1515

16-
#![expect(internal_features)]
17-
#![doc(rust_logo)]
18-
#![feature(rustdoc_internals)]
1916
#![feature(rustc_private)]
2017
#![recursion_limit = "256"]
2118
#![warn(rust_2018_idioms)]
@@ -100,11 +97,11 @@ use rustc_middle::util::Providers;
10097
use rustc_session::Session;
10198
use rustc_session::config::{OptLevel, OutputFilenames};
10299
use rustc_span::Symbol;
103-
use rustc_target::spec::RelocModel;
100+
use rustc_target::spec::{Arch, RelocModel};
104101
use tempfile::TempDir;
105102

106103
use crate::back::lto::ModuleBuffer;
107-
use crate::gcc_util::target_cpu;
104+
use crate::gcc_util::{target_cpu, to_gcc_features};
108105

109106
rustc_fluent_macro::fluent_messages! { "../messages.ftl" }
110107

@@ -226,7 +223,7 @@ impl CodegenBackend for GccCodegenBackend {
226223
}
227224

228225
fn provide(&self, providers: &mut Providers) {
229-
providers.global_backend_features = |tcx, ()| gcc_util::global_gcc_features(tcx.sess, true)
226+
providers.global_backend_features = |tcx, ()| gcc_util::global_gcc_features(tcx.sess)
230227
}
231228

232229
fn codegen_crate(&self, tcx: TyCtxt<'_>) -> Box<dyn Any> {
@@ -255,7 +252,7 @@ impl CodegenBackend for GccCodegenBackend {
255252

256253
fn new_context<'gcc, 'tcx>(tcx: TyCtxt<'tcx>) -> Context<'gcc> {
257254
let context = Context::default();
258-
if tcx.sess.target.arch == "x86" || tcx.sess.target.arch == "x86_64" {
255+
if matches!(tcx.sess.target.arch, Arch::X86 | Arch::X86_64) {
259256
context.add_command_line_option("-masm=intel");
260257
}
261258
#[cfg(feature = "master")]
@@ -470,21 +467,25 @@ fn to_gcc_opt_level(optlevel: Option<OptLevel>) -> OptimizationLevel {
470467

471468
/// Returns the features that should be set in `cfg(target_feature)`.
472469
fn target_config(sess: &Session, target_info: &LockedTargetInfo) -> TargetConfig {
473-
let (unstable_target_features, target_features) = cfg_target_feature(sess, |feature| {
474-
// TODO: we disable Neon for now since we don't support the LLVM intrinsics for it.
475-
if feature == "neon" {
476-
return false;
477-
}
478-
target_info.cpu_supports(feature)
479-
// cSpell:disable
480-
/*
481-
adx, aes, avx, avx2, avx512bf16, avx512bitalg, avx512bw, avx512cd, avx512dq, avx512er, avx512f, avx512fp16, avx512ifma,
482-
avx512pf, avx512vbmi, avx512vbmi2, avx512vl, avx512vnni, avx512vp2intersect, avx512vpopcntdq,
483-
bmi1, bmi2, cmpxchg16b, ermsb, f16c, fma, fxsr, gfni, lzcnt, movbe, pclmulqdq, popcnt, rdrand, rdseed, rtm,
484-
sha, sse, sse2, sse3, sse4.1, sse4.2, sse4a, ssse3, tbm, vaes, vpclmulqdq, xsave, xsavec, xsaveopt, xsaves
485-
*/
486-
// cSpell:enable
487-
});
470+
let (unstable_target_features, target_features) = cfg_target_feature(
471+
sess,
472+
|feature| to_gcc_features(sess, feature),
473+
|feature| {
474+
// TODO: we disable Neon for now since we don't support the LLVM intrinsics for it.
475+
if feature == "neon" {
476+
return false;
477+
}
478+
target_info.cpu_supports(feature)
479+
// cSpell:disable
480+
/*
481+
adx, aes, avx, avx2, avx512bf16, avx512bitalg, avx512bw, avx512cd, avx512dq, avx512er, avx512f, avx512fp16, avx512ifma,
482+
avx512pf, avx512vbmi, avx512vbmi2, avx512vl, avx512vnni, avx512vp2intersect, avx512vpopcntdq,
483+
bmi1, bmi2, cmpxchg16b, ermsb, f16c, fma, fxsr, gfni, lzcnt, movbe, pclmulqdq, popcnt, rdrand, rdseed, rtm,
484+
sha, sse, sse2, sse3, sse4.1, sse4.2, sse4a, ssse3, tbm, vaes, vpclmulqdq, xsave, xsavec, xsaveopt, xsaves
485+
*/
486+
// cSpell:enable
487+
},
488+
);
488489

489490
let has_reliable_f16 = target_info.supports_target_dependent_type(CType::Float16);
490491
let has_reliable_f128 = target_info.supports_target_dependent_type(CType::Float128);

0 commit comments

Comments
 (0)