Skip to content

Commit dfb9e50

Browse files
committed
prepare for landing before feature update
1 parent 9257c5b commit dfb9e50

File tree

6 files changed

+35
-37
lines changed

6 files changed

+35
-37
lines changed

emcc.py

+7-13
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
from subprocess import PIPE
3636

3737

38-
from tools import shared, system_libs, utils, ports, feature_matrix
38+
from tools import shared, system_libs, utils, ports
3939
from tools import colored_logger, diagnostics, building
4040
from tools.shared import unsuffixed, unsuffixed_basename, get_file_suffix
4141
from tools.shared import run_process, exit_with_error, DEBUG
@@ -383,6 +383,12 @@ def get_clang_flags(user_args):
383383
flags.append('-matomics')
384384
if '-mbulk-memory' not in user_args:
385385
flags.append('-mbulk-memory')
386+
elif '-mbulk-memory' not in user_args and '-mno-bulk-memory' not in user_args:
387+
# Bulk memory may be enabled via threads or directly via -s.
388+
if not settings.BULK_MEMORY:
389+
flags.append('-mno-bulk-memory')
390+
if '-mnontrapping-fptoint' not in user_args and '-mno-nontrapping-fptoint' not in user_args:
391+
flags.append('-mno-nontrapping-fptoint')
386392

387393
if settings.RELOCATABLE and '-fPIC' not in user_args:
388394
flags.append('-fPIC')
@@ -854,18 +860,6 @@ def phase_setup(options, state, newargs):
854860
if settings.SHARED_MEMORY:
855861
settings.BULK_MEMORY = 1
856862

857-
if '-mbulk-memory' not in newargs and '-mno-bulk-memory' not in newargs:
858-
if feature_matrix.caniuse(feature_matrix.Feature.BULK_MEMORY):
859-
newargs += ['-mbulk-memory']
860-
settings.BULK_MEMORY = 1
861-
else:
862-
newargs += ['-mno-bulk-memory']
863-
if '-mnontrapping-fptoint' not in newargs and '-mno-nontrapping-fptoint' not in newargs:
864-
if feature_matrix.caniuse(feature_matrix.Feature.NON_TRAPPING_FPTOINT):
865-
newargs += ['-mnontrapping-fptoint']
866-
else:
867-
newargs += ['-mno-nontrapping-fptoint']
868-
869863
if 'DISABLE_EXCEPTION_CATCHING' in user_settings and 'EXCEPTION_CATCHING_ALLOWED' in user_settings:
870864
# If we get here then the user specified both DISABLE_EXCEPTION_CATCHING and EXCEPTION_CATCHING_ALLOWED
871865
# on the command line. This is no longer valid so report either an error or a warning (for

test/test_core.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4625,7 +4625,7 @@ def test_dylink_postsets_chunking(self):
46254625

