Skip to content

Commit 63b3168

Browse files
committed
llvm6: Don't clone LLVM modules on wasm
The comment for why cloning exists doesn't actually apply for wasm today and apparently cloning is causing subtle bugs in LLVM, so let's just avoid it altogether. More specifically after we emit the assembly for the wasm target we don't actually use the module again, so there's no need to keep both around. This seemed to be causing some scary verifier assertions in LLVM which seemed to be uncovered by presumably (?) buggy behavior. Let's just avoid it for now and make the wasm target slightly more lean in the process.
1 parent caedb36 commit 63b3168

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/librustc_trans/back/write.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,7 @@ unsafe fn codegen(cgcx: &CodegenContext,
733733
// We can't use the same module for asm and binary output, because that triggers
734734
// various errors like invalid IR or broken binaries, so we might have to clone the
735735
// module to produce the asm output
736-
let llmod = if config.emit_obj {
736+
let llmod = if config.emit_obj && !asm2wasm {
737737
llvm::LLVMCloneModule(llmod)
738738
} else {
739739
llmod
@@ -742,7 +742,7 @@ unsafe fn codegen(cgcx: &CodegenContext,
742742
write_output_file(diag_handler, tm, cpm, llmod, &path,
743743
llvm::FileType::AssemblyFile)
744744
})?;
745-
if config.emit_obj {
745+
if config.emit_obj && !asm2wasm {
746746
llvm::LLVMDisposeModule(llmod);
747747
}
748748
timeline.record("asm");

0 commit comments

Comments
 (0)