Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions compiler/rustc_codegen_ssa/src/back/write.rs
Original file line number Diff line number Diff line change
Expand Up @@ -907,8 +907,6 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
module: CachedModuleCodegen,
module_config: &ModuleConfig,
) -> WorkItemResult<B> {
assert!(module_config.emit_obj != EmitObj::None);

let incr_comp_session_dir = cgcx.incr_comp_session_dir.as_ref().unwrap();

let load_from_incr_comp_dir = |output_path: PathBuf, saved_path: &str| {
Expand All @@ -928,12 +926,6 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
}
};

let object = load_from_incr_comp_dir(
cgcx.output_filenames.temp_path(OutputType::Object, Some(&module.name)),
module.source.saved_files.get("o").unwrap_or_else(|| {
cgcx.create_dcx().emit_fatal(errors::NoSavedObjectFile { cgu_name: &module.name })
}),
);
let dwarf_object =
module.source.saved_files.get("dwo").as_ref().and_then(|saved_dwarf_object_file| {
let dwarf_obj_out = cgcx
Expand All @@ -955,9 +947,14 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
}
};

let should_emit_obj = module_config.emit_obj != EmitObj::None;
let assembly = load_from_incr_cache(module_config.emit_asm, OutputType::Assembly);
let llvm_ir = load_from_incr_cache(module_config.emit_ir, OutputType::LlvmAssembly);
let bytecode = load_from_incr_cache(module_config.emit_bc, OutputType::Bitcode);
let object = load_from_incr_cache(should_emit_obj, OutputType::Object);
if should_emit_obj && object.is_none() {
cgcx.create_dcx().emit_fatal(errors::NoSavedObjectFile { cgu_name: &module.name })
}

WorkItemResult::Finished(CompiledModule {
name: module.name,
Expand Down
6 changes: 6 additions & 0 deletions tests/run-make/artifact-incr-cache-no-obj/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#![crate_name = "foo"]

#[inline(never)]
pub fn add(a: u32, b: u32) -> u32 {
a + b
}
23 changes: 23 additions & 0 deletions tests/run-make/artifact-incr-cache-no-obj/rmake.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// emitting an object file is not necessary if user didn't ask for one
//
// This test is similar to run-make/artifact-incr-cache but it doesn't
// require to emit an object file
//
// Fixes: rust-lang/rust#123234

extern crate run_make_support;

use run_make_support::{rustc, tmp_dir};

fn main() {
let inc_dir = tmp_dir();

for _ in 0..=1 {
rustc()
.input("lib.rs")
.crate_type("lib")
.emit("asm,dep-info,link,mir,llvm-ir,llvm-bc")
.incremental(&inc_dir)
.run();
}
}