Skip to content

Commit

Permalink
Put in place some minimum browser versions
Browse files Browse the repository at this point in the history
These are the values we use when `-sLEGACY_VM_SUPPORT` is set or when
the users set one of the `-sMIN_XX_VERSION` settings to zero.  Zero has
always implied "oldest supported version".

The upside of this is that when babel is run now with
`-sLEGACY_VM_SUPPORT` we get a babel config file that looks like this:

```
{
  "sourceType": "script",
  "targets": {
    "chrome": "45",
    "firefox": "34",
    "safari": "9.0.0",
    "node": "10.19.0"
  }
}
```

As a followup I think we can remove any code blocks that are only active
for versions older than these.
  • Loading branch information
sbc100 committed Dec 14, 2023
1 parent 0de50a2 commit fdb2c59
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 16 deletions.
1 change: 1 addition & 0 deletions tools/building.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,6 +539,7 @@ def transpile(filename):
config_json = json.dumps(config, indent=2)
outfile = shared.get_temp_files().get('babel.js').name
config_file = shared.get_temp_files().get('babel_config.json').name
logger.debug(config_json)
utils.write_file(config_file, config_json)
cmd = shared.get_npm_cmd('babel') + [filename, '-o', outfile, '--presets', '@babel/preset-env', '--config-file', config_file]
check_call(cmd, cwd=path_from_root())
Expand Down
15 changes: 15 additions & 0 deletions tools/feature_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,21 @@

UNSUPPORTED = 0x7FFFFFFF

# Oldest support browser versions. These have been set somewhat
# arbitrarily for now, based on:
# https://caniuse.com/mdn-javascript_builtins_object_assign
# -> FF:34 CHROME:45 SAFARI:9 NODE:4.0.0
# https://caniuse.com/promises
# https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise
# -> FF:29 CHROME:33 SAFARI:8 NODE:0.12.0
# TODO(sbc): Design a of policy for manging these values.
OLDEST_SUPPORTED_CHROME = 45
OLDEST_SUPPORTED_FIREFOX = 34
OLDEST_SUPPORTED_SAFARI = 90000
# 10.19.0 is the oldest version of node that we do any testing with.
# Keep this in sync with the test-node-compat in .circleci/config.yml.
OLDEST_SUPPORTED_NODE = 101900


class Feature(IntEnum):
NON_TRAPPING_FPTOINT = auto()
Expand Down
41 changes: 25 additions & 16 deletions tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -621,6 +621,26 @@ def set_max_memory():
exit_with_error('MAXIMUM_MEMORY cannot be less than INITIAL_MEMORY')


def check_browser_versions():
settings_map = {
'MIN_FIREFOX_VERSION': feature_matrix.OLDEST_SUPPORTED_FIREFOX,
'MIN_CHROME_VERSION': feature_matrix.OLDEST_SUPPORTED_CHROME,
'MIN_SAFARI_VERSION': feature_matrix.OLDEST_SUPPORTED_SAFARI,
'MIN_NODE_VERSION': feature_matrix.OLDEST_SUPPORTED_NODE,
}

if settings.LEGACY_VM_SUPPORT:
# Support all old browser versions
for key, oldest in settings_map.items():
default_setting(key, oldest)

for key, oldest in settings_map.items():
if settings[key] == 0:
settings[key] = oldest
if settings[key] < oldest:
exit_with_error(f'{key} older than {oldest} is not supported')


@ToolchainProfiler.profile_block('linker_setup')
def phase_linker_setup(options, state, newargs):
system_libpath = '-L' + str(cache.get_lib_dir(absolute=True))
Expand Down Expand Up @@ -1091,27 +1111,16 @@ def phase_linker_setup(options, state, newargs):
if settings.MINIMAL_RUNTIME and options.oformat == OFormat.HTML and not settings.PTHREADS:
settings.EXPORT_READY_PROMISE = 0

if settings.LEGACY_VM_SUPPORT:
if settings.WASM2JS:
settings.POLYFILL_OLD_MATH_FUNCTIONS = 1
if settings.WASM2JS and settings.LEGACY_VM_SUPPORT:
settings.POLYFILL_OLD_MATH_FUNCTIONS = 1

# Support all old browser versions
settings.MIN_FIREFOX_VERSION = 0
settings.MIN_SAFARI_VERSION = 0
settings.MIN_CHROME_VERSION = 0
settings.MIN_NODE_VERSION = 0
check_browser_versions()

if settings.MIN_CHROME_VERSION <= 37:
settings.WORKAROUND_OLD_WEBGL_UNIFORM_UPLOAD_IGNORED_OFFSET_BUG = 1

# 10.19.0 is the oldest version of node that we do any testing with.
# Keep this in sync with the test-node-compat in .circleci/config.yml
# and MINIMUM_NODE_VERSION in tools/shared.py
if settings.MIN_NODE_VERSION:
if settings.MIN_NODE_VERSION < 101900:
exit_with_error('targeting node older than 10.19.00 is not supported')
if settings.MIN_NODE_VERSION >= 150000:
default_setting('NODEJS_CATCH_REJECTION', 0)
if settings.MIN_NODE_VERSION >= 150000:
default_setting('NODEJS_CATCH_REJECTION', 0)

# Do not catch rejections or exits in modularize mode, as these options
# are for use when running emscripten modules standalone
Expand Down

0 comments on commit fdb2c59

Please sign in to comment.