summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2022-06-28 21:11:31 -0700
committerGitHub <noreply@github.com>2022-06-28 21:11:31 -0700
commit9dbe45780d8c78dbb49c208fe4505cd1624a98ac (patch)
tree041feff94f8df88b1798b0ee8dd2e3d282a98cfd /scripts
parent7b7e2c56b7df43c7c6d99ef44dc4fff3b2e142bc (diff)
downloadbinaryen-9dbe45780d8c78dbb49c208fe4505cd1624a98ac.tar.gz
binaryen-9dbe45780d8c78dbb49c208fe4505cd1624a98ac.tar.bz2
binaryen-9dbe45780d8c78dbb49c208fe4505cd1624a98ac.zip
Disallow --nominal with GC (#4758)
Nominal types don't make much sense without GC, and in particular trying to emit them with typed function references but not GC enabled can result in invalid binaries because nominal types do not respect the type ordering constraints required by the typed function references proposal. Making this change was mostly straightforward, but required fixing the fuzzer to use --nominal only when GC is enabled and required exiting early from nominal-only optimizations when GC was not enabled. Fixes #4756.
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/fuzz_opt.py23
1 files changed, 11 insertions, 12 deletions
diff --git a/scripts/fuzz_opt.py b/scripts/fuzz_opt.py
index 745065732..01895c585 100755
--- a/scripts/fuzz_opt.py
+++ b/scripts/fuzz_opt.py
@@ -39,7 +39,6 @@ TYPE_SYSTEM_FLAG = '--nominal'
# feature options that are always passed to the tools.
CONSTANT_FEATURE_OPTS = ['--all-features']
-CONSTANT_FEATURE_OPTS.append(TYPE_SYSTEM_FLAG)
INPUT_SIZE_MIN = 1024
INPUT_SIZE_MEAN = 40 * 1024
@@ -120,6 +119,9 @@ def randomize_feature_opts():
if possible in IMPLIED_FEATURE_OPTS:
FEATURE_OPTS.extend(IMPLIED_FEATURE_OPTS[possible])
print('randomized feature opts:', '\n ' + '\n '.join(FEATURE_OPTS))
+ # Type system flags only make sense when GC is enabled
+ if '--disable-gc' not in FEATURE_OPTS:
+ FEATURE_OPTS.append(TYPE_SYSTEM_FLAG)
ALL_FEATURE_OPTS = ['--all-features', '-all', '--mvp-features', '-mvp']
@@ -819,8 +821,8 @@ class CheckDeterminism(TestCaseHandler):
b1 = open('b1.wasm', 'rb').read()
b2 = open('b2.wasm', 'rb').read()
if (b1 != b2):
- run([in_bin('wasm-dis'), 'b1.wasm', '-o', 'b1.wat', TYPE_SYSTEM_FLAG])
- run([in_bin('wasm-dis'), 'b2.wasm', '-o', 'b2.wat', TYPE_SYSTEM_FLAG])
+ run([in_bin('wasm-dis'), 'b1.wasm', '-o', 'b1.wat', FEATURE_OPTS])
+ run([in_bin('wasm-dis'), 'b2.wasm', '-o', 'b2.wat', FEATURE_OPTS])
t1 = open('b1.wat', 'r').read()
t2 = open('b2.wat', 'r').read()
compare(t1, t2, 'Output must be deterministic.', verbose=False)
@@ -1379,10 +1381,8 @@ on valid wasm files.)
with open('reduce.sh', 'w') as reduce_sh:
reduce_sh.write('''\
# check the input is even a valid wasm file
-echo "At least one of the next two values should be 0:"
-%(wasm_opt)s %(typesystem)s --detect-features %(temp_wasm)s
-echo " " $?
-%(wasm_opt)s %(typesystem)s --all-features %(temp_wasm)s
+echo "The following value should be 0:"
+%(wasm_opt)s %(features)s %(temp_wasm)s
echo " " $?
# run the command
@@ -1419,7 +1419,7 @@ echo " " $?
'auto_init': auto_init,
'original_wasm': original_wasm,
'temp_wasm': os.path.abspath('t.wasm'),
- 'typesystem': TYPE_SYSTEM_FLAG,
+ 'features': ' '.join(FEATURE_OPTS),
'reduce_sh': os.path.abspath('reduce.sh')})
print('''\
@@ -1441,7 +1441,7 @@ You can reduce the testcase by running this now:
vvvv
-%(wasm_reduce)s %(type_system_flag)s %(original_wasm)s '--command=bash %(reduce_sh)s' -t %(temp_wasm)s -w %(working_wasm)s
+%(wasm_reduce)s %(features)s %(original_wasm)s '--command=bash %(reduce_sh)s' -t %(temp_wasm)s -w %(working_wasm)s
^^^^
@@ -1449,9 +1449,8 @@ vvvv
Make sure to verify by eye that the output says something like this:
-At least one of the next two values should be 0:
+The following value should be 0:
0
- 1
The following value should be 1:
1
@@ -1471,7 +1470,7 @@ After reduction, the reduced file will be in %(working_wasm)s
'working_wasm': os.path.abspath('w.wasm'),
'wasm_reduce': in_bin('wasm-reduce'),
'reduce_sh': os.path.abspath('reduce.sh'),
- 'type_system_flag': TYPE_SYSTEM_FLAG})
+ 'features': ' '.join(FEATURE_OPTS)})
break
if given_seed is not None:
break