From 4b3b4e37e93ed8181f676d1f4ee5ec37b29dd975 Mon Sep 17 00:00:00 2001 From: Eduard-Mihai Burtescu Date: Tue, 29 Nov 2022 19:08:43 +0200 Subject: [PATCH] linker/zombies: stop compilation after zombie errors. --- crates/rustc_codegen_spirv/src/linker/mod.rs | 2 +- .../rustc_codegen_spirv/src/linker/zombies.rs | 19 ++++++++++++++----- .../consts/nested-ref-in-composite.stderr | 7 +------ .../core/ptr/allocate_const_scalar.stderr | 7 +------ 4 files changed, 17 insertions(+), 18 deletions(-) diff --git a/crates/rustc_codegen_spirv/src/linker/mod.rs b/crates/rustc_codegen_spirv/src/linker/mod.rs index 7493d76b9a..2a0fad4cf3 100644 --- a/crates/rustc_codegen_spirv/src/linker/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/mod.rs @@ -182,7 +182,7 @@ pub fn link(sess: &Session, mut inputs: Vec, opts: &Options) -> Result>) { +fn report_error_zombies( + sess: &Session, + module: &Module, + zombie: &FxHashMap>, +) -> super::Result<()> { + let mut result = Ok(()); let mut names = None; for root in super::dce::collect_roots(module) { if let Some(reason) = zombie.get(&root) { @@ -120,14 +125,16 @@ fn report_error_zombies(sess: &Session, module: &Module, zombie: &FxHashMap>() .join("\n"); - sess.struct_span_err(reason.span, reason.reason) + result = Err(sess + .struct_span_err(reason.span, reason.reason) .note(&stack_note) - .emit(); + .emit()); } } + result } -pub fn remove_zombies(sess: &Session, module: &mut Module) { +pub fn remove_zombies(sess: &Session, module: &mut Module) -> super::Result<()> { let zombies_owned = ZombieDecoration::decode_all(module) .map(|(id, zombie)| { let ZombieDecoration { reason, span } = zombie.deserialize(); @@ -145,7 +152,7 @@ pub fn remove_zombies(sess: &Session, module: &mut Module) { // Note: This is O(n^2). while spread_zombie(module, &mut zombies) {} - report_error_zombies(sess, module, &zombies); + let result = report_error_zombies(sess, module, &zombies); if env::var("PRINT_ALL_ZOMBIE").is_ok() { for (&zomb, reason) in &zombies { @@ -208,4 +215,6 @@ pub fn remove_zombies(sess: &Session, module: &mut Module) { module .functions .retain(|f| is_zombie(f.def.as_ref().unwrap(), &zombies).is_none()); + + result } diff --git a/tests/ui/lang/consts/nested-ref-in-composite.stderr b/tests/ui/lang/consts/nested-ref-in-composite.stderr index f295068ba6..0844de7a6b 100644 --- a/tests/ui/lang/consts/nested-ref-in-composite.stderr +++ b/tests/ui/lang/consts/nested-ref-in-composite.stderr @@ -18,10 +18,5 @@ error: constant arrays/structs cannot contain pointers to other constants nested_ref_in_composite::main_array3 main_array3 -error: error:0:0 - No OpEntryPoint instruction was found. This is only allowed if the Linkage capability is being used. - | - = note: spirv-val failed - = note: module `$TEST_BUILD_DIR/lang/consts/nested-ref-in-composite.stage-id.spv.dir/module` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/lang/core/ptr/allocate_const_scalar.stderr b/tests/ui/lang/core/ptr/allocate_const_scalar.stderr index 865a13dd32..05d7b4690e 100644 --- a/tests/ui/lang/core/ptr/allocate_const_scalar.stderr +++ b/tests/ui/lang/core/ptr/allocate_const_scalar.stderr @@ -4,10 +4,5 @@ error: pointer has non-null integer address allocate_const_scalar::main main -error: error:0:0 - No OpEntryPoint instruction was found. This is only allowed if the Linkage capability is being used. - | - = note: spirv-val failed - = note: module `$TEST_BUILD_DIR/lang/core/ptr/allocate_const_scalar.stage-id.spv.dir/module` - -error: aborting due to 2 previous errors +error: aborting due to previous error