Skip to content

Commit ffccab6

Browse files
committed
Auto merge of #156278 - JonathanBrouwer:rollup-O8O1IcI, r=JonathanBrouwer
Rollup of 10 pull requests Successful merges: - #146273 (lint ImproperCTypes: refactor linting architecture (part 2)) - #154025 (Add `keepalive`, `set_keepalive` to `TcpStream` implementations) - #156024 (CFI: Fix LTO for `#![no_builtins]` crates with CFI) - #156243 (Move CrateInfo computation after codegen_crate) - #154846 (Add better default spans for the `Ty` impl of `QueryKey`) - #155220 (cg_clif: Don't show verbose run-make cmd output for passing tests) - #156204 (Implemented `PathBuf::into_string`) - #156245 (Move invocation_temp into OutputFilenames) - #156250 (add a few new solver normalization tests) - #156265 (Remove unused `ToStableHashKey` impls.)
2 parents 32bd660 + c19565b commit ffccab6

142 files changed

Lines changed: 1908 additions & 654 deletions

File tree

Some content is hidden

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

Cargo.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4101,6 +4101,7 @@ dependencies = [
41014101
name = "rustc_interface"
41024102
version = "0.0.0"
41034103
dependencies = [
4104+
"rand 0.9.2",
41044105
"rustc_abi",
41054106
"rustc_ast",
41064107
"rustc_ast_lowering",
@@ -4602,7 +4603,6 @@ version = "0.0.0"
46024603
dependencies = [
46034604
"getopts",
46044605
"libc",
4605-
"rand 0.9.2",
46064606
"rustc_abi",
46074607
"rustc_ast",
46084608
"rustc_data_structures",

compiler/rustc_codegen_cranelift/scripts/test_rustc_tests.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,5 +200,5 @@ index 073116933bd..c3e4578204d 100644
200200
EOF
201201

202202
echo "[TEST] rustc test suite"
203-
./x.py test --stage 0 --test-args=--no-capture tests/{codegen-units,run-make,run-make-cargo,ui,incremental}
203+
./x.py test --stage 0 --no-capture --verbose-run-make-subprocess-output=false tests/{codegen-units,run-make,run-make-cargo,ui,incremental}
204204
popd

compiler/rustc_codegen_cranelift/src/driver/aot.rs

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ fn make_module(sess: &Session, name: String) -> UnwindModule<ObjectModule> {
150150

151151
fn emit_cgu(
152152
output_filenames: &OutputFilenames,
153-
invocation_temp: Option<&str>,
154153
prof: &SelfProfilerRef,
155154
name: String,
156155
module: UnwindModule<ObjectModule>,
@@ -166,7 +165,6 @@ fn emit_cgu(
166165

167166
let module_regular = emit_module(
168167
output_filenames,
169-
invocation_temp,
170168
prof,
171169
product.object,
172170
ModuleKind::Regular,
@@ -192,7 +190,6 @@ fn emit_cgu(
192190

193191
fn emit_module(
194192
output_filenames: &OutputFilenames,
195-
invocation_temp: Option<&str>,
196193
prof: &SelfProfilerRef,
197194
mut object: cranelift_object::object::write::Object<'_>,
198195
kind: ModuleKind,
@@ -211,7 +208,7 @@ fn emit_module(
211208
object.set_section_data(comment_section, producer, 1);
212209
}
213210

214-
let tmp_file = output_filenames.temp_path_for_cgu(OutputType::Object, &name, invocation_temp);
211+
let tmp_file = output_filenames.temp_path_for_cgu(OutputType::Object, &name);
215212
let file = match File::create(&tmp_file) {
216213
Ok(file) => file,
217214
Err(err) => return Err(format!("error creating object file: {}", err)),
@@ -251,11 +248,8 @@ fn reuse_workproduct_for_cgu(
251248
cgu: &CodegenUnit<'_>,
252249
) -> Result<ModuleCodegenResult, String> {
253250
let work_product = cgu.previous_work_product(tcx);
254-
let obj_out_regular = tcx.output_filenames(()).temp_path_for_cgu(
255-
OutputType::Object,
256-
cgu.name().as_str(),
257-
tcx.sess.invocation_temp.as_deref(),
258-
);
251+
let obj_out_regular =
252+
tcx.output_filenames(()).temp_path_for_cgu(OutputType::Object, cgu.name().as_str());
259253
let source_file_regular = rustc_incremental::in_incr_comp_dir_sess(
260254
tcx.sess,
261255
work_product.saved_files.get("o").expect("no saved object file in work product"),
@@ -394,7 +388,6 @@ fn module_codegen(
394388
let producer = crate::debuginfo::producer(tcx.sess);
395389

396390
let profiler = tcx.prof.clone();
397-
let invocation_temp = tcx.sess.invocation_temp.clone();
398391
let output_filenames = tcx.output_filenames(()).clone();
399392
let should_write_ir = crate::pretty_clif::should_write_ir(tcx.sess);
400393

@@ -421,19 +414,13 @@ fn module_codegen(
421414

422415
let global_asm_object_file =
423416
profiler.generic_activity_with_arg("compile assembly", &*cgu_name).run(|| {
424-
crate::global_asm::compile_global_asm(
425-
&global_asm_config,
426-
&cgu_name,
427-
global_asm,
428-
invocation_temp.as_deref(),
429-
)
417+
crate::global_asm::compile_global_asm(&global_asm_config, &cgu_name, global_asm)
430418
})?;
431419

432420
let codegen_result =
433421
profiler.generic_activity_with_arg("write object file", &*cgu_name).run(|| {
434422
emit_cgu(
435423
&global_asm_config.output_filenames,
436-
invocation_temp.as_deref(),
437424
&profiler,
438425
cgu_name,
439426
module,
@@ -456,7 +443,6 @@ fn emit_allocator_module(tcx: TyCtxt<'_>) -> Option<CompiledModule> {
456443

457444
match emit_module(
458445
tcx.output_filenames(()),
459-
tcx.sess.invocation_temp.as_deref(),
460446
&tcx.sess.prof,
461447
product.object,
462448
ModuleKind::Allocator,

compiler/rustc_codegen_cranelift/src/driver/jit.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ fn create_jit_module(
3333
(jit_module, cx)
3434
}
3535

36-
pub(crate) fn run_jit(tcx: TyCtxt<'_>, crate_info: &CrateInfo, jit_args: Vec<String>) -> ! {
36+
pub(crate) fn run_jit(tcx: TyCtxt<'_>, target_cpu: String, jit_args: Vec<String>) -> ! {
3737
if !tcx.crate_types().contains(&rustc_session::config::CrateType::Executable) {
3838
tcx.dcx().fatal("can't jit non-executable crate");
3939
}
4040

4141
let output_filenames = tcx.output_filenames(());
42+
let crate_info = CrateInfo::new(tcx, target_cpu);
4243
let should_write_ir = crate::pretty_clif::should_write_ir(tcx.sess);
43-
let (mut jit_module, mut debug_context) = create_jit_module(tcx, crate_info);
44+
let (mut jit_module, mut debug_context) = create_jit_module(tcx, &crate_info);
4445
let mut cached_context = Context::new();
4546

4647
let cgus = tcx.collect_and_partition_mono_items(()).codegen_units;

compiler/rustc_codegen_cranelift/src/global_asm.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ pub(crate) fn compile_global_asm(
185185
config: &GlobalAsmConfig,
186186
cgu_name: &str,
187187
global_asm: String,
188-
invocation_temp: Option<&str>,
189188
) -> Result<Option<PathBuf>, String> {
190189
if global_asm.is_empty() {
191190
return Ok(None);
@@ -200,7 +199,7 @@ pub(crate) fn compile_global_asm(
200199
global_asm.push('\n');
201200

202201
let global_asm_object_file = add_file_stem_postfix(
203-
config.output_filenames.temp_path_for_cgu(OutputType::Object, cgu_name, invocation_temp),
202+
config.output_filenames.temp_path_for_cgu(OutputType::Object, cgu_name),
204203
".asm",
205204
);
206205

compiler/rustc_codegen_cranelift/src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,12 @@ impl CodegenBackend for CraneliftCodegenBackend {
209209
.to_owned()
210210
}
211211

212-
fn codegen_crate(&self, tcx: TyCtxt<'_>, _crate_info: &CrateInfo) -> Box<dyn Any> {
212+
fn codegen_crate(&self, tcx: TyCtxt<'_>) -> Box<dyn Any> {
213213
info!("codegen crate {}", tcx.crate_name(LOCAL_CRATE));
214214
let config = self.config.get().unwrap();
215215
if config.jit_mode {
216216
#[cfg(feature = "jit")]
217-
driver::jit::run_jit(tcx, _crate_info, config.jit_args.clone());
217+
driver::jit::run_jit(tcx, self.target_cpu(tcx.sess), config.jit_args.clone());
218218

219219
#[cfg(not(feature = "jit"))]
220220
tcx.dcx().fatal("jit support was disabled when compiling rustc_codegen_cranelift");
@@ -228,6 +228,7 @@ impl CodegenBackend for CraneliftCodegenBackend {
228228
ongoing_codegen: Box<dyn Any>,
229229
sess: &Session,
230230
outputs: &OutputFilenames,
231+
_crate_info: &CrateInfo,
231232
) -> (CompiledModules, FxIndexMap<WorkProductId, WorkProduct>) {
232233
ongoing_codegen.downcast::<driver::aot::OngoingCodegen>().unwrap().join(sess, outputs)
233234
}

compiler/rustc_codegen_gcc/src/back/write.rs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,8 @@ pub(crate) fn codegen(
2929
let lto_mode = module.module_llvm.lto_mode;
3030
let lto_supported = module.module_llvm.lto_supported;
3131

32-
let bc_out = cgcx.output_filenames.temp_path_for_cgu(
33-
OutputType::Bitcode,
34-
&module.name,
35-
cgcx.invocation_temp.as_deref(),
36-
);
37-
let obj_out = cgcx.output_filenames.temp_path_for_cgu(
38-
OutputType::Object,
39-
&module.name,
40-
cgcx.invocation_temp.as_deref(),
41-
);
32+
let bc_out = cgcx.output_filenames.temp_path_for_cgu(OutputType::Bitcode, &module.name);
33+
let obj_out = cgcx.output_filenames.temp_path_for_cgu(OutputType::Object, &module.name);
4234

4335
if config.bitcode_needed() {
4436
let _timer =
@@ -82,22 +74,15 @@ pub(crate) fn codegen(
8274
}
8375

8476
if config.emit_ir {
85-
let out = cgcx.output_filenames.temp_path_for_cgu(
86-
OutputType::LlvmAssembly,
87-
&module.name,
88-
cgcx.invocation_temp.as_deref(),
89-
);
77+
let out =
78+
cgcx.output_filenames.temp_path_for_cgu(OutputType::LlvmAssembly, &module.name);
9079
std::fs::write(out, "").expect("write file");
9180
}
9281

9382
if config.emit_asm {
9483
let _timer =
9584
prof.generic_activity_with_arg("GCC_module_codegen_emit_asm", &*module.name);
96-
let path = cgcx.output_filenames.temp_path_for_cgu(
97-
OutputType::Assembly,
98-
&module.name,
99-
cgcx.invocation_temp.as_deref(),
100-
);
85+
let path = cgcx.output_filenames.temp_path_for_cgu(OutputType::Assembly, &module.name);
10186
context.compile_to_file(OutputKind::Assembler, path.to_str().expect("path to str"));
10287
}
10388

@@ -215,7 +200,6 @@ pub(crate) fn codegen(
215200
config.emit_asm,
216201
config.emit_ir,
217202
&cgcx.output_filenames,
218-
cgcx.invocation_temp.as_deref(),
219203
)
220204
}
221205

compiler/rustc_codegen_gcc/src/lib.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,20 +291,21 @@ impl CodegenBackend for GccCodegenBackend {
291291
target_cpu(sess).to_owned()
292292
}
293293

294-
fn codegen_crate(&self, tcx: TyCtxt<'_>, crate_info: &CrateInfo) -> Box<dyn Any> {
295-
Box::new(codegen_crate(self.clone(), tcx, crate_info))
294+
fn codegen_crate(&self, tcx: TyCtxt<'_>) -> Box<dyn Any> {
295+
Box::new(codegen_crate(self.clone(), tcx))
296296
}
297297

298298
fn join_codegen(
299299
&self,
300300
ongoing_codegen: Box<dyn Any>,
301301
sess: &Session,
302302
_outputs: &OutputFilenames,
303+
crate_info: &CrateInfo,
303304
) -> (CompiledModules, FxIndexMap<WorkProductId, WorkProduct>) {
304305
ongoing_codegen
305306
.downcast::<rustc_codegen_ssa::back::write::OngoingCodegen<GccCodegenBackend>>()
306307
.expect("Expected GccCodegenBackend's OngoingCodegen, found Box<Any>")
307-
.join(sess)
308+
.join(sess, crate_info)
308309
}
309310

310311
fn target_config(&self, sess: &Session) -> TargetConfig {

compiler/rustc_codegen_llvm/src/back/write.rs

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,13 @@ pub(crate) fn create_target_machine(tcx: TyCtxt<'_>, mod_name: &str) -> OwnedTar
117117
tcx.sess.split_debuginfo(),
118118
tcx.sess.opts.unstable_opts.split_dwarf_kind,
119119
mod_name,
120-
tcx.sess.invocation_temp.as_deref(),
121120
)
122121
} else {
123122
None
124123
};
125124

126-
let output_obj_file = Some(tcx.output_filenames(()).temp_path_for_cgu(
127-
OutputType::Object,
128-
mod_name,
129-
tcx.sess.invocation_temp.as_deref(),
130-
));
125+
let output_obj_file =
126+
Some(tcx.output_filenames(()).temp_path_for_cgu(OutputType::Object, mod_name));
131127
let config = TargetMachineFactoryConfig { split_dwarf_file, output_obj_file };
132128

133129
target_machine_factory(
@@ -322,11 +318,7 @@ pub(crate) fn save_temp_bitcode(
322318
return;
323319
}
324320
let ext = format!("{name}.bc");
325-
let path = cgcx.output_filenames.temp_path_ext_for_cgu(
326-
&ext,
327-
&module.name,
328-
cgcx.invocation_temp.as_deref(),
329-
);
321+
let path = cgcx.output_filenames.temp_path_ext_for_cgu(&ext, &module.name);
330322
write_bitcode_to_file(&module.module_llvm, &path)
331323
}
332324

@@ -949,11 +941,8 @@ pub(crate) fn optimize(
949941
if let Some(thin_lto_buffer) = thin_lto_buffer {
950942
let thin_lto_buffer = thin_lto_buffer.unwrap();
951943
module.thin_lto_buffer = Some(thin_lto_buffer.data().to_vec());
952-
let bc_summary_out = cgcx.output_filenames.temp_path_for_cgu(
953-
OutputType::ThinLinkBitcode,
954-
&module.name,
955-
cgcx.invocation_temp.as_deref(),
956-
);
944+
let bc_summary_out =
945+
cgcx.output_filenames.temp_path_for_cgu(OutputType::ThinLinkBitcode, &module.name);
957946
if let Some(thin_lto_summary_buffer) = thin_lto_summary_buffer
958947
&& let Some(thin_link_bitcode_filename) = bc_summary_out.file_name()
959948
{
@@ -1008,16 +997,8 @@ pub(crate) fn codegen(
1008997
// copy it to the .o file, and delete the bitcode if it wasn't
1009998
// otherwise requested.
1010999

1011-
let bc_out = cgcx.output_filenames.temp_path_for_cgu(
1012-
OutputType::Bitcode,
1013-
&module.name,
1014-
cgcx.invocation_temp.as_deref(),
1015-
);
1016-
let obj_out = cgcx.output_filenames.temp_path_for_cgu(
1017-
OutputType::Object,
1018-
&module.name,
1019-
cgcx.invocation_temp.as_deref(),
1020-
);
1000+
let bc_out = cgcx.output_filenames.temp_path_for_cgu(OutputType::Bitcode, &module.name);
1001+
let obj_out = cgcx.output_filenames.temp_path_for_cgu(OutputType::Object, &module.name);
10211002

10221003
if config.bitcode_needed() {
10231004
if config.emit_bc || config.emit_obj == EmitObj::Bitcode {
@@ -1055,11 +1036,8 @@ pub(crate) fn codegen(
10551036
if config.emit_ir {
10561037
let _timer =
10571038
prof.generic_activity_with_arg("LLVM_module_codegen_emit_ir", &*module.name);
1058-
let out = cgcx.output_filenames.temp_path_for_cgu(
1059-
OutputType::LlvmAssembly,
1060-
&module.name,
1061-
cgcx.invocation_temp.as_deref(),
1062-
);
1039+
let out =
1040+
cgcx.output_filenames.temp_path_for_cgu(OutputType::LlvmAssembly, &module.name);
10631041
let out_c = path_to_c_string(&out);
10641042

10651043
extern "C" fn demangle_callback(
@@ -1103,11 +1081,7 @@ pub(crate) fn codegen(
11031081
if config.emit_asm {
11041082
let _timer =
11051083
prof.generic_activity_with_arg("LLVM_module_codegen_emit_asm", &*module.name);
1106-
let path = cgcx.output_filenames.temp_path_for_cgu(
1107-
OutputType::Assembly,
1108-
&module.name,
1109-
cgcx.invocation_temp.as_deref(),
1110-
);
1084+
let path = cgcx.output_filenames.temp_path_for_cgu(OutputType::Assembly, &module.name);
11111085

11121086
// We can't use the same module for asm and object code output,
11131087
// because that triggers various errors like invalid IR or broken
@@ -1136,9 +1110,7 @@ pub(crate) fn codegen(
11361110
let _timer =
11371111
prof.generic_activity_with_arg("LLVM_module_codegen_emit_obj", &*module.name);
11381112

1139-
let dwo_out = cgcx
1140-
.output_filenames
1141-
.temp_path_dwo_for_cgu(&module.name, cgcx.invocation_temp.as_deref());
1113+
let dwo_out = cgcx.output_filenames.temp_path_dwo_for_cgu(&module.name);
11421114
let dwo_out = match (cgcx.split_debuginfo, cgcx.split_dwarf_kind) {
11431115
// Don't change how DWARF is emitted when disabled.
11441116
(SplitDebuginfo::Off, _) => None,
@@ -1203,7 +1175,6 @@ pub(crate) fn codegen(
12031175
config.emit_asm,
12041176
config.emit_ir,
12051177
&cgcx.output_filenames,
1206-
cgcx.invocation_temp.as_deref(),
12071178
)
12081179
}
12091180

compiler/rustc_codegen_llvm/src/debuginfo/metadata.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,6 @@ pub(crate) fn build_compile_unit_di_node<'ll, 'tcx>(
903903
tcx.sess.split_debuginfo(),
904904
tcx.sess.opts.unstable_opts.split_dwarf_kind,
905905
codegen_unit_name,
906-
tcx.sess.invocation_temp.as_deref(),
907906
) {
908907
// We get a path relative to the working directory from split_dwarf_path
909908
Some(tcx.sess.source_map().path_mapping().to_real_filename(work_dir, f))

0 commit comments

Comments
 (0)