Skip to content

Commit 4d2aca5

Browse files
committed
Move invocation_temp into OutputFilenames
While it was previously defined in Session, it is only ever used with OutputFilenames methods.
1 parent 4feb722 commit 4d2aca5

14 files changed

Lines changed: 64 additions & 169 deletions

File tree

Cargo.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4100,6 +4100,7 @@ dependencies = [
41004100
name = "rustc_interface"
41014101
version = "0.0.0"
41024102
dependencies = [
4103+
"rand 0.9.2",
41034104
"rustc_abi",
41044105
"rustc_ast",
41054106
"rustc_ast_lowering",
@@ -4601,7 +4602,6 @@ version = "0.0.0"
46014602
dependencies = [
46024603
"getopts",
46034604
"libc",
4604-
"rand 0.9.2",
46054605
"rustc_abi",
46064606
"rustc_ast",
46074607
"rustc_data_structures",

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/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_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_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))

compiler/rustc_codegen_ssa/src/back/link.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -115,12 +115,7 @@ pub fn link_binary(
115115
let path = MaybeTempDir::new(tmpdir, sess.opts.cg.save_temps);
116116

117117
let crate_name = format!("{}", crate_info.local_crate_name);
118-
let out_filename = output.file_for_writing(
119-
outputs,
120-
OutputType::Exe,
121-
&crate_name,
122-
sess.invocation_temp.as_deref(),
123-
);
118+
let out_filename = output.file_for_writing(outputs, OutputType::Exe, &crate_name);
124119
match crate_type {
125120
CrateType::Rlib => {
126121
let _timer = sess.timer("link_rlib");

compiler/rustc_codegen_ssa/src/back/write.rs

Lines changed: 5 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -285,17 +285,13 @@ impl TargetMachineFactoryConfig {
285285
cgcx.split_debuginfo,
286286
cgcx.split_dwarf_kind,
287287
module_name,
288-
cgcx.invocation_temp.as_deref(),
289288
)
290289
} else {
291290
None
292291
};
293292

294-
let output_obj_file = Some(cgcx.output_filenames.temp_path_for_cgu(
295-
OutputType::Object,
296-
module_name,
297-
cgcx.invocation_temp.as_deref(),
298-
));
293+
let output_obj_file =
294+
Some(cgcx.output_filenames.temp_path_for_cgu(OutputType::Object, module_name));
299295
TargetMachineFactoryConfig { split_dwarf_file, output_obj_file }
300296
}
301297
}
@@ -322,7 +318,6 @@ pub struct CodegenContext {
322318
pub time_trace: bool,
323319
pub crate_types: Vec<CrateType>,
324320
pub output_filenames: Arc<OutputFilenames>,
325-
pub invocation_temp: Option<String>,
326321
pub module_config: Arc<ModuleConfig>,
327322
pub opt_level: OptLevel,
328323
pub backend_features: Vec<String>,
@@ -529,11 +524,7 @@ pub fn produce_final_output_artifacts(
529524
if let [module] = &compiled_modules.modules[..] {
530525
// 1) Only one codegen unit. In this case it's no difficulty
531526
// to copy `foo.0.x` to `foo.x`.
532-
let path = crate_output.temp_path_for_cgu(
533-
output_type,
534-
&module.name,
535-
sess.invocation_temp.as_deref(),
536-
);
527+
let path = crate_output.temp_path_for_cgu(output_type, &module.name);
537528
let output = crate_output.path(output_type);
538529
if !output_type.is_text_output() && output.is_tty() {
539530
sess.dcx()
@@ -912,12 +903,7 @@ fn execute_copy_from_cache_work_item(
912903
module.source.saved_files.get("dwo").as_ref().and_then(|saved_dwarf_object_file| {
913904
let dwarf_obj_out = cgcx
914905
.output_filenames
915-
.split_dwarf_path(
916-
cgcx.split_debuginfo,
917-
cgcx.split_dwarf_kind,
918-
&module.name,
919-
cgcx.invocation_temp.as_deref(),
920-
)
906+
.split_dwarf_path(cgcx.split_debuginfo, cgcx.split_dwarf_kind, &module.name)
921907
.expect(
922908
"saved dwarf object in work product but `split_dwarf_path` returned `None`",
923909
);
@@ -927,11 +913,7 @@ fn execute_copy_from_cache_work_item(
927913
let mut load_from_incr_cache = |perform, output_type: OutputType| {
928914
if perform {
929915
let saved_file = module.source.saved_files.get(output_type.extension())?;
930-
let output_path = cgcx.output_filenames.temp_path_for_cgu(
931-
output_type,
932-
&module.name,
933-
cgcx.invocation_temp.as_deref(),
934-
);
916+
let output_path = cgcx.output_filenames.temp_path_for_cgu(output_type, &module.name);
935917
load_from_incr_comp_dir(output_path, &saved_file)
936918
} else {
937919
None
@@ -1313,7 +1295,6 @@ fn start_executing_work<B: ExtraBackendMethods>(
13131295
split_dwarf_kind: tcx.sess.opts.unstable_opts.split_dwarf_kind,
13141296
parallel: backend.supports_parallel() && !sess.opts.unstable_opts.no_parallel_backend,
13151297
pointer_size: tcx.data_layout.pointer_size(),
1316-
invocation_temp: sess.invocation_temp.clone(),
13171298
};
13181299

13191300
// This is the "main loop" of parallel work happening for parallel codegen.

0 commit comments

Comments
 (0)