From a399326ca2ec6ec69c786fd6c6c8335388424952 Mon Sep 17 00:00:00 2001 From: varkor Date: Fri, 15 Dec 2017 19:25:05 +0000 Subject: [PATCH] Improve error messages on LLVM bitcode parsing failure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The LLVM error causing the parse failure is now printed, in the style of the other thin LTO error messages. This prevents a flood of assertion failure messages if the bitcode can’t be parsed. --- src/librustc_trans/back/lto.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/librustc_trans/back/lto.rs b/src/librustc_trans/back/lto.rs index 48c3fd638c36b..aa7754a7ab0ff 100644 --- a/src/librustc_trans/back/lto.rs +++ b/src/librustc_trans/back/lto.rs @@ -613,7 +613,10 @@ impl ThinModule { self.data().len(), self.shared.module_names[self.idx].as_ptr(), ); - assert!(!llmod.is_null()); + if llmod.is_null() { + let msg = format!("failed to parse bitcode for thin LTO module"); + return Err(write::llvm_err(&diag_handler, msg)); + } let mtrans = ModuleTranslation { source: ModuleSource::Translated(ModuleLlvm { llmod,