Skip to content
8 changes: 6 additions & 2 deletions emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -391,8 +391,6 @@ def get_clang_flags(user_args):
# Bulk memory may be enabled via threads or directly via -s.
if not settings.BULK_MEMORY:
flags.append('-mno-bulk-memory')
if '-mnontrapping-fptoint' not in user_args and '-mno-nontrapping-fptoint' not in user_args:
flags.append('-mno-nontrapping-fptoint')

if settings.RELOCATABLE and '-fPIC' not in user_args:
flags.append('-fPIC')
Expand Down Expand Up @@ -1416,6 +1414,12 @@ def consume_arg_file():
override=True)
elif arg == '-mno-sign-ext':
feature_matrix.disable_feature(feature_matrix.Feature.SIGN_EXT)
elif arg == '-mnontrappting-fptoint':
feature_matrix.enable_feature(feature_matrix.Feature.NON_TRAPPING_FPTOINT,
'-mnontrapping-fptoint',
override=True)
elif arg == '-mno-nontrapping-fptoint':
feature_matrix.disable_feature(feature_matrix.Feature.NON_TRAPPING_FPTOINT)
elif arg == '-fexceptions':
# TODO Currently -fexceptions only means Emscripten EH. Switch to wasm
# exception handling by default when -fexceptions is given when wasm
Expand Down
8 changes: 4 additions & 4 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -10432,7 +10432,7 @@ def compile(flags):

compile(['-c'])
verify_features_sec('bulk-memory', False)
verify_features_sec('nontrapping-fptoint', False)
verify_features_sec('nontrapping-fptoint', True)
verify_features_sec('sign-ext', True)
verify_features_sec('mutable-globals', True)
verify_features_sec('multivalue', True)
Expand All @@ -10453,8 +10453,8 @@ def compile(flags):
compile(['-sMIN_FIREFOX_VERSION=61', '-msign-ext'])
verify_features_sec_linked('sign-ext', True)

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

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

compile(['-sMIN_SAFARI_VERSION=150000', '-mno-bulk-memory'])
# -mno-bulk-memory at link time overrides MIN_SAFARI_VERSION
Expand Down
2 changes: 1 addition & 1 deletion tools/feature_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Feature(IntEnum):
Feature.NON_TRAPPING_FPTOINT: {
'chrome': 75,
'firefox': 65,
'safari': 150000,
'safari': 140100, #TODO: Reset back to 150000 when the default changes
},
Feature.SIGN_EXT: {
'chrome': 74,
Expand Down
3 changes: 3 additions & 0 deletions tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,9 @@ def get_binaryen_passes():
if not feature_matrix.caniuse(feature_matrix.Feature.SIGN_EXT):
logger.debug('lowering sign-ext feature due to incompatible target browser engines')
passes += ['--signext-lowering']
# nontrapping-fp is enabled by default in llvm. Lower it away if requested.
if not feature_matrix.caniuse(feature_matrix.Feature.NON_TRAPPING_FPTOINT):
passes += ['--llvm-nontrapping-fptoint-lowering']
if optimizing:
passes += ['--post-emscripten']
if settings.SIDE_MODULE:
Expand Down