Skip to content

Commit c4d1268

Browse files
committed
Merge ref 'a09fbe2c8372' from rust-lang/rust
Pull recent changes from https://github.com/rust-lang/rust via Josh. Upstream ref: a09fbe2 Filtered ref: e8da14f32630072c76aeb944454175f4d8266918 This merge was created using https://github.com/rust-lang/josh-sync.
2 parents deca489 + 4c849c7 commit c4d1268

File tree

319 files changed

+6083
-4104
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

319 files changed

+6083
-4104
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -336,7 +336,7 @@ dependencies = [
336336
"curl",
337337
"indexmap",
338338
"serde",
339-
"toml 0.7.8",
339+
"toml 0.8.23",
340340
]
341341

342342
[[package]]
@@ -4022,6 +4022,7 @@ dependencies = [
40224022
name = "rustc_lint"
40234023
version = "0.0.0"
40244024
dependencies = [
4025+
"bitflags",
40254026
"rustc_abi",
40264027
"rustc_ast",
40274028
"rustc_ast_pretty",
@@ -4072,7 +4073,6 @@ name = "rustc_log"
40724073
version = "0.0.0"
40734074
dependencies = [
40744075
"tracing",
4075-
"tracing-core",
40764076
"tracing-subscriber",
40774077
"tracing-tree",
40784078
]
@@ -5541,9 +5541,9 @@ dependencies = [
55415541

55425542
[[package]]
55435543
name = "tracing-core"
5544-
version = "0.1.30"
5544+
version = "0.1.34"
55455545
source = "registry+https://github.com/rust-lang/crates.io-index"
5546-
checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a"
5546+
checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678"
55475547
dependencies = [
55485548
"once_cell",
55495549
"valuable",

compiler/rustc_borrowck/src/region_infer/opaque_types/mod.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,16 @@ pub(crate) fn apply_computed_concrete_opaque_types<'tcx>(
503503
let mut errors = Vec::new();
504504
for &(key, hidden_type) in opaque_types {
505505
let Some(expected) = get_concrete_opaque_type(concrete_opaque_types, key.def_id) else {
506-
assert!(tcx.use_typing_mode_borrowck(), "non-defining use in defining scope");
506+
if !tcx.use_typing_mode_borrowck() {
507+
if let ty::Alias(ty::Opaque, alias_ty) = hidden_type.ty.kind()
508+
&& alias_ty.def_id == key.def_id.to_def_id()
509+
&& alias_ty.args == key.args
510+
{
511+
continue;
512+
} else {
513+
unreachable!("non-defining use in defining scope");
514+
}
515+
}
507516
errors.push(DeferredOpaqueTypeError::NonDefiningUseInDefiningScope {
508517
span: hidden_type.span,
509518
opaque_type_key: key,

compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ rm tests/ui/abi/large-byval-align.rs # exceeds implementation limit of Cranelift
121121
# ============================================================
122122
rm -r tests/run-make/remap-path-prefix-dwarf # requires llvm-dwarfdump
123123
rm -r tests/run-make/strip # same
124-
rm -r tests/run-make/compiler-builtins # Expects lib/rustlib/src/rust to contains the standard library source
124+
rm -r tests/run-make-cargo/compiler-builtins # Expects lib/rustlib/src/rust to contains the standard library source
125125
rm -r tests/run-make/translation # same
126126
rm -r tests/run-make/missing-unstable-trait-bound # This disables support for unstable features, but running cg_clif needs some unstable features
127127
rm -r tests/run-make/const-trait-stable-toolchain # same
@@ -166,5 +166,5 @@ index 073116933bd..c3e4578204d 100644
166166
EOF
167167

168168
echo "[TEST] rustc test suite"
169-
./x.py test --stage 0 --test-args=--no-capture tests/{codegen-units,run-make,ui,incremental}
169+
./x.py test --stage 0 --test-args=--no-capture tests/{codegen-units,run-make,run-make-cargo,ui,incremental}
170170
popd

compiler/rustc_codegen_cranelift/src/driver/aot.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ use cranelift_object::{ObjectBuilder, ObjectModule};
1212
use rustc_codegen_ssa::assert_module_sources::CguReuse;
1313
use rustc_codegen_ssa::back::link::ensure_removed;
1414
use rustc_codegen_ssa::base::determine_cgu_reuse;
15-
use rustc_codegen_ssa::{CodegenResults, CompiledModule, CrateInfo, errors as ssa_errors};
15+
use rustc_codegen_ssa::{
16+
CodegenResults, CompiledModule, CrateInfo, ModuleKind, errors as ssa_errors,
17+
};
1618
use rustc_data_structures::profiling::SelfProfilerRef;
1719
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
1820
use rustc_data_structures::sync::{IntoDynSyncSend, par_map};
@@ -361,6 +363,7 @@ fn emit_cgu(
361363
invocation_temp,
362364
prof,
363365
product.object,
366+
ModuleKind::Regular,
364367
name.clone(),
365368
producer,
366369
)?;
@@ -369,6 +372,7 @@ fn emit_cgu(
369372
module_regular,
370373
module_global_asm: global_asm_object_file.map(|global_asm_object_file| CompiledModule {
371374
name: format!("{name}.asm"),
375+
kind: ModuleKind::Regular,
372376
object: Some(global_asm_object_file),
373377
dwarf_object: None,
374378
bytecode: None,
@@ -385,6 +389,7 @@ fn emit_module(
385389
invocation_temp: Option<&str>,
386390
prof: &SelfProfilerRef,
387391
mut object: cranelift_object::object::write::Object<'_>,
392+
kind: ModuleKind,
388393
name: String,
389394
producer_str: &str,
390395
) -> Result<CompiledModule, String> {
@@ -425,6 +430,7 @@ fn emit_module(
425430

426431
Ok(CompiledModule {
427432
name,
433+
kind,
428434
object: Some(tmp_file),
429435
dwarf_object: None,
430436
bytecode: None,
@@ -479,6 +485,7 @@ fn reuse_workproduct_for_cgu(
479485
Ok(ModuleCodegenResult {
480486
module_regular: CompiledModule {
481487
name: cgu.name().to_string(),
488+
kind: ModuleKind::Regular,
482489
object: Some(obj_out_regular),
483490
dwarf_object: None,
484491
bytecode: None,
@@ -488,6 +495,7 @@ fn reuse_workproduct_for_cgu(
488495
},
489496
module_global_asm: source_file_global_asm.map(|source_file| CompiledModule {
490497
name: cgu.name().to_string(),
498+
kind: ModuleKind::Regular,
491499
object: Some(obj_out_global_asm),
492500
dwarf_object: None,
493501
bytecode: None,
@@ -643,6 +651,7 @@ fn emit_allocator_module(tcx: TyCtxt<'_>) -> Option<CompiledModule> {
643651
tcx.sess.invocation_temp.as_deref(),
644652
&tcx.sess.prof,
645653
product.object,
654+
ModuleKind::Allocator,
646655
"allocator_shim".to_owned(),
647656
&crate::debuginfo::producer(tcx.sess),
648657
) {

compiler/rustc_codegen_gcc/build_system/src/test.rs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1083,27 +1083,36 @@ where
10831083

10841084
fn test_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
10851085
test_rustc_inner(env, args, |_| Ok(false), false, "run-make")?;
1086+
test_rustc_inner(env, args, |_| Ok(false), false, "run-make-cargo")?;
10861087
test_rustc_inner(env, args, |_| Ok(false), false, "ui")
10871088
}
10881089

10891090
fn test_failing_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
1090-
let result1 = test_rustc_inner(
1091+
let run_make_result = test_rustc_inner(
10911092
env,
10921093
args,
10931094
retain_files_callback("tests/failing-run-make-tests.txt", "run-make"),
10941095
false,
10951096
"run-make",
10961097
);
10971098

1098-
let result2 = test_rustc_inner(
1099+
let run_make_cargo_result = test_rustc_inner(
1100+
env,
1101+
args,
1102+
retain_files_callback("tests/failing-run-make-tests.txt", "run-make-cargo"),
1103+
false,
1104+
"run-make",
1105+
);
1106+
1107+
let ui_result = test_rustc_inner(
10991108
env,
11001109
args,
11011110
retain_files_callback("tests/failing-ui-tests.txt", "ui"),
11021111
false,
11031112
"ui",
11041113
);
11051114

1106-
result1.and(result2)
1115+
run_make_result.and(run_make_cargo_result).and(ui_result)
11071116
}
11081117

11091118
fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
@@ -1120,6 +1129,13 @@ fn test_successful_rustc(env: &Env, args: &TestArg) -> Result<(), String> {
11201129
remove_files_callback("tests/failing-run-make-tests.txt", "run-make"),
11211130
false,
11221131
"run-make",
1132+
)?;
1133+
test_rustc_inner(
1134+
env,
1135+
args,
1136+
remove_files_callback("tests/failing-run-make-tests.txt", "run-make-cargo"),
1137+
false,
1138+
"run-make-cargo",
11231139
)
11241140
}
11251141

compiler/rustc_codegen_gcc/src/back/lto.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,9 @@ pub(crate) fn run_thin(
305305
)
306306
}
307307

308-
pub(crate) fn prepare_thin(
309-
module: ModuleCodegen<GccContext>,
310-
_emit_summary: bool,
311-
) -> (String, ThinBuffer) {
308+
pub(crate) fn prepare_thin(module: ModuleCodegen<GccContext>) -> (String, ThinBuffer) {
312309
let name = module.name;
313-
//let buffer = ThinBuffer::new(module.module_llvm.context, true, emit_summary);
310+
//let buffer = ThinBuffer::new(module.module_llvm.context, true);
314311
let buffer = ThinBuffer::new(&module.module_llvm.context);
315312
(name, buffer)
316313
}
@@ -650,10 +647,6 @@ impl ThinBufferMethods for ThinBuffer {
650647
fn data(&self) -> &[u8] {
651648
&[]
652649
}
653-
654-
fn thin_link_data(&self) -> &[u8] {
655-
unimplemented!();
656-
}
657650
}
658651

659652
pub struct ThinData; //(Arc<TempDir>);

compiler/rustc_codegen_gcc/src/lib.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,8 @@ impl WriteBackendMethods for GccCodegenBackend {
408408
back::write::codegen(cgcx, module, config)
409409
}
410410

411-
fn prepare_thin(
412-
module: ModuleCodegen<Self::Module>,
413-
emit_summary: bool,
414-
) -> (String, Self::ThinBuffer) {
415-
back::lto::prepare_thin(module, emit_summary)
411+
fn prepare_thin(module: ModuleCodegen<Self::Module>) -> (String, Self::ThinBuffer) {
412+
back::lto::prepare_thin(module)
416413
}
417414

418415
fn serialize_module(_module: ModuleCodegen<Self::Module>) -> (String, Self::ModuleBuffer) {

compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,19 @@ pub(crate) fn tune_cpu_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribu
296296
.map(|tune_cpu| llvm::CreateAttrStringValue(cx.llcx, "tune-cpu", tune_cpu))
297297
}
298298

299+
/// Get the `target-features` LLVM attribute.
300+
pub(crate) fn target_features_attr<'ll>(
301+
cx: &CodegenCx<'ll, '_>,
302+
function_features: Vec<String>,
303+
) -> Option<&'ll Attribute> {
304+
let global_features = cx.tcx.global_backend_features(()).iter().map(String::as_str);
305+
let function_features = function_features.iter().map(String::as_str);
306+
let target_features =
307+
global_features.chain(function_features).intersperse(",").collect::<String>();
308+
(!target_features.is_empty())
309+
.then(|| llvm::CreateAttrStringValue(cx.llcx, "target-features", &target_features))
310+
}
311+
299312
/// Get the `NonLazyBind` LLVM attribute,
300313
/// if the codegen options allow skipping the PLT.
301314
pub(crate) fn non_lazy_bind_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
@@ -523,14 +536,7 @@ pub(crate) fn llfn_attrs_from_instance<'ll, 'tcx>(
523536
}
524537
}
525538

526-
let global_features = cx.tcx.global_backend_features(()).iter().map(|s| s.as_str());
527-
let function_features = function_features.iter().map(|s| s.as_str());
528-
let target_features: String =
529-
global_features.chain(function_features).intersperse(",").collect();
530-
531-
if !target_features.is_empty() {
532-
to_add.push(llvm::CreateAttrStringValue(cx.llcx, "target-features", &target_features));
533-
}
539+
to_add.extend(target_features_attr(cx, function_features));
534540

535541
attributes::apply_to_llfn(llfn, Function, &to_add);
536542
}

compiler/rustc_codegen_llvm/src/back/lto.rs

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use object::{Object, ObjectSection};
1111
use rustc_codegen_ssa::back::lto::{SerializedModule, ThinModule, ThinShared};
1212
use rustc_codegen_ssa::back::write::{CodegenContext, FatLtoInput};
1313
use rustc_codegen_ssa::traits::*;
14-
use rustc_codegen_ssa::{ModuleCodegen, looks_like_rust_object_file};
14+
use rustc_codegen_ssa::{ModuleCodegen, ModuleKind, looks_like_rust_object_file};
1515
use rustc_data_structures::fx::FxHashMap;
1616
use rustc_data_structures::memmap::Mmap;
1717
use rustc_errors::DiagCtxtHandle;
@@ -185,12 +185,9 @@ pub(crate) fn run_thin(
185185
thin_lto(cgcx, dcx, modules, upstream_modules, cached_modules, &symbols_below_threshold)
186186
}
187187

188-
pub(crate) fn prepare_thin(
189-
module: ModuleCodegen<ModuleLlvm>,
190-
emit_summary: bool,
191-
) -> (String, ThinBuffer) {
188+
pub(crate) fn prepare_thin(module: ModuleCodegen<ModuleLlvm>) -> (String, ThinBuffer) {
192189
let name = module.name;
193-
let buffer = ThinBuffer::new(module.module_llvm.llmod(), true, emit_summary);
190+
let buffer = ThinBuffer::new(module.module_llvm.llmod(), true);
194191
(name, buffer)
195192
}
196193

@@ -225,9 +222,15 @@ fn fat_lto(
225222
// All the other modules will be serialized and reparsed into the new
226223
// context, so this hopefully avoids serializing and parsing the largest
227224
// codegen unit.
225+
//
226+
// Additionally use a regular module as the base here to ensure that various
227+
// file copy operations in the backend work correctly. The only other kind
228+
// of module here should be an allocator one, and if your crate is smaller
229+
// than the allocator module then the size doesn't really matter anyway.
228230
let costliest_module = in_memory
229231
.iter()
230232
.enumerate()
233+
.filter(|&(_, module)| module.kind == ModuleKind::Regular)
231234
.map(|(i, module)| {
232235
let cost = unsafe { llvm::LLVMRustModuleCost(module.module_llvm.llmod()) };
233236
(cost, i)
@@ -681,9 +684,9 @@ unsafe impl Send for ThinBuffer {}
681684
unsafe impl Sync for ThinBuffer {}
682685

683686
impl ThinBuffer {
684-
pub(crate) fn new(m: &llvm::Module, is_thin: bool, emit_summary: bool) -> ThinBuffer {
687+
pub(crate) fn new(m: &llvm::Module, is_thin: bool) -> ThinBuffer {
685688
unsafe {
686-
let buffer = llvm::LLVMRustThinLTOBufferCreate(m, is_thin, emit_summary);
689+
let buffer = llvm::LLVMRustThinLTOBufferCreate(m, is_thin);
687690
ThinBuffer(buffer)
688691
}
689692
}
@@ -692,21 +695,21 @@ impl ThinBuffer {
692695
let mut ptr = NonNull::new(ptr).unwrap();
693696
ThinBuffer(unsafe { ptr.as_mut() })
694697
}
695-
}
696698

697-
impl ThinBufferMethods for ThinBuffer {
698-
fn data(&self) -> &[u8] {
699+
pub(crate) fn thin_link_data(&self) -> &[u8] {
699700
unsafe {
700-
let ptr = llvm::LLVMRustThinLTOBufferPtr(self.0) as *const _;
701-
let len = llvm::LLVMRustThinLTOBufferLen(self.0);
701+
let ptr = llvm::LLVMRustThinLTOBufferThinLinkDataPtr(self.0) as *const _;
702+
let len = llvm::LLVMRustThinLTOBufferThinLinkDataLen(self.0);
702703
slice::from_raw_parts(ptr, len)
703704
}
704705
}
706+
}
705707

706-
fn thin_link_data(&self) -> &[u8] {
708+
impl ThinBufferMethods for ThinBuffer {
709+
fn data(&self) -> &[u8] {
707710
unsafe {
708-
let ptr = llvm::LLVMRustThinLTOBufferThinLinkDataPtr(self.0) as *const _;
709-
let len = llvm::LLVMRustThinLTOBufferThinLinkDataLen(self.0);
711+
let ptr = llvm::LLVMRustThinLTOBufferPtr(self.0) as *const _;
712+
let len = llvm::LLVMRustThinLTOBufferLen(self.0);
710713
slice::from_raw_parts(ptr, len)
711714
}
712715
}

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ pub(crate) fn codegen(
837837
"LLVM_module_codegen_make_bitcode",
838838
&*module.name,
839839
);
840-
ThinBuffer::new(llmod, config.emit_thin_lto, false)
840+
ThinBuffer::new(llmod, config.emit_thin_lto)
841841
};
842842
let data = thin.data();
843843
let _timer = cgcx

0 commit comments

Comments
 (0)