Skip to content

Commit 482e854

Browse files
authored
Merge pull request #746 from rust-lang/sync_from_rust_2025_08_03
Sync from rust 2025/08/03
2 parents 36a516d + dac1f34 commit 482e854

File tree

12 files changed

+60
-142
lines changed

12 files changed

+60
-142
lines changed

‎build_system/src/test.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -561,8 +561,6 @@ fn asm_tests(env: &Env, args: &TestArg) -> Result<(), String> {
561561
// FIXME: create a function "display_if_not_quiet" or something along the line.
562562
println!("[TEST] rustc asm test suite");
563563

564-
env.insert("COMPILETEST_FORCE_STAGE0".to_string(), "1".to_string());
565-
566564
let codegen_backend_path = format!(
567565
"{pwd}/target/{channel}/librustc_codegen_gcc.{dylib_ext}",
568566
pwd = std::env::current_dir()
@@ -588,7 +586,9 @@ fn asm_tests(env: &Env, args: &TestArg) -> Result<(), String> {
588586
&"always",
589587
&"--stage",
590588
&"0",
591-
&"tests/assembly/asm",
589+
&"--set",
590+
&"build.compiletest-allow-stage0=true",
591+
&"tests/assembly-llvm/asm",
592592
&"--compiletest-rustc-args",
593593
&rustc_args,
594594
],
@@ -1047,7 +1047,6 @@ where
10471047

10481048
// FIXME: create a function "display_if_not_quiet" or something along the line.
10491049
println!("[TEST] rustc {test_type} test suite");
1050-
env.insert("COMPILETEST_FORCE_STAGE0".to_string(), "1".to_string());
10511050

10521051
let extra =
10531052
if args.is_using_gcc_master_branch() { "" } else { " -Csymbol-mangling-version=v0" };
@@ -1070,6 +1069,8 @@ where
10701069
&"always",
10711070
&"--stage",
10721071
&"0",
1072+
&"--set",
1073+
&"build.compiletest-allow-stage0=true",
10731074
&format!("tests/{test_type}"),
10741075
&"--compiletest-rustc-args",
10751076
&rustc_args,

‎messages.ftl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ codegen_gcc_unwinding_inline_asm =
33
44
codegen_gcc_copy_bitcode = failed to copy bitcode to object file: {$err}
55
6-
codegen_gcc_dynamic_linking_with_lto =
7-
cannot prefer dynamic linking when performing LTO
8-
.note = only 'staticlib', 'bin', and 'cdylib' outputs are supported with LTO
9-
10-
codegen_gcc_lto_disallowed = lto can only be run for executables, cdylibs and static library outputs
11-
12-
codegen_gcc_lto_dylib = lto cannot be used for `dylib` crate type without `-Zdylib-lto`
13-
146
codegen_gcc_lto_bitcode_from_rlib = failed to get bitcode from object file for LTO ({$gcc_err})
7+
8+
codegen_gcc_explicit_tail_calls_unsupported = explicit tail calls with the 'become' keyword are not implemented in the GCC backend
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
1-
From b8f3eed3053c9333b5dfbeaeb2a6a65a4b3156df Mon Sep 17 00:00:00 2001
2-
From: Antoni Boucher <bouanto@zoho.com>
3-
Date: Tue, 29 Aug 2023 13:06:34 -0400
1+
From 190e26c9274b3c93a9ee3516b395590e6bd9213b Mon Sep 17 00:00:00 2001
2+
From: None <none@example.com>
3+
Date: Sun, 3 Aug 2025 19:54:56 -0400
44
Subject: [PATCH] Patch 0001-Add-stdarch-Cargo.toml-for-testing.patch
55

66
---
7-
library/stdarch/Cargo.toml | 23 +++++++++++++++++++++++
8-
1 file changed, 23 insertions(+)
7+
library/stdarch/Cargo.toml | 20 ++++++++++++++++++++
8+
1 file changed, 20 insertions(+)
99
create mode 100644 library/stdarch/Cargo.toml
1010

1111
diff --git a/library/stdarch/Cargo.toml b/library/stdarch/Cargo.toml
1212
new file mode 100644
13-
index 0000000..4c63700
13+
index 0000000..bd6725c
1414
--- /dev/null
1515
+++ b/library/stdarch/Cargo.toml
16-
@@ -0,0 +1,21 @@
16+
@@ -0,0 +1,20 @@
1717
+[workspace]
1818
+resolver = "1"
1919
+members = [
20-
+ "crates/core_arch",
21-
+ "crates/std_detect",
22-
+ "crates/stdarch-gen-arm",
20+
+ "crates/*",
2321
+ #"examples/"
2422
+]
2523
+exclude = [
26-
+ "crates/wasm-assert-instr-tests"
24+
+ "crates/wasm-assert-instr-tests",
25+
+ "rust_programs",
2726
+]
2827
+
2928
+[profile.release]
@@ -36,5 +35,5 @@ index 0000000..4c63700
3635
+opt-level = 3
3736
+incremental = true
3837
--
39-
2.42.0
38+
2.50.1
4039

‎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-07-21"
2+
channel = "nightly-2025-08-03"
33
components = ["rust-src", "rustc-dev", "llvm-tools-preview"]

‎src/attributes.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
use gccjit::FnAttribute;
33
use gccjit::Function;
44
#[cfg(feature = "master")]
5-
use rustc_attr_data_structures::InlineAttr;
6-
use rustc_attr_data_structures::InstructionSetAttr;
5+
use rustc_hir::attrs::InlineAttr;
6+
use rustc_hir::attrs::InstructionSetAttr;
77
#[cfg(feature = "master")]
88
use rustc_middle::middle::codegen_fn_attrs::CodegenFnAttrFlags;
99
#[cfg(feature = "master")]

‎src/back/lto.rs

Lines changed: 8 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -25,35 +25,21 @@ use std::sync::Arc;
2525
use gccjit::{Context, OutputKind};
2626
use object::read::archive::ArchiveFile;
2727
use rustc_codegen_ssa::back::lto::{SerializedModule, ThinModule, ThinShared};
28-
use rustc_codegen_ssa::back::symbol_export;
2928
use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput};
3029
use rustc_codegen_ssa::traits::*;
3130
use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file};
3231
use rustc_data_structures::memmap::Mmap;
3332
use rustc_errors::{DiagCtxtHandle, FatalError};
34-
use rustc_hir::def_id::LOCAL_CRATE;
3533
use rustc_middle::bug;
3634
use rustc_middle::dep_graph::WorkProduct;
37-
use rustc_middle::middle::exported_symbols::{SymbolExportInfo, SymbolExportLevel};
38-
use rustc_session::config::{CrateType, Lto};
35+
use rustc_session::config::Lto;
3936
use rustc_target::spec::RelocModel;
4037
use tempfile::{TempDir, tempdir};
4138

