Skip to content

Commit 8262f2a

Browse files
authored
Fix -sMIN_NODE_VERSION=-1 -sENVIRONMENT=web to build without errors. (#25471)
Users might "double-disable" Node.js support by setting both `-sENVIRONMENT=web` (no Node.js), and `-sMIN_NODE_VERSION=-1` (set Node to unsupported). But Emscripten complained about this not being allowed. Let this combination pass.
1 parent a623177 commit 8262f2a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

test/test_other.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14338,6 +14338,13 @@ def test_min_browser_version(self):
1433814338
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-Wno-transpile', '-Werror', '-pthread', '-sMIN_FIREFOX_VERSION=65'])
1433914339
self.assertContained('emcc: error: MIN_FIREFOX_VERSION=65 is not compatible with pthreads (MIN_FIREFOX_VERSION=79 or above required)', err)
1434014340

14341+
# Test that using two different ways to disable a target environment at the same time will not produce a warning.
14342+
def test_double_disable_environment(self):
14343+
self.run_process([EMCC, test_file('hello_world.c'), '-Werror', '-sENVIRONMENT=web', '-sMIN_NODE_VERSION=-1'])
14344+
self.run_process([EMCC, test_file('hello_world.c'), '-Werror', '-sENVIRONMENT=node', '-sMIN_FIREFOX_VERSION=-1'])
14345+
self.run_process([EMCC, test_file('hello_world.c'), '-Werror', '-sENVIRONMENT=node', '-sMIN_CHROME_VERSION=-1'])
14346+
self.run_process([EMCC, test_file('hello_world.c'), '-Werror', '-sENVIRONMENT=node', '-sMIN_SAFARI_VERSION=-1'])
14347+
1434114348
def test_signext_lowering(self):
1434214349
# Use `-v` to show the sub-commands being run by emcc.
1434314350
cmd = [EMCC, test_file('other/test_signext_lowering.c'), '-v']

tools/link.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,14 @@ def setup_environment_settings():
179179
settings.ENVIRONMENT_MAY_BE_WORKER = not settings.ENVIRONMENT or 'worker' in settings.ENVIRONMENT
180180

181181
if not settings.ENVIRONMENT_MAY_BE_NODE:
182-
if 'MIN_NODE_VERSION' in user_settings:
182+
if 'MIN_NODE_VERSION' in user_settings and settings.MIN_NODE_VERSION != feature_matrix.UNSUPPORTED:
183183
diagnostics.warning('unused-command-line-argument', 'ignoring MIN_NODE_VERSION because `node` environment is not enabled')
184184
settings.MIN_NODE_VERSION = feature_matrix.UNSUPPORTED
185185

186186
if not (settings.ENVIRONMENT_MAY_BE_WEB or settings.ENVIRONMENT_MAY_BE_WEBVIEW):
187187
for browser in ('FIREFOX', 'SAFARI', 'CHROME'):
188188
key = f'MIN_{browser}_VERSION'
189-
if key in user_settings:
189+
if key in user_settings and settings[key] != feature_matrix.UNSUPPORTED:
190190
diagnostics.warning('unused-command-line-argument', 'ignoring %s because `web` and `webview` environments are not enabled', key)
191191
settings[key] = feature_matrix.UNSUPPORTED
192192

0 commit comments

Comments
 (0)