Codebase list emscripten / c321a26
unfuzz patches Jonas Smedegaard 3 years ago
8 changed file(s) with 57 addition(s) and 57 deletion(s). Raw diff Collapse all Expand all
3535 });
3636 --- a/tools/building.py
3737 +++ b/tools/building.py
38 @@ -1006,7 +1006,7 @@
38 @@ -1003,7 +1003,7 @@
3939
4040 args = ['--compilation_level', 'ADVANCED_OPTIMIZATIONS' if advanced else 'SIMPLE_OPTIMIZATIONS']
4141 # Keep in sync with ecmaVersion in tools/acorn-optimizer.js
00 --- a/tests/runner.py
11 +++ b/tests/runner.py
2 @@ -98,6 +98,8 @@
2 @@ -97,6 +97,8 @@
33
44 EMTEST_SKIP_SLOW = os.getenv('EMTEST_SKIP_SLOW')
55
88 EMTEST_LACKS_NATIVE_CLANG = os.getenv('EMTEST_LACKS_NATIVE_CLANG')
99
1010 EMTEST_VERBOSE = int(os.getenv('EMTEST_VERBOSE', '0')) or shared.DEBUG
11 @@ -171,6 +173,17 @@
11 @@ -170,6 +172,17 @@
1212 return lambda f: f
1313
1414
3232 from tools.shared import EMCC, EMXX, EMAR, EMRANLIB, PYTHON, FILE_PACKAGER, WINDOWS, EM_BUILD_VERBOSE
3333 from tools.shared import CLANG_CC, CLANG_CXX, LLVM_AR, LLVM_DWARFDUMP
3434 from runner import RunnerCore, path_from_root, is_slow_test, ensure_dir, disabled, make_executable
35 -from runner import env_modify, no_mac, no_windows, requires_native_clang, chdir, with_env_modify
35 -from runner import env_modify, no_mac, no_windows, requires_native_clang, with_env_modify
3636 -from runner import create_test_file, parameterized, NON_ZERO, node_pthreads
37 +from runner import env_modify, no_mac, no_windows, requires_closure_compiler, requires_native_clang, chdir, with_env_modify
37 +from runner import env_modify, no_mac, no_windows, requires_closure_compiler, requires_native_clang, with_env_modify
3838 +from runner import create_test_file, parameterized, NON_ZERO, EMTEST_LACKS_CLOSURE_COMPILER, node_pthreads
3939 from tools import shared, building, utils
4040 import jsrun
4141 import clang_native
42 @@ -1062,7 +1062,7 @@
42 @@ -1085,7 +1085,7 @@
4343 create_test_file('in.txt', 'abcdef\nghijkl')
4444 run_test()
4545 building.emcc(path_from_root('tests', 'module', 'test_stdin.c'),
4848 run_test()
4949
5050 def test_ungetc_fscanf(self):
51 @@ -2056,7 +2056,8 @@
51 @@ -2079,7 +2079,8 @@
5252 test_cases += test_cases_without_utf8
5353 test_cases.extend([(args[:] + ['-s', 'DYNAMIC_EXECUTION=0']) for args in test_cases])
5454 # closure compiler doesn't work with DYNAMIC_EXECUTION=0
5858 for args in test_cases:
5959 print(args)
6060 self.clear()
61 @@ -2364,6 +2365,7 @@
61 @@ -2398,6 +2399,7 @@
6262 print(output)
6363 self.assertLess(output.count('Cannot enlarge memory arrays'), 5)
6464
6666 def test_module_exports_with_closure(self):
6767 # This test checks that module.export is retained when JavaScript is minified by compiling with --closure 1
6868 # This is important as if module.export is not present the Module object will not be visible to node.js
69 @@ -4671,10 +4673,11 @@
69 @@ -4705,10 +4707,11 @@
7070 test(['-s', 'ASSERTIONS=0'], 120000) # we don't care about code size with assertions
7171 test(['-O1'], 91000)
7272 test(['-O2'], 46000)
8282
8383 def test_no_browser(self):
8484 BROWSER_INIT = 'var Browser'
85 @@ -5999,7 +6002,7 @@
85 @@ -6033,7 +6036,7 @@
8686 '--post-js', path_from_root('tests', 'return64bit', 'testbindend.js'),
8787 '-s', 'DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=[$dynCall]',
8888 '-s', 'EXPORTED_FUNCTIONS=[_test_return64]', '-o', 'test.js', '-O2',
9191
9292 # Simple test program to load the test.js binding library and call the binding to the
9393 # C function returning the 64 bit long.
94 @@ -6588,7 +6591,7 @@
94 @@ -6622,7 +6625,7 @@
9595
9696 # test debug info and debuggability of JS output
9797 def test_binaryen_debug(self):
100100 (['-O0'], False, False, False, True, False),
101101 (['-O0', '-g1'], False, False, False, True, False),
102102 (['-O0', '-g2'], True, False, False, True, False), # in -g2+, we emit -g to asm2wasm so function names are saved
103 @@ -6598,9 +6601,11 @@
103 @@ -6632,9 +6635,11 @@
104104 (['-O2'], False, False, True, False, False),
105105 (['-O2', '-g1'], False, False, True, True, False),
106106 (['-O2', '-g'], True, True, False, True, False),
115115 print(args, expect_dash_g, expect_emit_text)
116116 try_delete('a.out.wat')
117117 cmd = [EMCC, path_from_root('tests', 'hello_world.cpp')] + args
118 @@ -7177,7 +7182,7 @@
118 @@ -7212,7 +7217,7 @@
119119 cmd += ['--memory-init-file', '1']
120120 if debug_enabled:
121121 cmd += ['-g']
124124 cmd += ['--closure', '1']
125125 if not wasm_enabled:
126126 cmd += ['-s', 'WASM=0']
127 @@ -7283,6 +7288,7 @@
127 @@ -7318,6 +7323,7 @@
128128 assert_aliases_match('MAXIMUM_MEMORY', 'WASM_MEM_MAX', '16777216', ['-s', 'ALLOW_MEMORY_GROWTH'])
129129 assert_aliases_match('MAXIMUM_MEMORY', 'BINARYEN_MEM_MAX', '16777216', ['-s', 'ALLOW_MEMORY_GROWTH'])
130130
132132 def test_IGNORE_CLOSURE_COMPILER_ERRORS(self):
133133 create_test_file('pre.js', r'''
134134 // make closure compiler very very angry
135 @@ -7310,6 +7316,7 @@
136 proc = test(check=True, extra=['-s', 'IGNORE_CLOSURE_COMPILER_ERRORS=1'])
135 @@ -7345,6 +7351,7 @@
136 proc = test(check=True, extra=['-s', 'IGNORE_CLOSURE_COMPILER_ERRORS'])
137137 self.assertNotContained(WARNING, proc.stderr)
138138
139139 + @requires_closure_compiler
140140 def test_closure_full_js_library(self):
141141 # test for closure errors in the entire JS library
142142 # We must ignore various types of errors that are expected in this situation, as we
143 @@ -7321,6 +7328,7 @@
144 self.run_process([EMCC, path_from_root('tests', 'hello_world.c'), '-O1', '--closure', '1', '-g1', '-s', 'INCLUDE_FULL_LIBRARY=1', '-s', 'USE_WEBGPU=1', '-s', 'ERROR_ON_UNDEFINED_SYMBOLS=0'])
143 @@ -7356,6 +7363,7 @@
144 self.run_process([EMCC, path_from_root('tests', 'hello_world.c'), '-O1', '--closure', '1', '-g1', '-s', 'INCLUDE_FULL_LIBRARY', '-s', 'USE_WEBGPU', '-s', 'ERROR_ON_UNDEFINED_SYMBOLS=0'])
145145
146146 # Tests --closure-args command line flag
147147 + @requires_closure_compiler
148148 def test_closure_externs(self):
149149 self.run_process([EMCC, path_from_root('tests', 'hello_world.c'), '--closure', '1', '--pre-js', path_from_root('tests', 'test_closure_externs_pre_js.js'), '--closure-args', '--externs "' + path_from_root('tests', 'test_closure_externs.js') + '"'])
150150
151 @@ -7469,11 +7477,12 @@
151 @@ -7504,11 +7512,12 @@
152152 self.assertIdentical(normal, tiny)
153153 self.assertIdentical(normal, huge)
154154
163163 })
164164 def test_EM_ASM_ES6(self, args):
165165 create_test_file('src.cpp', r'''
166 @@ -8129,9 +8138,10 @@
166 @@ -8164,9 +8173,10 @@
167167
168168 self.run_process([PYTHON, path_from_root('tests', 'gen_many_js_functions.py'), 'library_long.js', 'main_long.c'])
169169 for wasm in [[], ['-s', 'WASM=0']]:
177177 args = [EMCC, '-O3', '--js-library', 'library_long.js', 'main_long.c', '-o', 'a.html'] + wasm + closure
178178 print(' '.join(args))
179179 self.run_process(args)
180 @@ -8178,15 +8188,16 @@
180 @@ -8213,15 +8223,16 @@
181181 ret = self.run_process(config.NODE_JS + ['a.out.js'], stdout=PIPE).stdout
182182 self.assertContained('hello, world!\n', ret)
183183
197197 })
198198 def test_emscripten_license(self, expect_license, args):
199199 # fastcomp does not support the new license flag
200 @@ -8221,7 +8232,10 @@
200 @@ -8256,7 +8267,10 @@
201201 num_times_export_is_referenced = output.count('thisIsAFunctionExportedFromAsmJsOrWasmWithVeryLongFunction')
202202 self.assertEqual(num_times_export_is_referenced, 1)
203203
209209 for opt in [['-O2'], ['-O3'], ['-Os']]:
210210 test(['-s', 'WASM=0'], closure, opt)
211211 test(['-s', 'WASM_ASYNC_COMPILATION=0'], closure, opt)
212 @@ -8263,7 +8277,7 @@
213 '-s', 'NO_FILESYSTEM=1',
212 @@ -8298,7 +8312,7 @@
213 '-s', 'NO_FILESYSTEM',
214214 '--output_eol', 'linux',
215215 '-Oz',
216216 - '--closure', '1',
218218 '-DNDEBUG',
219219 '-ffast-math']
220220
221 @@ -8752,6 +8766,7 @@
221 @@ -8787,6 +8801,7 @@
222222 # otherwise in such a trivial program).
223223 self.assertLess(no, 0.95 * yes)
224224
226226 def test_INCOMING_MODULE_JS_API(self):
227227 def test(args):
228228 self.run_process([EMCC, path_from_root('tests', 'hello_world.c'), '-O3', '--closure', '1'] + args)
229 @@ -9075,11 +9090,14 @@
229 @@ -9110,11 +9125,14 @@
230230
231231 def test_warning_flags(self):
232232 self.run_process([EMCC, '-c', '-o', 'hello.o', path_from_root('tests', 'hello_world.c')])
244244
245245 # -w to suppress warnings
246246 stderr = self.run_process(cmd + ['-w'], stderr=PIPE).stderr
247 @@ -9090,12 +9108,14 @@
247 @@ -9125,12 +9143,14 @@
248248 self.assertNotContained('warning', stderr)
249249
250250 # with -Werror should fail
262262 + self.assertContained('emcc: warning: disabling closure because debug info was requested [-Wemcc]', stderr)
263263
264264 # check that `-Werror=foo` also enales foo
265 stderr = self.expect_fail(cmd + ['-Werror=legacy-settings', '-s', 'TOTAL_MEMORY=1'])
266 @@ -9312,6 +9332,7 @@
265 stderr = self.expect_fail(cmd + ['-Werror=legacy-settings', '-s', 'TOTAL_MEMORY'])
266 @@ -9347,6 +9367,7 @@
267267 self.assertContained('INITIAL_MEMORY must be less than 2GB due to current spec limitations', stderr)
268268
269269 # Verifies that warning messages that Closure outputs are recorded to console
271271 def test_closure_warnings(self):
272272 proc = self.run_process([EMCC, path_from_root('tests', 'test_closure_warning.c'), '-O3', '--closure', '1', '-s', 'CLOSURE_WARNINGS=quiet'], stderr=PIPE)
273273 self.assertNotContained('WARNING', proc.stderr)
274 @@ -9725,6 +9746,7 @@
274 @@ -9756,6 +9777,7 @@
275275 self.assertContained('hello, world!', self.run_js('a.out.js'))
276276
277277 # Test that Closure prints out clear readable error messages when there are errors.
279279 def test_closure_errors(self):
280280 err = self.expect_fail([EMCC, path_from_root('tests', 'closure_error.c'), '-O2', '--closure', '1'])
281281 lines = err.split('\n')
282 @@ -9743,16 +9765,19 @@
282 @@ -9774,16 +9796,19 @@
283283 self.assertNotEqual(idx1, idx2)
284284
285285 # Make sure that --cpuprofiler compiles with --closure 1
298298 + @requires_closure_compiler
299299 def test_threadprofiler_closure(self):
300300 # TODO: Enable '-s', 'CLOSURE_WARNINGS=error' in the following, but that has currently regressed.
301 self.run_process([EMCC, path_from_root('tests', 'hello_world.c'), '-O2', '-s', 'USE_PTHREADS=1', '--closure', '1', '--threadprofiler'])
301 self.run_process([EMCC, path_from_root('tests', 'hello_world.c'), '-O2', '-s', 'USE_PTHREADS', '--closure', '1', '--threadprofiler'])
302302 --- a/tests/test_core.py
303303 +++ b/tests/test_core.py
304304 @@ -22,10 +22,10 @@
314314 import clang_native
315315
316316 # decorators for limiting which modes a test can run in
317 @@ -260,7 +260,7 @@
317 @@ -261,7 +261,7 @@
318318
319319 # Use closure in some tests for some additional coverage
320320 def maybe_closure(self):
323323 self.emcc_args += ['--closure', '1']
324324 return True
325325 return False
326 @@ -1781,7 +1781,7 @@
326 @@ -1779,7 +1779,7 @@
327327 # needs to flush stdio streams
328 self.set_setting('EXIT_RUNTIME', 1)
328 self.set_setting('EXIT_RUNTIME')
329329
330330 - if self.run_name == 'asm2':
331331 + if self.run_name == 'asm2' and not EMTEST_LACKS_CLOSURE_COMPILER:
332332 self.emcc_args += ['--closure', '1'] # Use closure here for some additional coverage
333333 self.do_runf(path_from_root('tests', 'emscripten_get_now.cpp'), 'Timer resolution is good')
334334
335 @@ -4723,7 +4723,7 @@
335 @@ -4729,7 +4729,7 @@
336336 self.banned_js_engines = [config.SPIDERMONKEY_ENGINE] # closure can generate variables called 'gc', which pick up js shell stuff
337337 if self.maybe_closure(): # Use closure here, to test we don't break FS stuff
338338 self.emcc_args = [x for x in self.emcc_args if x != '-g'] # ensure we test --closure 1 --memory-init-file 1 (-g would disable closure)
341341 print('closure 2')
342342 self.emcc_args += ['--closure', '2'] # Use closure 2 here for some additional coverage
343343 return self.skipTest('TODO: currently skipped because CI runs out of memory running Closure in this test!')
344 @@ -5082,7 +5082,7 @@
344 @@ -5091,7 +5091,7 @@
345345 self.emcc_args += ['-lnodefs.js']
346 self.set_setting('SYSCALL_DEBUG', 1)
346 self.set_setting('SYSCALL_DEBUG')
347347 self.do_runf(path_from_root('tests', 'fs', 'test_nodefs_rw.c'), 'success')
348348 - if '-g' not in self.emcc_args:
349349 + if '-g' not in self.emcc_args and not EMTEST_LACKS_CLOSURE_COMPILER:
350350 print('closure')
351351 self.emcc_args += ['--closure', '1']
352352 self.do_runf(path_from_root('tests', 'fs', 'test_nodefs_rw.c'), 'success')
353 @@ -5687,7 +5687,7 @@
353 @@ -5688,7 +5688,7 @@
354354 def test_cubescript(self):
355355 # uses register keyword
356356 self.emcc_args += ['-std=c++03', '-Wno-dynamic-class-memaccess']
359359 self.emcc_args += ['--closure', '1'] # Use closure here for some additional coverage
360360
361361 self.emcc_args = [x for x in self.emcc_args if x != '-g'] # remove -g, so we have one test without it by default
362 @@ -6219,7 +6219,7 @@
362 @@ -6220,7 +6220,7 @@
363363 self.set_setting('EXPORTED_FUNCTIONS', ['_get_int', '_get_float', '_get_bool', '_get_string', '_print_int', '_print_float', '_print_bool', '_print_string', '_multi', '_pointer', '_call_ccall_again', '_malloc'])
364364 self.do_run_in_out_file_test('tests', 'core', 'test_ccall.cpp')
365365
368368 print('with closure')
369369 self.emcc_args += ['--closure', '1']
370370 self.do_run_in_out_file_test('tests', 'core', 'test_ccall.cpp')
371 @@ -6833,7 +6833,7 @@
371 @@ -6827,7 +6827,7 @@
372372 })
373373 @sync
374374 def test_webidl(self, mode, allow_memory_growth):
376376 + if self.run_name == 'asm2' and not EMTEST_LACKS_CLOSURE_COMPILER:
377377 self.emcc_args += ['--closure', '1', '-g1'] # extra testing
378378 # avoid closure minified names competing with our test code in the global name space
379 self.set_setting('MODULARIZE', 1)
380 @@ -7117,6 +7117,7 @@
379 self.set_setting('MODULARIZE')
380 @@ -7111,6 +7111,7 @@
381381 self.assertLessEqual(start_wat_addr, dwarf_addr)
382382 self.assertLessEqual(dwarf_addr, end_wat_addr)
383383
385385 def test_modularize_closure_pre(self):
386386 # test that the combination of modularize + closure + pre-js works. in that mode,
387387 # closure should not minify the Module object in a way that the pre-js cannot use it.
388 @@ -7143,10 +7144,11 @@
388 @@ -7137,10 +7138,11 @@
389389 self.emcc_args.append('-g')
390390 self.emcc_args += ['-DRUN_FROM_JS_SHELL']
391391 self.do_run_in_out_file_test('tests', 'emscripten_log', 'emscripten_log.cpp')
401401
402402 def test_float_literals(self):
403403 self.do_run_in_out_file_test('tests', 'test_float_literals.cpp')
404 @@ -7996,6 +7998,7 @@
404 @@ -8001,6 +8003,7 @@
405405
406406 @no_safe_heap('asan does not work with SAFE_HEAP')
407407 @no_wasm2js('TODO: ASAN in wasm2js')
408408 + @requires_closure_compiler
409409 def test_asan_modularized_with_closure(self):
410 self.emcc_args.append('-sMODULARIZE=1')
411 self.emcc_args.append('-sEXPORT_NAME="createModule"')
410 self.emcc_args.append('-fsanitize=address')
411 self.set_setting('MODULARIZE')
00 --- a/tests/test_other.py
11 +++ b/tests/test_other.py
2 @@ -7104,7 +7104,7 @@
2 @@ -7138,7 +7138,7 @@
33 def test_error_on_missing_libraries(self):
44 # -llsomenonexistingfile is an error by default
55 err = self.expect_fail([EMCC, path_from_root('tests', 'hello_world.cpp'), '-lsomenonexistingfile'])
88
99 # Tests that if user accidentally attempts to link native object code, we show an error
1010 def test_native_link_error_message(self):
11 @@ -7122,7 +7122,7 @@
11 @@ -7156,7 +7156,7 @@
1212 }
1313 ''')
1414 err = self.expect_fail([EMCC, 'src.cpp', '-s', 'TOTAL_STACK=1KB', '-s', 'INITIAL_MEMORY=64KB'])
1717
1818 def test_o_level_clamp(self):
1919 for level in [3, 4, 20]:
20 @@ -9055,10 +9055,10 @@
20 @@ -9090,10 +9090,10 @@
2121
2222 def test_linker_flags_pass_through(self):
2323 err = self.expect_fail([EMCC, path_from_root('tests', 'hello_world.cpp'), '-Wl,--waka'])
3030
3131 def test_linker_flags_unused(self):
3232 err = self.run_process([EMCC, path_from_root('tests', 'hello_world.cpp'), '-c', '-lbar'], stderr=PIPE).stderr
33 @@ -9324,7 +9324,7 @@
33 @@ -9359,7 +9359,7 @@
3434 def test_lld_report_undefined(self):
3535 create_test_file('main.c', 'void foo(); int main() { foo(); return 0; }')
3636 stderr = self.expect_fail([EMCC, '-s', 'LLD_REPORT_UNDEFINED', 'main.c'])
44 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
55 --- a/tools/shared.py
66 +++ b/tools/shared.py
7 @@ -998,10 +998,10 @@
7 @@ -994,10 +994,10 @@
88 LLVM_OBJCOPY = os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-objcopy')))
99 WASM_LD = os.path.expanduser(build_llvm_tool_path(exe_suffix('wasm-ld')))
1010
44 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
55 --- a/tests/runner.py
66 +++ b/tests/runner.py
7 @@ -575,14 +575,12 @@
7 @@ -559,14 +559,12 @@
88 return args
99
1010 def verify_es5(self, filename):
44 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
55 --- a/emcc.py
66 +++ b/emcc.py
7 @@ -3054,36 +3054,13 @@
7 @@ -3040,36 +3040,13 @@
88 opts = []
99 # -g1 and greater retain whitespace and comments in source
1010 if shared.Settings.DEBUG_LEVEL == 0:
99 This patch header follows DEP-3: http://dep.debian.net/deps/dep3/
1010 --- a/tools/building.py
1111 +++ b/tools/building.py
12 @@ -904,8 +904,8 @@
12 @@ -901,8 +901,8 @@
1313 if config.CLOSURE_COMPILER:
1414 return shared.CLOSURE_COMPILER
1515
2020 if not WINDOWS:
2121 # Work around an issue that Closure compiler can take up a lot of memory and crash in an error
2222 # "FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap
23 @@ -954,11 +954,12 @@
23 @@ -951,11 +951,12 @@
2424
2525 closure_cmd = get_closure_compiler()
2626
2222 + binaryen_root = os.path.dirname(os.path.dirname(which('binaryen') or '/usr/bin/binaryen'))
2323 + config_file = config_file.replace('\'{{{ BINARYEN_ROOT }}}\'', repr(binaryen_root))
2424 +
25 node = which('nodejs') or which('node') or 'node'
25 node = which('node') or which('nodejs') or 'node'
2626 config_file = config_file.replace('\'{{{ NODE }}}\'', repr(node))
2727