46264626
@with_dylink_reversed
46274627
@parameterized({
4628-
'libcxx': ('libc,libc++,libmalloc,libc++abi,libbulkmemory',),
4628+
'libcxx': ('libc,libc++,libmalloc,libc++abi',),
46294629
'all': ('1',),
46304630
'missing': ('libc,libmalloc,libc++abi', False, False, False),
46314631
'missing_assertions': ('libc,libmalloc,libc++abi', False, False, True),

test/test_other.py

+25-17
Original file line numberDiff line numberDiff line change
@@ -8370,7 +8370,7 @@ def test_binaryen_warn_mem(self):
83708370
self.run_process([EMCC, test_file('hello_world.c'), '-sINITIAL_MEMORY=' + str(16 * 1024 * 1024), '--pre-js', 'pre.js', '-sWASM_ASYNC_COMPILATION=0', '-sIMPORTED_MEMORY'])
83718371
out = self.run_js('a.out.js', assert_returncode=NON_ZERO)
83728372
self.assertContained('LinkError', out)
8373-
self.assertContained("memory import 1 has a larger maximum size 800 than the module's declared maximum", out)
8373+
self.assertContained("memory import 2 has a larger maximum size 800 than the module's declared maximum", out)
83748374
self.assertNotContained('hello, world!', out)
83758375
# and with memory growth, all should be good
83768376
self.run_process([EMCC, test_file('hello_world.c'), '-sINITIAL_MEMORY=' + str(16 * 1024 * 1024), '--pre-js', 'pre.js', '-sALLOW_MEMORY_GROWTH', '-sWASM_ASYNC_COMPILATION=0', '-sIMPORTED_MEMORY'])
@@ -10270,37 +10270,45 @@ def test_wasm_features_section(self, args):
1027010270

1027110271
def test_wasm_features(self):
1027210272
# Test that wasm features are explicitly enabled or disabled based on target engine version
10273-
def verify_features_sec(feature, expect_in):
10274-
with webassembly.Module('hello_world.o') as module:
10273+
def verify_features_sec(feature, expect_in, linked=False):
10274+
with webassembly.Module('a.out.wasm' if linked else 'hello_world.o') as module:
1027510275
features = module.get_target_features()
1027610276
if expect_in:
10277-
self.assertTrue(feature in features and features[feature] == webassembly.TargetFeaturePrefix.USED)
10277+
self.assertTrue(feature in features and
10278+
features[feature] == webassembly.TargetFeaturePrefix.USED,
10279+
f'{feature} missing from wasm file')
1027810280
else:
10279-
self.assertFalse(feature in features)
10281+
self.assertFalse(feature in features,
10282+
f'{feature} unexpectedly found in wasm file')
10283+
10284+
def verify_features_sec_linked(feature, expect_in):
10285+
return verify_features_sec(feature, expect_in, linked=True)
1028010286

1028110287
def compile(flags):
10282-
self.run_process([EMCC, test_file('hello_world.c'), '-c'] + flags)
10288+
self.run_process([EMCC, test_file('hello_world.c')] + flags)
1028310289

10284-
compile([])
10290+
compile(['-c'])
1028510291
verify_features_sec('bulk-memory', False)
1028610292
verify_features_sec('nontrapping-fptoint', False)
1028710293
verify_features_sec('sign-ext', True)
1028810294
verify_features_sec('mutable-globals', True)
1028910295
verify_features_sec('multivalue', True)
1029010296
verify_features_sec('reference-types', True)
1029110297

10292-
compile(['-mnontrapping-fptoint'])
10298+
compile(['-mnontrapping-fptoint', '-c'])
1029310299
verify_features_sec('nontrapping-fptoint', True)
1029410300

10295-
compile(['-sMIN_SAFARI_VERSION=150000'])
10296-
verify_features_sec('sign-ext', True)
10297-
verify_features_sec('mutable-globals', True)
10298-
verify_features_sec('multivalue', True)
10299-
verify_features_sec('bulk-memory', True)
10300-
verify_features_sec('nontrapping-fptoint', True)
10301+
# BIGINT causes binaryen to not run, and keeps the target_features section
10302+
compile(['-sMIN_SAFARI_VERSION=150000', '-sWASM_BIGINT'])
10303+
verify_features_sec_linked('sign-ext', True)
10304+
verify_features_sec_linked('mutable-globals', True)
10305+
verify_features_sec_linked('multivalue', True)
10306+
verify_features_sec_linked('bulk-memory', True)
10307+
verify_features_sec_linked('nontrapping-fptoint', False)
1030110308

10302-
compile(['-sMIN_SAFARI_VERSION=150000', '-mno-bulk-memory'])
10303-
verify_features_sec('bulk-memory', False)
10309+
compile(['-sMIN_SAFARI_VERSION=150000', '-mno-bulk-memory', '-sWASM_BIGINT'])
10310+
# FIXME? -mno-bulk-memory at link time does not override MIN_SAFARI_VERSION. it probably should?
10311+
verify_features_sec_linked('bulk-memory', True)
1030410312

1030510313
def test_js_preprocess(self):
1030610314
# Use stderr rather than stdout here because stdout is redirected to the output JS file itself.
@@ -12850,7 +12858,7 @@ def test_split_module(self, customLoader, jspi):
1285012858
self.assertExists('profile.data')
1285112859

1285212860
wasm_split = os.path.join(building.get_binaryen_bin(), 'wasm-split')
12853-
wasm_split_run = [wasm_split, '-g', '--enable-mutable-globals', '--enable-bulk-memory', '--export-prefix=%', 'test_split_module.wasm.orig', '-o1', 'primary.wasm', '-o2', 'secondary.wasm', '--profile=profile.data']
12861+
wasm_split_run = [wasm_split, '-g', '--enable-mutable-globals', '--export-prefix=%', 'test_split_module.wasm.orig', '-o1', 'primary.wasm', '-o2', 'secondary.wasm', '--profile=profile.data']
1285412862
if jspi:
1285512863
wasm_split_run += ['--jspi', '--enable-reference-types']
1285612864
self.run_process(wasm_split_run)

tools/feature_matrix.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class Feature(IntEnum):
5454
Feature.BULK_MEMORY: {
5555
'chrome': 75,
5656
'firefox': 79,
57-
'safari': 140000,
57+
'safari': 150000,
5858
},
5959
Feature.MUTABLE_GLOBALS: {
6060
'chrome': 74,

tools/maybe_wasm2js.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

4242
# main
4343

44-
cmd = [os.path.join(building.get_binaryen_bin(), 'wasm2js'), '--emscripten', '--enable-bulk-memory', wasm_file]
44+
cmd = [os.path.join(building.get_binaryen_bin(), 'wasm2js'), '--emscripten', wasm_file]
4545
cmd += opts
4646
js = shared.run_process(cmd, stdout=subprocess.PIPE).stdout
4747
# assign the instantiate function to where it will be used

tools/settings.py

-4
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,6 @@
9696
'WASM_OBJECT_FILES',
9797
'WASM_WORKERS',
9898
'BULK_MEMORY',
99-
'MIN_SAFARI_VERSION',
100-
'MIN_CHROME_VERSION',
101-
'MIN_FIREFOX_VERSION',
102-
'MIN_NODE_VERSION',
10399

104100
# Internal settings used during compilation
105101
'EXCEPTION_CATCHING_ALLOWED',

0 commit comments

Comments
 (0)