Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/wasm/wasm-binary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ void WasmBinaryWriter::writeStart() {
}

void WasmBinaryWriter::writeMemories() {
if (wasm->memories.empty()) {
if (importInfo->getNumDefinedMemories() == 0) {
return;
}
BYN_TRACE("== writeMemories\n");
Expand Down
Binary file added test/unit/input/only-imported-memory.wasm
Binary file not shown.
8 changes: 8 additions & 0 deletions test/unit/test_only_imported_memory.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from . import utils


class OnlyImportedMemoryTest(utils.BinaryenTestCase):
def test_only_imported_memory(self):
# We should not create a memories section for a file with only an
# imported memory: such a module has no declared memories.
self.roundtrip('only-imported-memory.wasm', debug=False)
6 changes: 4 additions & 2 deletions test/unit/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ def input_path(self, filename):
return os.path.join(shared.options.binaryen_test, 'unit', 'input',
filename)

def roundtrip(self, filename, opts=[]):
def roundtrip(self, filename, opts=[], debug=True):
if debug:
opts = opts + ['-g']
path = self.input_path(filename)
p = shared.run_process(shared.WASM_OPT + ['-g', '-o', 'a.wasm', path] +
p = shared.run_process(shared.WASM_OPT + ['-o', 'a.wasm', path] +
opts)
self.assertEqual(p.returncode, 0)
with open(path, 'rb') as f:
Expand Down