Skip to content

Commit

Permalink
Pass owned CodegenResults to link_binary
Browse files Browse the repository at this point in the history
After link_binary the temporary files referenced by CodegenResults are
deleted, so calling link_binary again with the same CodegenResults
should not be allowed.
  • Loading branch information
bjorn3 committed Nov 9, 2024
1 parent cb44c0c commit 0a619db
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_llvm/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ impl CodegenBackend for LlvmCodegenBackend {

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

Expand Down
8 changes: 4 additions & 4 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ pub fn ensure_removed(dcx: DiagCtxtHandle<'_>, path: &Path) {
pub fn link_binary(
sess: &Session,
archive_builder_builder: &dyn ArchiveBuilderBuilder,
codegen_results: &CodegenResults,
codegen_results: CodegenResults,
outputs: &OutputFilenames,
) -> Result<(), ErrorGuaranteed> {
let _timer = sess.timer("link_binary");
Expand Down Expand Up @@ -116,7 +116,7 @@ pub fn link_binary(
link_rlib(
sess,
archive_builder_builder,
codegen_results,
&codegen_results,
RlibFlavor::Normal,
&path,
)?
Expand All @@ -126,7 +126,7 @@ pub fn link_binary(
link_staticlib(
sess,
archive_builder_builder,
codegen_results,
&codegen_results,
&out_filename,
&path,
)?;
Expand All @@ -137,7 +137,7 @@ pub fn link_binary(
archive_builder_builder,
crate_type,
&out_filename,
codegen_results,
&codegen_results,
path.as_ref(),
)?;
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_codegen_ssa/src/traits/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ pub trait CodegenBackend {
codegen_results: CodegenResults,
outputs: &OutputFilenames,
) -> Result<(), ErrorGuaranteed> {
link_binary(sess, &ArArchiveBuilderBuilder, &codegen_results, outputs)
link_binary(sess, &ArArchiveBuilderBuilder, codegen_results, outputs)
}

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

0 comments on commit 0a619db

Please sign in to comment.