-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Do not pass --enable-bulk-memory in Binaryen when -mno-bulk-memory is used #25466
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2757,6 +2757,22 @@ def test_copyop(self): | |
# (llvm-gcc copies items one by one). | ||
self.do_core_test('test_copyop.cpp') | ||
|
||
# Verify that when passing -mno-bulk-memory -mno-bulk-memory-opt, that the | ||
# resulting .wasm module should not have the bulk-memory Data Count section. | ||
@no_wasm2js('This test verifies .wasm module behavior') | ||
@no_esm_integration('TODO: Currently fails') | ||
def test_no_bulk_memory(self): | ||
if self.get_setting('MEMORY64') == 1: | ||
self.skipTest('Wasm64 always has bulk-memory') | ||
if self.get_setting('MEMORY64') == 2: | ||
self.skipTest('TODO: Currently fails') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think there's any reason to support a configuration with memory64 but without bulk memory, so this probably doesn't need to be a TODO. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That corresponds to the To my understanding that should "technically" work? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah right, that could technically work. real memory64 without bulk could technically work too of course, but I've never heard of any implementation like that, nor can I think of any reason anyone would do that. Wasm64l is a very niche use case, but at least I can imagine why someone might use it in theory. |
||
|
||
self.emcc(test_file('hello_world.c'), ['-mno-bulk-memory', '-mno-bulk-memory-opt']) | ||
|
||
with webassembly.Module('a.out.wasm') as module: | ||
for s in module.sections(): | ||
self.assertNotEqual(s.type, webassembly.SecType.DATACOUNT) | ||
|
||
@parameterized({ | ||
'': ([],), | ||
'bulkmem': (['-mbulk-memory'],), | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
from tools import building | ||
from tools import config | ||
from tools import diagnostics | ||
from tools import feature_matrix | ||
from tools import js_manipulation | ||
from tools import shared | ||
from tools import utils | ||
|
@@ -116,6 +117,12 @@ def update_settings_glue(wasm_file, metadata, base_metadata): | |
|
||
# start with the MVP features, and add any detected features. | ||
settings.BINARYEN_FEATURES = ['--mvp-features'] + metadata.features | ||
if not feature_matrix.caniuse(feature_matrix.Feature.BULK_MEMORY): | ||
if '--enable-bulk-memory' in settings.BINARYEN_FEATURES: | ||
settings.BINARYEN_FEATURES.remove('--enable-bulk-memory') | ||
if '--enable-bulk-memory-opt' in settings.BINARYEN_FEATURES: | ||
settings.BINARYEN_FEATURES.remove('--enable-bulk-memory-opt') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this is handled elsewhere. In
Which should lower it away... but maybe its not working as intended? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder if that would only lower the instructions, but the extra Wasm sections still remain in the generated code, which results in pre-bulk memory browsers not being able to parse the .wasm module. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case maybe the lowing pass is broken!? Seems odd that we wouldn't have test coverage for that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What extra sections are you referring to? IIRC that only time llvm uses bulk memory is to copying and and filling withing the normal linear memory? Or perhaps you mean the use of bulk memory in pthreads init code? Does pthreads not have a hard dependency on bulk memory? Are there targets that support pthreads/SAB but not bulk memory? IIRC there are not? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe.. The concrete error that Firefox 78 ESR then complains is that the generated .wasm file has a Data Count section, i.e. in the case of the above
and Firefox 78 ESR croaks at byte 121. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any any case it doesn't look like this is the right place to try and to lowing passes / removing of features. I think this should go with the existing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does not seem to be a binaryen pass selection/activation problem. if not feature_matrix.caniuse(feature_matrix.Feature.BULK_MEMORY):
logger.debug('lowering bulk-memory feature due to incompatible target browser engines')
passes += ['--llvm-memory-copy-fill-lowering'] but that doesn't seem to be enough. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. But is there some other flag you can add to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kripken do you know that best place / way to do force the removal of the data count section? |
||
|
||
if settings.ASYNCIFY == 2: | ||
settings.BINARYEN_FEATURES += ['--enable-reference-types'] | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is an existing
test_wasm_features
test that is supposed to code this kind of thing. Maybe this can be added to that existing test? Or at least co-located with it and named similarly to it?Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I placed this in the core test suite, because it looks like this is optimization flag dependent. I.e. it does not fail in -O0, but fails in -Os and -O3. So testing different optimization modes seems in order.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe
test_wasm_features
should be in core for the same reasons then?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe..
I'll close this out for now, I get an impression that the fix is in wrong place, and the test is in wrong place. I'll pick my battles to focus progress in my testing effort.