about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2017-12-15 19:25:05 +0000
committervarkor <github@varkor.com>2017-12-15 19:25:05 +0000
commita399326ca2ec6ec69c786fd6c6c8335388424952 (patch)
tree08e9789eaea9429e5404b275991ae349bdc61290
parent50f6c3ece0ec738da48f8e77e6379a14bd02d1f4 (diff)
downloadrust-a399326ca2ec6ec69c786fd6c6c8335388424952.tar.gz
rust-a399326ca2ec6ec69c786fd6c6c8335388424952.zip
Improve error messages on LLVM bitcode parsing failure
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.
-rw-r--r--src/librustc_trans/back/lto.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/librustc_trans/back/lto.rs b/src/librustc_trans/back/lto.rs
index 48c3fd638c3..aa7754a7ab0 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,