|
34 | 34 | webassembly, |
35 | 35 | ) |
36 | 36 | from .cmdline import OFormat |
| 37 | +from .feature_matrix import Feature |
37 | 38 | from .minimal_runtime_shell import generate_minimal_runtime_html |
38 | 39 | from .settings import ( |
39 | 40 | DEPRECATED_SETTINGS, |
@@ -367,16 +368,21 @@ def get_binaryen_lowering_passes(): |
367 | 368 | # This can happen if the feature is explicitly disabled on the command line, |
368 | 369 | # or when targeting an VM/engine that does not support the feature. |
369 | 370 |
|
370 | | - # List of [<feature_name>, <lowering_flag>] pairs. |
| 371 | + # List of [<feature_name>, <lowering_flag>, <feature_flags>] triples. |
371 | 372 | features = [ |
372 | | - [feature_matrix.Feature.SIGN_EXT, '--signext-lowering'], |
373 | | - [feature_matrix.Feature.NON_TRAPPING_FPTOINT, '--llvm-nontrapping-fptoint-lowering'], |
374 | | - [feature_matrix.Feature.BULK_MEMORY, '--llvm-memory-copy-fill-lowering'], |
| 373 | + [Feature.SIGN_EXT, '--signext-lowering', ['--enable-sign-ext']], |
| 374 | + [Feature.NON_TRAPPING_FPTOINT, '--llvm-nontrapping-fptoint-lowering', ['--enable-nontrapping-float-to-int']], |
| 375 | + [Feature.BULK_MEMORY, '--llvm-memory-copy-fill-lowering', ['--enable-bulk-memory', '--enable-bulk-memory-opt']], |
375 | 376 | ] |
376 | 377 |
|
377 | | - for feature, lowering_flag in features: |
| 378 | + for feature, lowering_flag, feature_flags in features: |
378 | 379 | if not feature_matrix.caniuse(feature): |
379 | 380 | logger.debug(f'lowering {feature.name} feature due to incompatible target browser engines') |
| 381 | + for f in feature_flags: |
| 382 | + # Remove features from binaryen_features, otherwise future runs of binaryen |
| 383 | + # could re-introduce the feature. |
| 384 | + if f in building.binaryen_features: |
| 385 | + building.binaryen_features.remove(f) |
380 | 386 | passes.append(lowering_flag) |
381 | 387 |
|
382 | 388 | return passes |
@@ -1044,7 +1050,7 @@ def limit_incoming_module_api(): |
1044 | 1050 | if user_settings.get('WASM_BIGINT') and settings.WASM_BIGINT: |
1045 | 1051 | exit_with_error('WASM_BIGINT=1 is not compatible with wasm2js') |
1046 | 1052 | settings.WASM_BIGINT = 0 |
1047 | | - feature_matrix.disable_feature(feature_matrix.Feature.JS_BIGINT_INTEGRATION) |
| 1053 | + feature_matrix.disable_feature(Feature.JS_BIGINT_INTEGRATION) |
1048 | 1054 |
|
1049 | 1055 | if options.oformat == OFormat.WASM and not settings.SIDE_MODULE: |
1050 | 1056 | # if the output is just a wasm file, it will normally be a standalone one, |
@@ -1583,8 +1589,8 @@ def limit_incoming_module_api(): |
1583 | 1589 |
|
1584 | 1590 | # TODO(sbc): Find make a generic way to expose the feature matrix to JS |
1585 | 1591 | # compiler rather then adding them all ad-hoc as internal settings |
1586 | | - settings.SUPPORTS_PROMISE_ANY = feature_matrix.caniuse(feature_matrix.Feature.PROMISE_ANY) |
1587 | | - default_setting('WASM_BIGINT', feature_matrix.caniuse(feature_matrix.Feature.JS_BIGINT_INTEGRATION)) |
| 1592 | + settings.SUPPORTS_PROMISE_ANY = feature_matrix.caniuse(Feature.PROMISE_ANY) |
| 1593 | + default_setting('WASM_BIGINT', feature_matrix.caniuse(Feature.JS_BIGINT_INTEGRATION)) |
1588 | 1594 |
|
1589 | 1595 | if settings.AUDIO_WORKLET: |
1590 | 1596 | add_system_js_lib('libwebaudio.js') |
|
0 commit comments