Skip to content

Commit 87a3b6e

Browse files
committed
Add MUTABLE_GLOBALS to feature_matrix
This is needed by dynamic linking since GOT entries are all imported as mutable globals. The net effect of this is that you cannot actually target the oldest version of safari that we support (12) and with dynamically linked programs. Specifying `-sLEGACY_VM_SUPPORT` will give you safari 13.1 instead of 12 if you also using `-sMAIN_MODULE`.
1 parent 89cf437 commit 87a3b6e

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

src/lib/libdylink.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -276,12 +276,10 @@ var LibraryDylink = {
276276
continue;
277277
}
278278
#endif
279-
if (typeof value?.value != 'undefined') {
280-
// a breaking change in the wasm spec, globals are now objects
281-
// https://github.com/WebAssembly/mutable-global/issues/1
279+
// Detect wasm global exports. These represent data addresses
280+
// which are relative to `memoryBase`
281+
if (typeof value.value != 'undefined') {
282282
value = value.value;
283-
}
284-
if (typeof value == {{{ POINTER_JS_TYPE }}}) {
285283
value += {{{ to64('memoryBase') }}};
286284
}
287285
relocated[e] = value;

test/codesize/test_codesize_hello_dylink.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
2-
"a.out.js": 26931,
3-
"a.out.js.gz": 11472,
2+
"a.out.js": 26908,
3+
"a.out.js.gz": 11463,
44
"a.out.nodebug.wasm": 18567,
55
"a.out.nodebug.wasm.gz": 9199,
6-
"total": 45498,
7-
"total_gz": 20671,
6+
"total": 45475,
7+
"total_gz": 20662,
88
"sent": [
99
"__heap_base",
1010
"__indirect_function_table",

test/codesize/test_codesize_hello_dylink_all.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"a.out.js": 245841,
2+
"a.out.js": 245818,
33
"a.out.nodebug.wasm": 597746,
4-
"total": 843587,
4+
"total": 843564,
55
"sent": [
66
"IMG_Init",
77
"IMG_Load",

test/test_other.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,6 +2015,9 @@ def test_exclude_file(self):
20152015
def test_dylink_strict(self):
20162016
self.do_run_in_out_file_test('hello_world.c', cflags=['-sSTRICT', '-sMAIN_MODULE=1'])
20172017

2018+
def test_dylink_legacy(self):
2019+
self.do_run_in_out_file_test('hello_world.c', cflags=['-sLEGACY_GL_EMULATION', '-sMAIN_MODULE=2'])
2020+
20182021
def test_dylink_exceptions_and_assertions(self):
20192022
# Linking side modules using the STL and exceptions should not abort with
20202023
# "function in Table but not functionsInTableMap" when using ASSERTIONS=2

tools/feature_matrix.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232

3333
class Feature(IntEnum):
34+
MUTABLE_GLOBALS = auto()
3435
NON_TRAPPING_FPTOINT = auto()
3536
SIGN_EXT = auto()
3637
BULK_MEMORY = auto()
@@ -48,6 +49,12 @@ class Feature(IntEnum):
4849
enable_override_features = set()
4950

5051
min_browser_versions = {
52+
Feature.MUTABLE_GLOBALS: {
53+
'chrome': 74,
54+
'firefox': 61,
55+
'safari': 130100,
56+
'node': 120000,
57+
},
5158
Feature.NON_TRAPPING_FPTOINT: {
5259
'chrome': 75,
5360
'firefox': 65,
@@ -213,6 +220,8 @@ def apply_min_browser_versions():
213220
enable_feature(Feature.BULK_MEMORY, 'pthreads')
214221
elif settings.WASM_WORKERS or settings.SHARED_MEMORY:
215222
enable_feature(Feature.BULK_MEMORY, 'shared-mem')
223+
if settings.RELOCATABLE:
224+
enable_feature(Feature.MUTABLE_GLOBALS, 'dynamic linking')
216225
if settings.MEMORY64 == 1:
217226
enable_feature(Feature.MEMORY64, 'MEMORY64')
218227
if settings.EXPORT_ES6 and settings.PTHREADS:

0 commit comments

Comments
 (0)