Skip to content

Commit

Permalink
Update default Safari version target to 15.0 (#23312)
Browse files Browse the repository at this point in the history
Update the default MIN_SAFARI_VERSION from 14.1 to 15.0.
Also fix the feature matrix code to be correct again as described in
#23184
  • Loading branch information
dschuff authored Jan 7, 2025
1 parent 229bc6d commit 844e8ca
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 37 deletions.
28 changes: 17 additions & 11 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,23 @@ See docs/process.md for more on how version tagging works.
----------------------
- compiler-rt, libcxx, libcxxabi, and libunwind were updated to LLVM 19.1.6.
(#22937, #22994, and #23294)
- The Wasm nontrapping-fptoint feature has been enabled by default. clang will
generate nontrapping (saturating) float-to-int conversion instructions for
C typecasts. This should have no effect on programs that do not have
undefined behavior but if the casted floating-point value is outside the range
of the target integer type, the result will be a number of the max or min value
instead of a trap. This also results in a small code size improvement because
of details of the LLVM IR semantics. This feature can be disabled in clang with
the -mno-nontrapping-fptoint flag. (#23007)
- The `WASM_BIGINT` feature has been enabled by default. This has the effect that
Wasm i64 values are passed and returned between Wasm and JS as BigInt values
rather than being split by Binaryen into pairs of Numbers. (#22993)
- The default Safari version targeted by Emscripten has been raised from 14.1
to 15.0 (the `MIN_SAFARI_VERSION` setting) (#23312). This has several effects:
- The Wasm nontrapping-fptoint feature is enabled by default. Clang will
generate nontrapping (saturating) float-to-int conversion instructions for
C typecasts. This should have no effect on programs that do not have
undefined behavior but if the casted floating-point value is outside the range
of the target integer type, the result will be a number of the max or min value
instead of a trap. This also results in a small code size improvement because
of details of the LLVM IR semantics. This feature can be disabled in clang with
the -mno-nontrapping-fptoint flag. (#23007)
- The `WASM_BIGINT` feature is enabled by default. This has the effect that
Wasm i64 values are passed and returned between Wasm and JS as BigInt values
rather than being split by Binaryen into pairs of Numbers. (#22993)
- The `BULK_MEMORY` feature is enabled by default. `memory.copy` and
`memory.fill` instructions are used in the implementation of C `memcpy` and
`memset`, and Clang may generate them elsewhere (#22873). It can be
disabled with the `-mno-bulk-memory` flag.
- When using `-sMODULARIZE` we now assert if the factory function is called with
the JS `new` keyword. e.g. `a = new Module()` rather than `b = Module()`.
This paves the way for marking the function as `async` which does not allow
Expand Down
5 changes: 2 additions & 3 deletions site/source/docs/tools_reference/settings_reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2186,8 +2186,7 @@ WASM_BIGINT

WebAssembly integration with JavaScript BigInt. When enabled we don't need to
legalize i64s into pairs of i32s, as the wasm VM will use a BigInt where an
i64 is used. If WASM_BIGINT is present, the default minimum supported browser
versions will be increased to the min version that supports BigInt.
i64 is used.

Default value: true

Expand Down Expand Up @@ -2928,7 +2927,7 @@ MAX_INT (0x7FFFFFFF, or -1) specifies that target is not supported.
Minimum supported value is 101000 which was released in 2016-09 (see
feature_matrix.py).

Default value: 140100
Default value: 150000

.. _min_chrome_version:

Expand Down
5 changes: 2 additions & 3 deletions src/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -1495,8 +1495,7 @@ var DYNCALLS = false;

// WebAssembly integration with JavaScript BigInt. When enabled we don't need to
// legalize i64s into pairs of i32s, as the wasm VM will use a BigInt where an
// i64 is used. If WASM_BIGINT is present, the default minimum supported browser
// versions will be increased to the min version that supports BigInt.
// i64 is used.
// [link]
var WASM_BIGINT = true;

Expand Down Expand Up @@ -1913,7 +1912,7 @@ var MIN_FIREFOX_VERSION = 79;
// Minimum supported value is 101000 which was released in 2016-09 (see
// feature_matrix.py).
// [link]
var MIN_SAFARI_VERSION = 140100;
var MIN_SAFARI_VERSION = 150000;

// Specifies the oldest version of Chrome. E.g. pass -sMIN_CHROME_VERSION=58 to
// drop support for Chrome 57 and older.
Expand Down
3 changes: 1 addition & 2 deletions src/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ var Module = typeof {{{ EXPORT_NAME }}} != 'undefined' ? {{{ EXPORT_NAME }}} : {
#endif // USE_CLOSURE_COMPILER

#if POLYFILL
#if WASM_BIGINT && MIN_SAFARI_VERSION < 140100
// TODO(https://github.com/emscripten-core/emscripten/issues/23184): Fix this back to 150000
#if WASM_BIGINT && MIN_SAFARI_VERSION < 150000
// See https://caniuse.com/mdn-javascript_builtins_bigint64array
#include "polyfill/bigint64array.js"
#endif
Expand Down
34 changes: 19 additions & 15 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -10448,6 +10448,7 @@ def verify_features_sec_linked(feature, expect_in):
def compile(flags):
self.run_process([EMCC, test_file('hello_world.c')] + flags)

# Default features, unlinked and linked
compile(['-c'])
verify_features_sec('bulk-memory', True)
verify_features_sec('nontrapping-fptoint', True)
Expand All @@ -10456,17 +10457,28 @@ def compile(flags):
verify_features_sec('multivalue', True)
verify_features_sec('reference-types', True)

compile([])
verify_features_sec_linked('sign-ext', True)
verify_features_sec_linked('mutable-globals', True)
verify_features_sec_linked('multivalue', True)
verify_features_sec_linked('bulk-memory-opt', True)
verify_features_sec_linked('nontrapping-fptoint', True)
verify_features_sec_linked('reference-types', True)

# Disable a feature
compile(['-mno-sign-ext', '-c'])
verify_features_sec('sign-ext', False)
# Disable via browser selection
compile(['-sMIN_FIREFOX_VERSION=61'])
verify_features_sec_linked('sign-ext', False)
compile(['-sMIN_SAFARI_VERSION=140100'])
verify_features_sec_linked('bulk-memory-opt', False)
verify_features_sec_linked('nontrapping-fptoint', False)
# Flag disabling overrides default browser versions
compile(['-mno-sign-ext'])
verify_features_sec_linked('sign-ext', False)
# Flag disabling overrides explicit browser version
compile(['-sMIN_SAFARI_VERSION=150000', '-mno-sign-ext'])
compile(['-sMIN_SAFARI_VERSION=160000', '-mno-sign-ext'])
verify_features_sec_linked('sign-ext', False)
# Flag enabling overrides explicit browser version
compile(['-sMIN_FIREFOX_VERSION=61', '-msign-ext'])
Expand All @@ -10475,18 +10487,12 @@ def compile(flags):
compile(['-sMIN_SAFARI_VERSION=150000', '-mno-bulk-memory'])
verify_features_sec_linked('bulk-memory-opt', False)

# TODO(https://github.com/emscripten-core/emscripten/issues/23184) set this back to 14.1
# Also the section below can be deleted/updated once the default is 15.1
compile(['-sMIN_SAFARI_VERSION=140000'])
# Bigint ovrride does not cause other features to enable
compile(['-sMIN_SAFARI_VERSION=140100', '-sWASM_BIGINT=1'])
verify_features_sec_linked('bulk-memory-opt', False)
verify_features_sec_linked('nontrapping-fptoint', False)

compile(['-sMIN_SAFARI_VERSION=150000'])
verify_features_sec_linked('sign-ext', True)
verify_features_sec_linked('mutable-globals', True)
verify_features_sec_linked('multivalue', True)
verify_features_sec_linked('bulk-memory-opt', True)
verify_features_sec_linked('nontrapping-fptoint', True)
compile(['-sMIN_SAFARI_VERSION=140100', '-mbulk-memory'])
verify_features_sec_linked('nontrapping-fptoint', False)

def test_js_preprocess(self):
# Use stderr rather than stdout here because stdout is redirected to the output JS file itself.
Expand Down Expand Up @@ -12365,8 +12371,7 @@ def fail(args, details):
# plain -O0
legalization_message = 'to disable int64 legalization (which requires changes after link) use -sWASM_BIGINT'
fail(['-sWASM_BIGINT=0'], legalization_message)
# TODO(https://github.com/emscripten-core/emscripten/issues/23184): change this back to 140100 after 15 is default
fail(['-sMIN_SAFARI_VERSION=140000'], legalization_message)
fail(['-sMIN_SAFARI_VERSION=140100'], legalization_message)
# optimized builds even without legalization
optimization_message = '-O2+ optimizations always require changes, build with -O0 or -O1 instead'
fail(['-O2'], optimization_message)
Expand Down Expand Up @@ -14440,8 +14445,7 @@ def test_reproduce(self):

def test_min_browser_version(self):
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Wno-transpile', '-Werror', '-sWASM_BIGINT', '-sMIN_SAFARI_VERSION=120000'])
# TODO(https://github.com/emscripten-core/emscripten/issues/23184): fix back to 15000 once Safari 15 is default
self.assertContained('emcc: error: MIN_SAFARI_VERSION=120000 is not compatible with WASM_BIGINT (140100 or above required)', err)
self.assertContained('emcc: error: MIN_SAFARI_VERSION=120000 is not compatible with WASM_BIGINT (150000 or above required)', err)

err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Wno-transpile', '-Werror', '-pthread', '-sMIN_CHROME_VERSION=73'])
self.assertContained('emcc: error: MIN_CHROME_VERSION=73 is not compatible with pthreads (74 or above required)', err)
Expand Down
6 changes: 3 additions & 3 deletions 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': 140100, # TODO: Reset back to 150000 when the default changes
'safari': 150000,
'node': 130000,
},
Feature.SIGN_EXT: {
Expand All @@ -58,7 +58,7 @@ class Feature(IntEnum):
Feature.BULK_MEMORY: {
'chrome': 75,
'firefox': 79,
'safari': 140100, # TODO: Reset this to 150000 when we update the default.
'safari': 150000,
'node': 130000,
},
Feature.MUTABLE_GLOBALS: {
Expand All @@ -70,7 +70,7 @@ class Feature(IntEnum):
Feature.JS_BIGINT_INTEGRATION: {
'chrome': 67,
'firefox': 68,
'safari': 140100, # TODO(https://github.com/emscripten-core/emscripten/issues/23184): set this back to 15 after we update the default targets.
'safari': 150000,
'node': 130000,
},
Feature.THREADS: {
Expand Down

0 comments on commit 844e8ca

Please sign in to comment.