From 6430d4e69ab7701ec54cc74edce5673a28992a9a Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Sun, 5 Jul 2020 21:47:50 -0700 Subject: [PATCH] Remove asmjs validation This only ever worked in spidermonkey and I don't think we care about asmjs validation anymore anyway. Perhaps this should wait until after we remove fastcomp which is the only route to generating valid asm.js that we still maintain. --- cmake/Modules/Platform/Emscripten.cmake | 2 +- tests/cmake/target_html/CMakeLists.txt | 5 -- tests/runner.py | 12 --- tests/test_core.py | 9 --- tests/test_other.py | 4 +- tools/validate_asmjs.py | 103 ------------------------ 6 files changed, 2 insertions(+), 133 deletions(-) delete mode 100755 tools/validate_asmjs.py diff --git a/cmake/Modules/Platform/Emscripten.cmake b/cmake/Modules/Platform/Emscripten.cmake index 7362e7054f85f..08dcc80a6d15c 100644 --- a/cmake/Modules/Platform/Emscripten.cmake +++ b/cmake/Modules/Platform/Emscripten.cmake @@ -296,7 +296,7 @@ set(CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL "-Os" CACHE STRING "Emscripten-overridd set(CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO "-O2 -g" CACHE STRING "Emscripten-overridden CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO") function(em_validate_asmjs_after_build target) - add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E echo Validating build output for asm.js... COMMAND "python" ARGS "${EMSCRIPTEN_ROOT_PATH}/tools/validate_asmjs.py" "$") + message(WARNING "em_validate_asmjs_after_build no longer exists") endfunction() # A global counter to guarantee unique names for js library files. diff --git a/tests/cmake/target_html/CMakeLists.txt b/tests/cmake/target_html/CMakeLists.txt index a4a8c9ed191ba..3a9b6d9c08c15 100644 --- a/tests/cmake/target_html/CMakeLists.txt +++ b/tests/cmake/target_html/CMakeLists.txt @@ -88,8 +88,3 @@ endif() add_executable(hello_world_gles ${sourceFiles}) target_link_libraries(hello_world_gles cpp_lib) set_target_properties(hello_world_gles PROPERTIES LINK_FLAGS "${linkFlags}") - -# Validating asm.js requires SpiderMonkey JS VM - detect its presence via the SPIDERMONKEY environment variable. -if (DEFINED ENV{SPIDERMONKEY} AND CMAKE_BUILD_TYPE STREQUAL Release) - em_validate_asmjs_after_build(hello_world_gles) -endif() diff --git a/tests/runner.py b/tests/runner.py index d55f084b16db5..89b829754677d 100755 --- a/tests/runner.py +++ b/tests/runner.py @@ -747,16 +747,6 @@ def build(self, src, dirname, filename, main_file=None, # side memory init file, or an empty one in the js assert ('/* memory initializer */' not in src) or ('/* memory initializer */ allocate([]' in src) - def validate_asmjs(self, err): - # check for asm.js validation - if 'uccessfully compiled asm.js code' in err and 'asm.js link error' not in err: - print("[was asm.js'ified]", file=sys.stderr) - # check for an asm.js validation error, if we expect one - elif 'asm.js' in err and not self.is_wasm() and self.get_setting('ASM_JS') == 1: - self.fail("did NOT asm.js'ify: " + err) - err = '\n'.join([line for line in err.split('\n') if 'uccessfully compiled asm.js code' not in line]) - return err - def get_func(self, src, name): start = src.index('function ' + name + '(') t = start @@ -825,8 +815,6 @@ def run_js(self, filename, engine=None, args=[], output_nicerizer=None, assert_r out = open(stdout, 'r').read() err = open(stderr, 'r').read() - if engine == SPIDERMONKEY_ENGINE and self.get_setting('ASM_JS') == 1: - err = self.validate_asmjs(err) if output_nicerizer: ret = output_nicerizer(out, err) else: diff --git a/tests/test_core.py b/tests/test_core.py index a50704ee4ddc6..dda77bb8815a1 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -2907,11 +2907,6 @@ def test_dlfcn_qsort(self): self.do_run(src, 'Sort with main comparison: 5 4 3 2 1 *Sort with lib comparison: 1 2 3 4 5 *', output_nicerizer=lambda x, err: x.replace('\n', '*')) - if self.get_setting('ASM_JS') and SPIDERMONKEY_ENGINE and os.path.exists(SPIDERMONKEY_ENGINE[0]) and not self.is_wasm(): - out = self.run_js('liblib.so', engine=SPIDERMONKEY_ENGINE) - if 'asm' in out: - self.validate_asmjs(out) - @needs_dlfcn def test_dlfcn_data_and_fptr(self): # Failing under v8 since: https://chromium-review.googlesource.com/712595 @@ -3701,10 +3696,6 @@ def dylink_test(self, main, side, expected=None, header=None, main_emcc_args=[], self.build(side, self.get_dir(), base, js_outfile=(side_suffix == 'js')) if force_c: shutil.move(base + '.o.' + side_suffix, 'liblib.cpp.o.' + side_suffix) - if SPIDERMONKEY_ENGINE and os.path.exists(SPIDERMONKEY_ENGINE[0]) and not self.is_wasm(): - out = self.run_js('liblib.cpp.o.js', engine=SPIDERMONKEY_ENGINE) - if 'asm' in out: - self.validate_asmjs(out) shutil.move('liblib.cpp.o.' + side_suffix, 'liblib.so') # main settings diff --git a/tests/test_other.py b/tests/test_other.py index 72cc6cd47baea..767962c04e1ea 100644 --- a/tests/test_other.py +++ b/tests/test_other.py @@ -33,7 +33,7 @@ from tools.shared import try_delete from tools.shared import EMCC, EMXX, EMAR, EMRANLIB, PYTHON, FILE_PACKAGER, WINDOWS, LLVM_ROOT, 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 NODE_JS, JS_ENGINES, WASM_ENGINES, V8_ENGINE 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, requires_native_clang, chdir, with_env_modify, create_test_file, parameterized from runner import js_engines_modify, NON_ZERO @@ -535,8 +535,6 @@ def test_emcc_asm_v_wasm(self): print(' engine', engine) out = self.run_js('a.out.js', engine=engine) self.assertContained('hello, world!', out) - if not wasm and engine == SPIDERMONKEY_ENGINE: - self.validate_asmjs(out) if not wasm and not self.is_wasm_backend(): src = open('a.out.js').read() if opts == []: diff --git a/tools/validate_asmjs.py b/tools/validate_asmjs.py deleted file mode 100755 index 68ba6ac9c0baa..0000000000000 --- a/tools/validate_asmjs.py +++ /dev/null @@ -1,103 +0,0 @@ -#!/usr/bin/python -# Copyright 2013 The Emscripten Authors. All rights reserved. -# Emscripten is available under two separate licenses, the MIT license and the -# University of Illinois/NCSA Open Source License. Both these licenses can be -# found in the LICENSE file. - -# This is a helper script to validate a file for asm.js. - -# cmdline usage: 'python validate_asmjs.py filename.{html/js}' -# Prints a line starting with 'OK: ' on success, and returns process exit code 0. -# On failure, prints a line starting with 'FAIL: ', and returns a nonzero process exit code. - -# python usage: 'validate_asmjs("filename.{html/js}", muteOutput=True/False)' -# Returns True/False depending on whether the file was valid asm.js. - -# This script depends on the SpiderMonkey JS engine, which must be present in PATH in order for this script to function. - -from __future__ import print_function -import os -import re -import subprocess -import sys -import tempfile - -sys.path.insert(1, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) - -from tools import shared - - -# Given a .js file, returns True/False depending on if that file is valid asm.js -def validate_asmjs_jsfile(filename, muteOutput): - cmd = shared.SPIDERMONKEY_ENGINE + ['-c', filename] - if not shared.SPIDERMONKEY_ENGINE or cmd[0] == 'js-not-found' or len(cmd[0].strip()) == 0: - print('Could not find SpiderMonkey engine! Please set its location to SPIDERMONKEY_ENGINE in your ' + shared.hint_config_file_location() + ' configuration file!', file=sys.stderr) - return False - try: - process = shared.run_process(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) - except Exception as e: - print('Executing command ' + str(cmd) + ' failed due to an exception: ' + str(e) + '!', file=sys.stderr) - return False - stdout = process.stdout - stderr = process.stderr - if not muteOutput: - if len(stdout.strip()): - print(stdout.strip()) - if len(stderr.strip()): - # Pretty-print the output not to contain a spurious warning. - warning_re = re.compile(re.escape('warning: successfully compiled asm.js'), re.IGNORECASE) - stderr = warning_re.sub(' successfully compiled asm.js', stderr) - print(stderr.strip(), file=sys.stderr) - if 'successfully compiled asm.js' in stderr.lower(): - return True - else: - return False - - -# This tool takes as input a file built with Emscripten (either .html or .js) and validates it for asm.js. -# Returns True/False denoting whether the file was valid asm.js. In case of a .html file, all tags are searched, -# and the ones containing a "use asm" section are validated. -def validate_asmjs(filename, muteOutput): - if filename.endswith('.html'): - html = open(filename, 'r').read() - matches = re.findall(r'''<\w*script\w*.*?>(.*?)<\w*/script\w*>''', html, re.DOTALL | re.MULTILINE) - numAsmJsBlocks = 0 - for match in matches: - if '"use asm"' in match: - numAsmJsBlocks = numAsmJsBlocks + 1 - tmp_js = tempfile.mkstemp(suffix='.js') - os.write(tmp_js[0], match) - os.close(tmp_js[0]) - valid_asmjs = validate_asmjs_jsfile(tmp_js[1], muteOutput) - os.remove(tmp_js[1]) - if not valid_asmjs: - return False - if numAsmJsBlocks == 0: - # Test a .js file with the same basename - emcc convention - # is to generate files with same basename but different suffix. - js_file = filename.replace('.html', '.js') - if os.path.isfile(js_file): - return validate_asmjs(js_file, muteOutput) - if not muteOutput: - print('Error: the file does not contain any "use asm" modules.', file=sys.stderr) - return False - else: - return True - else: - return validate_asmjs_jsfile(filename, muteOutput) - - -def main(): - if len(sys.argv) < 2: - print('Usage: validate_asmjs ') - return 2 - if validate_asmjs(sys.argv[1], muteOutput=False): - print("OK: File '" + sys.argv[1] + "' validates as asm.js") - return 0 - else: - print("FAIL: File '" + sys.argv[1] + "' is not valid asm.js") - return 1 - - -if __name__ == '__main__': - sys.exit(main())