diff options
author | Jacob Gravelle <jgravelle@google.com> | 2018-02-14 10:30:16 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-14 10:30:16 -0800 |
commit | ee78bc9bccb02bb2b63fbb881fd2893a5fca0044 (patch) | |
tree | f757a2b8d0baed7d73628905038894217ab4bdee /scripts/test | |
parent | e97d485bb1f1818e2c2118d28507d49cb61ea57b (diff) | |
download | binaryen-ee78bc9bccb02bb2b63fbb881fd2893a5fca0044.tar.gz binaryen-ee78bc9bccb02bb2b63fbb881fd2893a5fca0044.tar.bz2 binaryen-ee78bc9bccb02bb2b63fbb881fd2893a5fca0044.zip |
Fold wasm-link-metadata into wasm-emscripten-finalize (#1408)
* wasm-link-metadata: Use `__data_end` symbol.
* Add --global-base param to emscripten-wasm-finalize to compute staticBump properly
* Let ModuleWriter write to a provided Output object
Diffstat (limited to 'scripts/test')
-rwxr-xr-x | scripts/test/generate_lld_tests.py | 76 | ||||
-rwxr-xr-x | scripts/test/lld.py | 32 | ||||
-rw-r--r-- | scripts/test/shared.py | 1 |
3 files changed, 39 insertions, 70 deletions
diff --git a/scripts/test/generate_lld_tests.py b/scripts/test/generate_lld_tests.py index c959bd857..4f1718068 100755 --- a/scripts/test/generate_lld_tests.py +++ b/scripts/test/generate_lld_tests.py @@ -27,58 +27,54 @@ def files_with_extensions(path, extensions): yield file, ext -def generate_object_files(clang_bin): - print '\n[ building object files from C sources... ]\n' +def generate_wast_files(clang_bin, lld_bin, emscripten_root): + print '\n[ building wast files from C sources... ]\n' lld_path = os.path.join(shared.options.binaryen_test, 'lld') for src_file, ext in files_with_extensions(lld_path, ['.c', '.cpp']): print '..', src_file - obj_file = src_file.replace(ext, '.o') - - src_path = os.path.join(lld_path, src_file) - obj_path = os.path.join(lld_path, obj_file) - run_command([ - clang_bin, src_path, '-o', obj_path, - '--target=wasm32-unknown-unknown-wasm', - '-c', - '-nostdinc', - '-Xclang', '-nobuiltininc', - '-Xclang', '-nostdsysteminc', - '-Xclang', '-I/s/work/emscripten/system/include', - '-O1', - ]) + try: + obj_file = src_file.replace(ext, '.o') + src_path = os.path.join(lld_path, src_file) + obj_path = os.path.join(lld_path, obj_file) + run_command([ + clang_bin, src_path, '-o', obj_path, + '--target=wasm32-unknown-unknown-wasm', + '-c', + '-nostdinc', + '-Xclang', '-nobuiltininc', + '-Xclang', '-nostdsysteminc', + '-Xclang', '-I%s/system/include' % emscripten_root, + '-O1', + ]) -def generate_wast_files(lld_bin): - print '\n[ linking wasm files from object files... ]\n' - lld_path = os.path.join(shared.options.binaryen_test, 'lld') - for obj_file, ext in files_with_extensions(lld_path, ['.o']): - print '..', obj_file - wasm_file = obj_file.replace(ext, '.wasm') - wast_file = obj_file.replace(ext, '.wast') + wasm_file = src_file.replace(ext, '.wasm') + wast_file = src_file.replace(ext, '.wast') - obj_path = os.path.join(lld_path, obj_file) - wasm_path = os.path.join(lld_path, wasm_file) - wast_path = os.path.join(lld_path, wast_file) - run_command([ - lld_bin, '-flavor', 'wasm', - '-z', '-stack-size=1048576', - obj_path, '-o', wasm_path, - '--entry=main', - '--allow-undefined', - '--export', '__wasm_call_ctors', - ]) - try: + obj_path = os.path.join(lld_path, obj_file) + wasm_path = os.path.join(lld_path, wasm_file) + wast_path = os.path.join(lld_path, wast_file) + run_command([ + lld_bin, '-flavor', 'wasm', + '-z', '-stack-size=1048576', + obj_path, '-o', wasm_path, + '--entry=main', + '--allow-undefined', + '--export', '__wasm_call_ctors', + '--global-base=568', + ]) run_command(shared.WASM_DIS + [wasm_path, '-o', wast_path]) finally: - # Don't need the .wasm file, don't leave it around + # Don't need the .o or .wasm files, don't leave them around + shared.delete_from_orbit(obj_path) shared.delete_from_orbit(wasm_path) if __name__ == '__main__': - if len(sys.argv) != 3: - print 'Usage: generate_lld_tests.py [path/to/clang] [path/to/lld]' + if len(sys.argv) != 4: + print 'Usage: generate_lld_tests.py [path/to/clang] [path/to/lld] \ +[path/to/emscripten]' sys.exit(1) - generate_object_files(sys.argv[1]) - generate_wast_files(sys.argv[2]) + generate_wast_files(*sys.argv[1:]) diff --git a/scripts/test/lld.py b/scripts/test/lld.py index 85159ba3a..f6aa91e6f 100755 --- a/scripts/test/lld.py +++ b/scripts/test/lld.py @@ -18,36 +18,10 @@ import os from support import run_command from shared import ( fail, fail_with_error, files_with_pattern, options, - WASM_LINK_METADATA, WASM_EMSCRIPTEN_FINALIZE + WASM_EMSCRIPTEN_FINALIZE ) -def test_wasm_link_metadata(): - print '\n[ checking wasm-link-metadata testcases... ]\n' - - extension_arg_map = { - '.json': [], - '.jscall.json': ['--emscripten-reserved-function-pointers=3'], - } - - for obj_path in files_with_pattern(options.binaryen_test, 'lld', '*.o'): - print '..', obj_path - for ext, ext_args in extension_arg_map.items(): - expected_file = obj_path.replace('.o', ext) - if ext != '.json' and not os.path.exists(expected_file): - continue - - cmd = WASM_LINK_METADATA + [obj_path] + ext_args - actual = run_command(cmd) - - if not os.path.exists(expected_file): - print actual - fail_with_error('output ' + expected_file + ' does not exist') - expected = open(expected_file, 'rb').read() - if actual != expected: - fail(actual, expected) - - def test_wasm_emscripten_finalize(): print '\n[ checking wasm-emscripten-finalize testcases... ]\n' @@ -63,7 +37,8 @@ def test_wasm_emscripten_finalize(): if ext != '.out' and not os.path.exists(expected_file): continue - cmd = WASM_EMSCRIPTEN_FINALIZE + [wast_path, '-S'] + ext_args + cmd = (WASM_EMSCRIPTEN_FINALIZE + + [wast_path, '-S', '--global-base=568'] + ext_args) actual = run_command(cmd) if not os.path.exists(expected_file): @@ -75,5 +50,4 @@ def test_wasm_emscripten_finalize(): if __name__ == '__main__': - test_wasm_link_metadata() test_wasm_emscripten_finalize() diff --git a/scripts/test/shared.py b/scripts/test/shared.py index 863e97ec0..b48202e98 100644 --- a/scripts/test/shared.py +++ b/scripts/test/shared.py @@ -170,7 +170,6 @@ WASM_MERGE = [os.path.join(options.binaryen_bin, 'wasm-merge')] S2WASM = [os.path.join(options.binaryen_bin, 's2wasm')] WASM_REDUCE = [os.path.join(options.binaryen_bin, 'wasm-reduce')] WASM_METADCE = [os.path.join(options.binaryen_bin, 'wasm-metadce')] -WASM_LINK_METADATA = [os.path.join(options.binaryen_bin, 'wasm-link-metadata')] WASM_EMSCRIPTEN_FINALIZE = [os.path.join(options.binaryen_bin, 'wasm-emscripten-finalize')] |