feedback
diff --git a/emcc.py b/emcc.py index e0a7a45..3faf331 100755 --- a/emcc.py +++ b/emcc.py
@@ -3249,7 +3249,7 @@ # after generating the wasm, do some final operations if shared.Settings.SIDE_MODULE and not shared.Settings.WASM_BACKEND: - shared.WebAssembly.make_shared_library(wasm_binary_target, shared.Settings.RUNTIME_LINKED_LIBS) + shared.WebAssembly.add_dylink_section(wasm_binary_target, shared.Settings.RUNTIME_LINKED_LIBS) if not DEBUG: os.unlink(asm_target) # we don't need the asm.js, it can just confuse
diff --git a/tests/test_other.py b/tests/test_other.py index e36f943..cc1b69b 100644 --- a/tests/test_other.py +++ b/tests/test_other.py
@@ -33,7 +33,6 @@ from tools.shared import EMCC, EMXX, EMAR, EMRANLIB, PYTHON, FILE_PACKAGER, WINDOWS, LLVM_ROOT, EMCONFIG, EM_BUILD_VERBOSE from tools.shared import CLANG_CC, CLANG_CXX, LLVM_AR, LLVM_DWARFDUMP from tools.shared import NODE_JS, SPIDERMONKEY_ENGINE, JS_ENGINES, WASM_ENGINES, V8_ENGINE -from tools.shared import WebAssembly from runner import RunnerCore, path_from_root, no_wasm_backend, no_fastcomp, is_slow_test, ensure_dir from runner import needs_dlfcn, env_modify, no_windows, chdir, with_env_modify, create_test_file, parameterized from tools import jsrun, shared @@ -9655,48 +9654,17 @@ self.assertNotContained('invoke_ii', output) self.assertNotContained('invoke_v', output) - def test_add_emscripten_metadata(self): + def test_emscripten_metadata(self): + run_process([PYTHON, EMCC, path_from_root('tests', 'hello_world.c')]) + self.assertNotIn(b'emscripten_metadata', open('a.out.wasm', 'rb').read()) run_process([PYTHON, EMCC, path_from_root('tests', 'hello_world.c'), '-s', 'EMIT_EMSCRIPTEN_METADATA']) - wasm = open('a.out.wasm', 'rb').read() - # emscripten_metadata should be in the wasm data - offset = 8 # skip magic + header - while True: - section = wasm[offset:offset + 1] - # No emscripten_metadata section found before standard wasm sections') - self.assertEqual(section, b'\0') - offset += 1 - section_size, offset = WebAssembly.readLEB(wasm, offset) - end_offset = offset + section_size - name_len, offset = WebAssembly.readLEB(wasm, offset) - name = wasm[offset:offset + name_len] - if name == b'emscripten_metadata': - break - offset = end_offset - if offset >= len(wasm): - self.assertFalse('No emscripten_metadata section found') + self.assertIn(b'emscripten_metadata', open('a.out.wasm', 'rb').read()) # make sure wasm executes correctly ret = run_process(NODE_JS + ['a.out.js'], stdout=PIPE).stdout self.assertTextDataIdentical('hello, world!\n', ret) - def test_no_emscripten_metadata(self): - run_process([PYTHON, EMCC, path_from_root('tests', 'hello_world.c')]) - wasm = open('a.out.wasm', 'rb').read() - # emscripten_metadata should be in the wasm data - offset = 8 # skip magic + header - while offset < len(wasm): - section = wasm[offset:offset + 1] - offset += 1 - section_size, offset = WebAssembly.readLEB(wasm, offset) - end_offset = offset + section_size - # if this is a custom section - if section == b'\0': - name_len, offset = WebAssembly.readLEB(wasm, offset) - name = wasm[offset:offset + name_len] - self.assertNotEqual(name, b'emscripten_metadata') - offset = end_offset - @parameterized({ 'O2': (False, ['-O2']), # noqa 'O2_emit': (True, ['-O2', '-s', 'EMIT_EMSCRIPTEN_LICENSE']), # noqa
diff --git a/tools/shared.py b/tools/shared.py index e4a9c11..e7ce782 100644 --- a/tools/shared.py +++ b/tools/shared.py
@@ -3137,7 +3137,7 @@ f.write(orig[8:]) @staticmethod - def make_shared_library(wasm_file, needed_dynlibs): + def add_dylink_section(wasm_file, needed_dynlibs): # a wasm shared library has a special "dylink" section, see tools-conventions repo assert not Settings.WASM_BACKEND mem_align = Settings.MAX_GLOBAL_ALIGN