Skip to content

Commit 0a619db

Browse files
committed
Pass owned CodegenResults to link_binary
After link_binary the temporary files referenced by CodegenResults are deleted, so calling link_binary again with the same CodegenResults should not be allowed.
1 parent cb44c0c commit 0a619db

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

compiler/rustc_codegen_llvm/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ impl CodegenBackend for LlvmCodegenBackend {
382382

383383
// Run the linker on any artifacts that resulted from the LLVM run.
384384
// This should produce either a finished executable or library.
385-
link_binary(sess, &LlvmArchiveBuilderBuilder, &codegen_results, outputs)
385+
link_binary(sess, &LlvmArchiveBuilderBuilder, codegen_results, outputs)
386386
}
387387
}
388388

compiler/rustc_codegen_ssa/src/back/link.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub fn ensure_removed(dcx: DiagCtxtHandle<'_>, path: &Path) {
6969
pub fn link_binary(
7070
sess: &Session,
7171
archive_builder_builder: &dyn ArchiveBuilderBuilder,
72-
codegen_results: &CodegenResults,
72+
codegen_results: CodegenResults,
7373
outputs: &OutputFilenames,
7474
) -> Result<(), ErrorGuaranteed> {
7575
let _timer = sess.timer("link_binary");
@@ -116,7 +116,7 @@ pub fn link_binary(
116116
link_rlib(
117117
sess,
118118
archive_builder_builder,
119-
codegen_results,
119+
&codegen_results,
120120
RlibFlavor::Normal,
121121
&path,
122122
)?
@@ -126,7 +126,7 @@ pub fn link_binary(
126126
link_staticlib(
127127
sess,
128128
archive_builder_builder,
129-
codegen_results,
129+
&codegen_results,
130130
&out_filename,
131131
&path,
132132
)?;
@@ -137,7 +137,7 @@ pub fn link_binary(
137137
archive_builder_builder,
138138
crate_type,
139139
&out_filename,
140-
codegen_results,
140+
&codegen_results,
141141
path.as_ref(),
142142
)?;
143143
}

compiler/rustc_codegen_ssa/src/traits/backend.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ pub trait CodegenBackend {
9090
codegen_results: CodegenResults,
9191
outputs: &OutputFilenames,
9292
) -> Result<(), ErrorGuaranteed> {
93-
link_binary(sess, &ArArchiveBuilderBuilder, &codegen_results, outputs)
93+
link_binary(sess, &ArArchiveBuilderBuilder, codegen_results, outputs)
9494
}
9595

9696
/// Returns `true` if this backend can be safely called from multiple threads.

0 commit comments

Comments
 (0)