4239
use crate::back::write::save_temp_bitcode;
43-
use crate::errors::{DynamicLinkingWithLTO, LtoBitcodeFromRlib, LtoDisallowed, LtoDylib};
40+
use crate::errors::LtoBitcodeFromRlib;
4441
use crate::{GccCodegenBackend, GccContext, SyncContext, to_gcc_opt_level};
4542

46-
pub fn crate_type_allows_lto(crate_type: CrateType) -> bool {
47-
match crate_type {
48-
CrateType::Executable
49-
| CrateType::Dylib
50-
| CrateType::Staticlib
51-
| CrateType::Cdylib
52-
| CrateType::Sdylib => true,
53-
CrateType::Rlib | CrateType::ProcMacro => false,
54-
}
55-
}
56-
5743
struct LtoData {
5844
// TODO(antoyo): use symbols_below_threshold.
5945
//symbols_below_threshold: Vec<String>,
@@ -63,18 +49,9 @@ struct LtoData {
6349

6450
fn prepare_lto(
6551
cgcx: &CodegenContext<GccCodegenBackend>,
52+
each_linked_rlib_for_lto: &[PathBuf],
6653
dcx: DiagCtxtHandle<'_>,
6754
) -> Result<LtoData, FatalError> {
68-
let export_threshold = match cgcx.lto {
69-
// We're just doing LTO for our one crate
70-
Lto::ThinLocal => SymbolExportLevel::Rust,
71-
72-
// We're doing LTO for the entire crate graph
73-
Lto::Fat | Lto::Thin => symbol_export::crates_export_threshold(&cgcx.crate_types),
74-
75-
Lto::No => panic!("didn't request LTO but we're doing LTO"),
76-
};
77-
7855
let tmp_path = match tempdir() {
7956
Ok(tmp_path) => tmp_path,
8057
Err(error) => {
@@ -83,20 +60,6 @@ fn prepare_lto(
8360
}
8461
};
8562

86-
let symbol_filter = &|&(ref name, info): &(String, SymbolExportInfo)| {
87-
if info.level.is_below_threshold(export_threshold) || info.used {
88-
Some(name.clone())
89-
} else {
90-
None
91-
}
92-
};
93-
let exported_symbols = cgcx.exported_symbols.as_ref().expect("needs exported symbols for LTO");
94-
let mut symbols_below_threshold = {
95-
let _timer = cgcx.prof.generic_activity("GCC_lto_generate_symbols_below_threshold");
96-
exported_symbols[&LOCAL_CRATE].iter().filter_map(symbol_filter).collect::<Vec<String>>()
97-
};
98-
info!("{} symbols to preserve in this crate", symbols_below_threshold.len());
99-
10063
// If we're performing LTO for the entire crate graph, then for each of our
10164
// upstream dependencies, find the corresponding rlib and load the bitcode
10265
// from the archive.
@@ -105,32 +68,7 @@ fn prepare_lto(
10568
// with either fat or thin LTO
10669
let mut upstream_modules = Vec::new();
10770
if cgcx.lto != Lto::ThinLocal {
108-
// Make sure we actually can run LTO
109-
for crate_type in cgcx.crate_types.iter() {
110-
if !crate_type_allows_lto(*crate_type) {
111-
dcx.emit_err(LtoDisallowed);
112-
return Err(FatalError);
113-
}
114-
if *crate_type == CrateType::Dylib && !cgcx.opts.unstable_opts.dylib_lto {
115-
dcx.emit_err(LtoDylib);
116-
return Err(FatalError);
117-
}
118-
}
119-
120-
if cgcx.opts.cg.prefer_dynamic && !cgcx.opts.unstable_opts.dylib_lto {
121-
dcx.emit_err(DynamicLinkingWithLTO);
122-
return Err(FatalError);
123-
}
124-
125-
for &(cnum, ref path) in cgcx.each_linked_rlib_for_lto.iter() {
126-
let exported_symbols =
127-
cgcx.exported_symbols.as_ref().expect("needs exported symbols for LTO");
128-
{
129-
let _timer = cgcx.prof.generic_activity("GCC_lto_generate_symbols_below_threshold");
130-
symbols_below_threshold
131-
.extend(exported_symbols[&cnum].iter().filter_map(symbol_filter));
132-
}
133-
71+
for path in each_linked_rlib_for_lto {
13472
let archive_data = unsafe {
13573
Mmap::map(File::open(path).expect("couldn't open rlib")).expect("couldn't map rlib")
13674
};
@@ -174,19 +112,18 @@ fn save_as_file(obj: &[u8], path: &Path) -> Result<(), LtoBitcodeFromRlib> {
174112
/// for further optimization.
175113
pub(crate) fn run_fat(
176114
cgcx: &CodegenContext<GccCodegenBackend>,
115+
each_linked_rlib_for_lto: &[PathBuf],
177116
modules: Vec<FatLtoInput<GccCodegenBackend>>,
178-
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
179117
) -> Result<ModuleCodegen<GccContext>, FatalError> {
180118
let dcx = cgcx.create_dcx();
181119
let dcx = dcx.handle();
182-
let lto_data = prepare_lto(cgcx, dcx)?;
120+
let lto_data = prepare_lto(cgcx, each_linked_rlib_for_lto, dcx)?;
183121
/*let symbols_below_threshold =
184122
lto_data.symbols_below_threshold.iter().map(|c| c.as_ptr()).collect::<Vec<_>>();*/
185123
fat_lto(
186124
cgcx,
187125
dcx,
188126
modules,
189-
cached_modules,
190127
lto_data.upstream_modules,
191128
lto_data.tmp_path,
192129
//&lto_data.symbols_below_threshold,
@@ -197,7 +134,6 @@ fn fat_lto(
197134
cgcx: &CodegenContext<GccCodegenBackend>,
198135
_dcx: DiagCtxtHandle<'_>,
199136
modules: Vec<FatLtoInput<GccCodegenBackend>>,
200-
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
201137
mut serialized_modules: Vec<(SerializedModule<ModuleBuffer>, CString)>,
202138
tmp_path: TempDir,
203139
//symbols_below_threshold: &[String],
@@ -211,21 +147,12 @@ fn fat_lto(
211147
// modules that are serialized in-memory.
212148
// * `in_memory` contains modules which are already parsed and in-memory,
213149
// such as from multi-CGU builds.
214-
//
215-
// All of `cached_modules` (cached from previous incremental builds) can
216-
// immediately go onto the `serialized_modules` modules list and then we can
217-
// split the `modules` array into these two lists.
218150
let mut in_memory = Vec::new();
219-
serialized_modules.extend(cached_modules.into_iter().map(|(buffer, wp)| {
220-
info!("pushing cached module {:?}", wp.cgu_name);
221-
(buffer, CString::new(wp.cgu_name).unwrap())
222-
}));
223151
for module in modules {
224152
match module {
225153
FatLtoInput::InMemory(m) => in_memory.push(m),
226154
FatLtoInput::Serialized { name, buffer } => {
227155
info!("pushing serialized module {:?}", name);
228-
let buffer = SerializedModule::Local(buffer);
229156
serialized_modules.push((buffer, CString::new(name).unwrap()));
230157
}
231158
}
@@ -356,12 +283,13 @@ impl ModuleBufferMethods for ModuleBuffer {
356283
/// can simply be copied over from the incr. comp. cache.
357284
pub(crate) fn run_thin(
358285
cgcx: &CodegenContext<GccCodegenBackend>,
286+
each_linked_rlib_for_lto: &[PathBuf],
359287
modules: Vec<(String, ThinBuffer)>,
360288
cached_modules: Vec<(SerializedModule<ModuleBuffer>, WorkProduct)>,
361289
) -> Result<(Vec<ThinModule<GccCodegenBackend>>, Vec<WorkProduct>), FatalError> {
362290
let dcx = cgcx.create_dcx();
363291
let dcx = dcx.handle();
364-
let lto_data = prepare_lto(cgcx, dcx)?;
292+
let lto_data = prepare_lto(cgcx, each_linked_rlib_for_lto, dcx)?;
365293
if cgcx.opts.cg.linker_plugin_lto.enabled() {
366294
unreachable!(
367295
"We should never reach this case if the LTO step \

‎src/back/write.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use gccjit::{Context, OutputKind};
44
use rustc_codegen_ssa::back::link::ensure_removed;
55
use rustc_codegen_ssa::back::write::{BitcodeSection, CodegenContext, EmitObj, ModuleConfig};
66
use rustc_codegen_ssa::{CompiledModule, ModuleCodegen};
7-
use rustc_errors::DiagCtxtHandle;
87
use rustc_fs_util::link_or_copy;
98
use rustc_session::config::OutputType;
109
use rustc_span::fatal_error::FatalError;
@@ -258,14 +257,6 @@ pub(crate) fn codegen(
258257
))
259258
}
260259

261-
pub(crate) fn link(
262-
_cgcx: &CodegenContext<GccCodegenBackend>,
263-
_dcx: DiagCtxtHandle<'_>,
264-
mut _modules: Vec<ModuleCodegen<GccContext>>,
265-
) -> Result<ModuleCodegen<GccContext>, FatalError> {
266-
unimplemented!();
267-
}
268-
269260
pub(crate) fn save_temp_bitcode(
270261
cgcx: &CodegenContext<GccCodegenBackend>,
271262
_module: &ModuleCodegen<GccContext>,

‎src/builder.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ use rustc_target::spec::{HasTargetSpec, HasX86AbiOpt, Target, X86Abi};
3434

3535
use crate::common::{SignType, TypeReflection, type_is_pointer};
3636
use crate::context::CodegenCx;
37+
use crate::errors;
3738
use crate::intrinsic::llvm;
3839
use crate::type_of::LayoutGccExt;
3940

@@ -1756,6 +1757,20 @@ impl<'a, 'gcc, 'tcx> BuilderMethods<'a, 'tcx> for Builder<'a, 'gcc, 'tcx> {
17561757
call
17571758
}
17581759

1760+
fn tail_call(
1761+
&mut self,
1762+
_llty: Self::Type,
1763+
_fn_attrs: Option<&CodegenFnAttrs>,
1764+
_fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
1765+
_llfn: Self::Value,
1766+
_args: &[Self::Value],
1767+
_funclet: Option<&Self::Funclet>,
1768+
_instance: Option<Instance<'tcx>>,
1769+
) {
1770+
// FIXME: implement support for explicit tail calls like rustc_codegen_llvm.
1771+
self.tcx.dcx().emit_fatal(errors::ExplicitTailCallsUnsupported);
1772+
}
1773+
17591774
fn zext(&mut self, value: RValue<'gcc>, dest_typ: Type<'gcc>) -> RValue<'gcc> {
17601775
// FIXME(antoyo): this does not zero-extend.
17611776
self.gcc_int_cast(value, dest_typ)

‎src/callee.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ pub fn get_fn<'gcc, 'tcx>(cx: &CodegenCx<'gcc, 'tcx>, instance: Instance<'tcx>)
106106
// This is a monomorphization of a generic function.
107107
if !(cx.tcx.sess.opts.share_generics()
108108
|| tcx.codegen_instance_attrs(instance.def).inline
109-
== rustc_attr_data_structures::InlineAttr::Never)
109+
== rustc_hir::attrs::InlineAttr::Never)
110110
{
111111
// When not sharing generics, all instances are in the same
112112
// crate and have hidden visibility.

‎src/errors.rs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,12 @@ pub(crate) struct CopyBitcode {
1414
pub err: std::io::Error,
1515
}
1616

17-
#[derive(Diagnostic)]
18-
#[diag(codegen_gcc_dynamic_linking_with_lto)]
19-
#[note]
20-
pub(crate) struct DynamicLinkingWithLTO;
21-
22-
#[derive(Diagnostic)]
23-
#[diag(codegen_gcc_lto_disallowed)]
24-
pub(crate) struct LtoDisallowed;
25-
26-
#[derive(Diagnostic)]
27-
#[diag(codegen_gcc_lto_dylib)]
28-
pub(crate) struct LtoDylib;
29-
3017
#[derive(Diagnostic)]
3118
#[diag(codegen_gcc_lto_bitcode_from_rlib)]
3219
pub(crate) struct LtoBitcodeFromRlib {
3320
pub gcc_err: String,
3421
}
22+
23+
#[derive(Diagnostic)]
24+
#[diag(codegen_gcc_explicit_tail_calls_unsupported)]
25+
pub(crate) struct ExplicitTailCallsUnsupported;

0 commit comments

Comments
 (0)