Skip to content

Commit c02781e

Browse files
committed
Move BINARYEN_PASSES out of settings_internal.js. NFC
I'm making an effort to remove stuff from `settings_internal.js` unless its specifically needed by the JS compiler. We might want to invent a new place for such python global state but we I think we can add this organically, over time.
1 parent b9ebd4d commit c02781e

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

src/settings_internal.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,6 @@ var TARGET_JS_NAME = '';
5757
// never used, then we don't actually need to support operations on streams.
5858
var SYSCALLS_REQUIRE_FILESYSTEM = true;
5959

60-
// A list of feature flags to pass to each binaryen invocation (like wasm-opt,
61-
// etc.). This is received from wasm-emscripten-finalize, which reads it from
62-
// the features section.
63-
var BINARYEN_FEATURES = [];
64-
6560
// Whether EMCC_AUTODEBUG is on, which automatically instruments code for
6661
// runtime logging that can help in debugging.
6762
var AUTODEBUG = false;

tools/building.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
import subprocess
1414
import sys
1515
from subprocess import PIPE
16-
from typing import Dict, Set
16+
from typing import Dict, List, Set
1717

1818
from . import (
1919
cache,
@@ -59,6 +59,10 @@
5959
_is_ar_cache: Dict[str, bool] = {}
6060
# the exports the user requested
6161
user_requested_exports: Set[str] = set()
62+
# A list of feature flags to pass to each binaryen invocation (like `wasm-opt`,
63+
# etc.). This is received by the first call to binaryen (e.g. `wasm-emscripten-finalize`)
64+
# which reads it using `--detect-features`.
65+
binaryen_features: List[str] = []
6266

6367

6468
def get_building_env():
@@ -1187,10 +1191,10 @@ def emit_wasm_source_map(wasm_file, map_file, final_wasm):
11871191

11881192

11891193
def get_binaryen_feature_flags():
1190-
# settings.BINARYEN_FEATURES is empty unless features have been extracted by
1191-
# wasm-emscripten-finalize already.
1192-
if settings.BINARYEN_FEATURES:
1193-
return settings.BINARYEN_FEATURES
1194+
# `binaryen_features` is empty unless features have been extracted by
1195+
# a previous call to a binaryen tool.
1196+
if binaryen_features:
1197+
return binaryen_features
11941198
else:
11951199
return ['--detect-features']
11961200

tools/emscripten.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,14 @@ def update_settings_glue(wasm_file, metadata, base_metadata):
116116
settings.HAVE_EM_ASM = bool(settings.MAIN_MODULE or len(metadata.em_asm_consts) != 0)
117117

118118
# start with the MVP features, and add any detected features.
119-
settings.BINARYEN_FEATURES = ['--mvp-features'] + metadata.features
119+
building.binaryen_features = ['--mvp-features'] + metadata.features
120120
if settings.ASYNCIFY == 2:
121-
settings.BINARYEN_FEATURES += ['--enable-reference-types']
121+
building.binaryen_features += ['--enable-reference-types']
122122

123123
if settings.PTHREADS:
124-
assert '--enable-threads' in settings.BINARYEN_FEATURES
124+
assert '--enable-threads' in building.binaryen_features
125125
if settings.MEMORY64:
126-
assert '--enable-memory64' in settings.BINARYEN_FEATURES
126+
assert '--enable-memory64' in building.binaryen_features
127127

128128
settings.HAS_MAIN = bool(settings.MAIN_MODULE) or settings.PROXY_TO_PTHREAD or settings.STANDALONE_WASM or 'main' in settings.WASM_EXPORTS or '__main_argc_argv' in settings.WASM_EXPORTS
129129
if settings.HAS_MAIN and not settings.MINIMAL_RUNTIME:

0 commit comments

Comments
 (0)