Skip to content

Commit b725fbf

Browse files
authored
Make Emscripten aware of minimum browser versions for WASM_BIGINT setting (#17163)
When WASM_BIGINT is set, we can assume the browser is recent enough to support that feature, as things will not work otherwise anyhow.
1 parent 06e68ea commit b725fbf

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.2.0
2222
-----
23+
- Emscripten now knows what minimum browser versions the `WASM_BIGINT` feature
24+
requires and will automatically set the defaults accordingly. (#17163)
2325
- Weak undefined symbols fixed in dynamic linking. (#17164)
2426
- Internally, the name of `main` function now gets mangled (by clang) in the
2527
same way as with other wasm targets. This means that within the wasm module

emcc.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,21 @@ def apply_settings(user_settings):
396396
settings.LTO = 0 if value else 'full'
397397

398398

399+
# apply minimum browser version defaults based on user settings. if
400+
# a user requests a feature that we know is only supported in browsers
401+
# from a specific version and above, we can assume that browser version.
402+
def apply_min_browser_versions(user_settings):
403+
404+
def default_min_browser_version(browser, version):
405+
default_setting(user_settings, f'MIN_{browser.upper()}_VERSION', version)
406+
407+
if settings.WASM_BIGINT:
408+
default_min_browser_version('Safari', 150000)
409+
default_min_browser_version('Edge', 79)
410+
default_min_browser_version('Firefox', 68)
411+
# Chrome has BigInt since v67 which is less than default min version.
412+
413+
399414
def is_ar_file_with_missing_index(archive_file):
400415
# We parse the archive header outselves because llvm-nm --print-armap is slower and less
401416
# reliable.
@@ -2597,6 +2612,8 @@ def get_full_import_name(name):
25972612
if settings.WASM_EXCEPTIONS:
25982613
settings.REQUIRED_EXPORTS += ['__trap']
25992614

2615+
apply_min_browser_versions(user_settings)
2616+
26002617
return target, wasm_target
26012618

26022619

src/settings.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,9 +1338,10 @@ var WASM_ASYNC_COMPILATION = true;
13381338
// [link]
13391339
var DYNCALLS = false;
13401340

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

0 commit comments

Comments
 (0)