Skip to content

Commit 56e189d

Browse files
committed
Enable nontrapping by lowering browser requirement
1 parent bc2123f commit 56e189d

File tree

4 files changed

+14
-7
lines changed

4 files changed

+14
-7
lines changed

emcc.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,8 +391,6 @@ def get_clang_flags(user_args):
391391
# Bulk memory may be enabled via threads or directly via -s.
392392
if not settings.BULK_MEMORY:
393393
flags.append('-mno-bulk-memory')
394-
if '-mnontrapping-fptoint' not in user_args and '-mno-nontrapping-fptoint' not in user_args:
395-
flags.append('-mno-nontrapping-fptoint')
396394

397395
if settings.RELOCATABLE and '-fPIC' not in user_args:
398396
flags.append('-fPIC')
@@ -1416,6 +1414,12 @@ def consume_arg_file():
14161414
override=True)
14171415
elif arg == '-mno-sign-ext':
14181416
feature_matrix.disable_feature(feature_matrix.Feature.SIGN_EXT)
1417+
elif arg == '-mnontrappting-fptoint':
1418+
feature_matrix.enable_feature(feature_matrix.Feature.NON_TRAPPING_FPTOINT,
1419+
'-mnontrapping-fptoint',
1420+
override=True)
1421+
elif arg == '-mno-nontrapping-fptoint':
1422+
feature_matrix.disable_feature(feature_matrix.Feature.NON_TRAPPING_FPTOINT)
14191423
elif arg == '-fexceptions':
14201424
# TODO Currently -fexceptions only means Emscripten EH. Switch to wasm
14211425
# exception handling by default when -fexceptions is given when wasm

test/test_other.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10432,7 +10432,7 @@ def compile(flags):
1043210432

1043310433
compile(['-c'])
1043410434
verify_features_sec('bulk-memory', False)
10435-
verify_features_sec('nontrapping-fptoint', False)
10435+
verify_features_sec('nontrapping-fptoint', True)
1043610436
verify_features_sec('sign-ext', True)
1043710437
verify_features_sec('mutable-globals', True)
1043810438
verify_features_sec('multivalue', True)
@@ -10453,8 +10453,8 @@ def compile(flags):
1045310453
compile(['-sMIN_FIREFOX_VERSION=61', '-msign-ext'])
1045410454
verify_features_sec_linked('sign-ext', True)
1045510455

10456-
compile(['-mnontrapping-fptoint', '-c'])
10457-
verify_features_sec('nontrapping-fptoint', True)
10456+
compile(['-mno-nontrapping-fptoint'])
10457+
verify_features_sec_linked('nontrapping-fptoint', False)
1045810458

1045910459
# Setting this SAFARI_VERSION should enable bulk memory because it links in emscripten_memcpy_bulkmem
1046010460
# However it does not enable nontrapping-fptoint yet because it has no effect at compile time and
@@ -10464,7 +10464,7 @@ def compile(flags):
1046410464
verify_features_sec_linked('mutable-globals', True)
1046510465
verify_features_sec_linked('multivalue', True)
1046610466
verify_features_sec_linked('bulk-memory', True)
10467-
verify_features_sec_linked('nontrapping-fptoint', False)
10467+
verify_features_sec_linked('nontrapping-fptoint', True)
1046810468

1046910469
compile(['-sMIN_SAFARI_VERSION=150000', '-mno-bulk-memory'])
1047010470
# -mno-bulk-memory at link time overrides MIN_SAFARI_VERSION

tools/feature_matrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class Feature(IntEnum):
4646
Feature.NON_TRAPPING_FPTOINT: {
4747
'chrome': 75,
4848
'firefox': 65,
49-
'safari': 150000,
49+
'safari': 140100, #TODO: Reset back to 150000 when the default changes
5050
},
5151
Feature.SIGN_EXT: {
5252
'chrome': 74,

tools/link.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -340,6 +340,9 @@ def get_binaryen_passes():
340340
if not feature_matrix.caniuse(feature_matrix.Feature.SIGN_EXT):
341341
logger.debug('lowering sign-ext feature due to incompatible target browser engines')
342342
passes += ['--signext-lowering']
343+
# nontrapping-fp is enabled by default in llvm. Lower it away if requested.
344+
if not feature_matrix.caniuse(feature_matrix.Feature.NON_TRAPPING_FPTOINT):
345+
passes += ['--llvm-nontrapping-fptoint-lowering']
343346
if optimizing:
344347
passes += ['--post-emscripten']
345348
if settings.SIDE_MODULE:

0 commit comments

Comments
 (0)