diff --git a/emcc.py b/emcc.py index 5bc913fa1875..af5d78884d30 100755 --- a/emcc.py +++ b/emcc.py @@ -80,7 +80,6 @@ LIB_PREFIXES = ('', 'lib') - DEFERRED_RESPONSE_FILES = ('EMTERPRETIFY_BLACKLIST', 'EMTERPRETIFY_WHITELIST', 'EMTERPRETIFY_SYNCLIST') # Mapping of emcc opt levels to llvm opt levels. We use llvm opt level 3 in emcc @@ -1733,11 +1732,11 @@ def compile_source_file(i, input_file): # we have multiple files: Link them logger.debug('link: ' + str(linker_inputs) + specified_target) shared.Building.link_to_object(linker_inputs, specified_target) - logger.debug('stopping at bitcode') + logger.debug('stopping at object file') if shared.Settings.SIDE_MODULE: - exit_with_error('SIDE_MODULE must only be used when compiling to an executable shared library, and not when emitting LLVM bitcode. That is, you should be emitting a .wasm file (for wasm) or a .js file (for asm.js). Note that when compiling to a typical native suffix for a shared library (.so, .dylib, .dll; which many build systems do) then Emscripten emits an LLVM bitcode file, which you should then compile to .wasm or .js with SIDE_MODULE.') + exit_with_error('SIDE_MODULE must only be used when compiling to an executable shared library, and not when emitting an object file. That is, you should be emitting a .wasm file (for wasm) or a .js file (for asm.js). Note that when compiling to a typical native suffix for a shared library (.so, .dylib, .dll; which many build systems do) then Emscripten emits an object file, which you should then compile to .wasm or .js with SIDE_MODULE.') if final_suffix.lower() in ('.so', '.dylib', '.dll'): - logger.warning('When Emscripten compiles to a typical native suffix for shared libraries (.so, .dylib, .dll) then it emits an LLVM bitcode file. You should then compile that to an emscripten SIDE_MODULE (using that flag) with suffix .wasm (for wasm) or .js (for asm.js). (You may also want to adapt your build system to emit the more standard suffix for a file with LLVM bitcode, \'.bc\', which would avoid this warning.)') + logger.warning('When Emscripten compiles to a typical native suffix for shared libraries (.so, .dylib, .dll) then it emits an object file. You should then compile that to an emscripten SIDE_MODULE (using that flag) with suffix .wasm (for wasm) or .js (for asm.js). (You may also want to adapt your build system to emit the more standard suffix for a an object file, \'.bc\' or \'.o\', which would avoid this warning.)') return 0 # exit block 'process inputs' @@ -2715,6 +2714,7 @@ def do_binaryen(target, asm_target, options, memfile, wasm_binary_target, if not DEBUG: os.unlink(asm_target) # we don't need the asm.js, it can just confuse + # after generating the wasm, do some final operations if shared.Settings.EMIT_EMSCRIPTEN_METADATA: wso = shared.WebAssembly.add_emscripten_metadata(final, wasm_binary_target) shutil.move(wso, wasm_binary_target) diff --git a/tests/test_other.py b/tests/test_other.py index 87942ce0b4b6..517313d4acef 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -3827,8 +3827,9 @@ def test_warn_dylibs(self): shared_suffixes = ['.so', '.dylib', '.dll'] for suffix in ['.o', '.a', '.bc', '.so', '.lib', '.dylib', '.js', '.html']: - err = run_process([PYTHON, EMCC, path_from_root('tests', 'hello_world.c'), '-o', 'out' + suffix], stdout=PIPE, stderr=PIPE).stderr - warning = 'When Emscripten compiles to a typical native suffix for shared libraries (.so, .dylib, .dll) then it emits an LLVM bitcode file. You should then compile that to an emscripten SIDE_MODULE (using that flag) with suffix .wasm (for wasm) or .js (for asm.js).' + print(suffix) + err = run_process([PYTHON, EMCC, path_from_root('tests', 'hello_world.c'), '-o', 'out' + suffix], stderr=PIPE).stderr + warning = 'When Emscripten compiles to a typical native suffix for shared libraries (.so, .dylib, .dll) then it emits an object file. You should then compile that to an emscripten SIDE_MODULE (using that flag) with suffix .wasm (for wasm) or .js (for asm.js).' if suffix in shared_suffixes: self.assertContained(warning, err) else: @@ -3840,9 +3841,9 @@ def test_side_module_without_proper_target(self): # otherwise, we are just linking bitcode, and should show an error for wasm in [0, 1]: print(wasm) - process = run_process([PYTHON, EMCC, path_from_root('tests', 'hello_world.cpp'), '-s', 'SIDE_MODULE=1', '-o', 'a.so', '-s', 'WASM=%d' % wasm], stdout=PIPE, stderr=PIPE, check=False) - self.assertContained('SIDE_MODULE must only be used when compiling to an executable shared library, and not when emitting LLVM bitcode', process.stderr) - assert process.returncode is not 0 + process = run_process([PYTHON, EMCC, path_from_root('tests', 'hello_world.cpp'), '-s', 'SIDE_MODULE=1', '-o', 'a.so', '-s', 'WASM=%d' % wasm], stderr=PIPE, check=False) + self.assertContained('SIDE_MODULE must only be used when compiling to an executable shared library, and not when emitting an object file', process.stderr) + self.assertNotEqual(process.returncode, 0) @no_wasm_backend() def test_simplify_ifs(self): @@ -8093,24 +8094,22 @@ def test_export_aliasee(self): self.assertContained('success', ret) def test_sysconf_phys_pages(self): - for args, expected in [ - ([], 1024), - (['-s', 'TOTAL_MEMORY=32MB'], 2048), - (['-s', 'TOTAL_MEMORY=32MB', '-s', 'ALLOW_MEMORY_GROWTH=1'], (2 * 1024 * 1024 * 1024 - 65536) // 16384), - (['-s', 'TOTAL_MEMORY=32MB', '-s', 'ALLOW_MEMORY_GROWTH=1', '-s', 'WASM=0'], (2 * 1024 * 1024 * 1024 - 16777216) // 16384), - (['-s', 'TOTAL_MEMORY=32MB', '-s', 'BINARYEN=1'], 2048), - (['-s', 'TOTAL_MEMORY=32MB', '-s', 'ALLOW_MEMORY_GROWTH=1', '-s', 'BINARYEN=1'], (2 * 1024 * 1024 * 1024 - 65536) // 16384), - (['-s', 'TOTAL_MEMORY=32MB', '-s', 'ALLOW_MEMORY_GROWTH=1', '-s', 'BINARYEN=1', '-s', 'WASM_MEM_MAX=128MB'], 2048 * 4) - ]: - if self.is_wasm_backend(): - if 'WASM=0' in args: - continue + def run(args, expected): + if self.is_wasm_backend() and 'WASM=0' in args: + return cmd = [PYTHON, EMCC, path_from_root('tests', 'unistd', 'sysconf_phys_pages.c')] + args print(str(cmd)) run_process(cmd) result = run_js('a.out.js').strip() - print(result) - assert result == str(expected) + ', errno: 0', expected + self.assertEqual(result, str(expected) + ', errno: 0') + + run([], 1024) + run(['-s', 'TOTAL_MEMORY=32MB'], 2048) + run(['-s', 'TOTAL_MEMORY=32MB', '-s', 'ALLOW_MEMORY_GROWTH=1'], (2 * 1024 * 1024 * 1024 - 65536) // 16384) + run(['-s', 'TOTAL_MEMORY=32MB', '-s', 'ALLOW_MEMORY_GROWTH=1', '-s', 'WASM=0'], (2 * 1024 * 1024 * 1024 - 16777216) // 16384) + run(['-s', 'TOTAL_MEMORY=32MB', '-s', 'BINARYEN=1'], 2048) + run(['-s', 'TOTAL_MEMORY=32MB', '-s', 'ALLOW_MEMORY_GROWTH=1', '-s', 'BINARYEN=1'], (2 * 1024 * 1024 * 1024 - 65536) // 16384) + run(['-s', 'TOTAL_MEMORY=32MB', '-s', 'ALLOW_MEMORY_GROWTH=1', '-s', 'BINARYEN=1', '-s', 'WASM_MEM_MAX=128MB'], 2048 * 4) def test_wasm_targets(self): for opts, potentially_expect_minified_exports_and_imports in (