Skip to content

Skip all validation when 'no-validation' pass is specified #15128

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions tests/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -7028,6 +7028,23 @@ def build(args=[]):
# adding --metrics should not affect code size
self.assertEqual(base_size, os.path.getsize('a.out.wasm'))

def test_binaryen_passes_no_validation(self):
def build(args=[]):
return self.run_process([EMXX, test_file('hello_world.cpp'), '-O3', '-g3'] + args, stderr=PIPE).stderr

with env_modify({'BINARYEN_PASS_DEBUG': '1'}):
out = build()
self.assertContained('(validating)', out)
self.assertContained('(final validation)', out)
base_size = os.path.getsize('a.out.wasm')

out = build(['-s', 'BINARYEN_EXTRA_PASSES="--no-validation"'])
# (validating) and (final validation) should not appear
self.assertNotContained('(validating)', out)
self.assertNotContained('(final validation)', out)
# adding --no-validation should not affect code size
self.assertEqual(base_size, os.path.getsize('a.out.wasm'))

def assertFileContents(self, filename, contents):
contents = contents.replace('\r', '')

Expand Down
7 changes: 7 additions & 0 deletions tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,13 @@ def run_binaryen_command(tool, infile, outfile=None, args=[], debug=False, stdou
if settings.GENERATE_SOURCE_MAP and outfile:
cmd += [f'--input-source-map={infile}.map']
cmd += [f'--output-source-map={outfile}.map']
# we should skip all validation when 'no-validation' pass is specified
if settings.BINARYEN_EXTRA_PASSES:
# BINARYEN_EXTRA_PASSES is comma-separated
extras = settings.BINARYEN_EXTRA_PASSES.split(',')
# we support both '-'-prefixed and unprefixed pass names
if '--no-validation' in extras or 'no-validation' in extras:
cmd += ['--no-validation']
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a the right place to put --no-validation.. its BINARYEN_EXTRA_PASSES is, up until now, something the only effects the running of wasm-opt.

Perhaps a new -s NO_VALIDATE setting would make more sense?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, BINARYEN_EXTRA_PASSES is a single possible place to use --no-validation.

Default settings require my action:

struct PassOptions {
...
// Whether to run the validator to check for errors.
bool validate = true;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed that we already have BINARYEN_FEATURES which is almost what we want here, except that it is an internal setting atm. If we moved that from src/settings_internal.js to src/settings.js then this would work.

The name is because it is used to pass around features primarily, but nothing prevents other things from being there like --no-validation. Perhaps we should rename it though to BINARYEN_FLAGS?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've be OK with adding BINARYEN_FLAGS assuming we can show this is really needed. I think in order to make it work while we would need to show a significant amount of the link time could be saved by adding --no-validation.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(My preferred option would be will be to modify BINARYEN_PASS_DEBUG to have a mode that didn't slow things down quite as much since that is that what is specifically needed here).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope to finish tests for next weekends. Then things can come clear.

ret = check_call(cmd, stdout=stdout).stdout
if outfile:
save_intermediate(outfile, '%s.wasm' % tool)
Expand Down