From 47d23ba800dad4bf135d9c91e2f3e9f99af23bcc Mon Sep 17 00:00:00 2001 From: Ashley Hauck Date: Wed, 11 Nov 2020 14:02:05 +0100 Subject: [PATCH] Don't ICE on spir-v module version mismatch (#226) --- crates/rustc_codegen_spirv/src/linker/mod.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/rustc_codegen_spirv/src/linker/mod.rs b/crates/rustc_codegen_spirv/src/linker/mod.rs index b6979cf3ac..5bb5f82c37 100644 --- a/crates/rustc_codegen_spirv/src/linker/mod.rs +++ b/crates/rustc_codegen_spirv/src/linker/mod.rs @@ -99,7 +99,16 @@ pub fn link(sess: Option<&Session>, inputs: &mut [&mut Module], opts: &Options) for mut module in inputs.iter_mut().skip(1) { simple_passes::shift_ids(&mut module, bound); bound += module.header.as_ref().unwrap().bound - 1; - assert_eq!(version, module.header.as_ref().unwrap().version()); + let this_version = module.header.as_ref().unwrap().version(); + if version != this_version { + match sess { + Some(sess) => sess.fatal(&format!( + "cannot link two modules with different SPIR-V versions: v{}.{} and v{}.{}", + version.0, version.1, this_version.0, this_version.1 + )), + None => panic!("spir-v version mismatch: {:?} {:?}", version, this_version), + } + } } // merge the binaries