]> git.lizzy.rs Git - rust.git/commitdiff
Improve error messages on LLVM bitcode parsing failure
authorvarkor <github@varkor.com>
Fri, 15 Dec 2017 19:25:05 +0000 (19:25 +0000)
committervarkor <github@varkor.com>
Fri, 15 Dec 2017 19:25:05 +0000 (19:25 +0000)
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

index 48c3fd638c36ba52711b9b2c801bb5360a76fb23..aa7754a7ab0ff5d621bc573cbebcc17373e6f3de 100644 (file)
@@ -613,7 +613,10 @@ unsafe fn optimize(&mut self, cgcx: &CodegenContext, timeline: &mut Timeline)
             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,