Skip to content

Commit 5a8e1e8

Browse files
authored
Remove the 'ENVIRONMENT=worker implies ENVIRONMENT=web' assumption (#25514)
Remove the 'ENVIRONMENT=worker implies ENVIRONMENT=web' assumption. Fixes #25414 (review). Add test to verify the expectation mentioned in that comment.
1 parent 9d98f81 commit 5a8e1e8

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

ChangeLog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ See docs/process.md for more on how version tagging works.
2525
- Firefox: v65 -> v68
2626
- For windows users, colored console output for error messages and logging now
2727
requires Windows 10 or above. (#25502)
28+
- Fixed an issue from previous release 4.0.16 where "-sENVIRONMENT=worker" was
29+
erroneously made to imply "-sENVIRONMENT=web,worker" (#25514)
30+
- Passing '-sENVIRONMENT=worker' is now disallowed due to being ambiguous in
31+
its meaning. Instead, use '-sENVIRONMENT=web,worker' or
32+
'-sENVIRONMENT=node,worker' to refer to either Web or Node.js multithreading.
2833

2934
4.0.16 - 10/07/25
3035
-----------------

test/test_other.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14395,6 +14395,15 @@ def test_double_disable_environment(self):
1439514395
self.run_process([EMCC, test_file('hello_world.c'), '-Werror', '-sENVIRONMENT=node', '-sMIN_CHROME_VERSION=-1'])
1439614396
self.run_process([EMCC, test_file('hello_world.c'), '-Werror', '-sENVIRONMENT=node', '-sMIN_SAFARI_VERSION=-1'])
1439714397

14398+
# Test that passing "-sENVIRONMENT=node -pthread" will generate code that only targets Node.js multithreading, and
14399+
# does not pull in code that supports browser multithreading.
14400+
def test_only_target_node_pthreads(self):
14401+
self.run_process([EMCC, test_file('hello_world.c'), '-Werror', '-sENVIRONMENT=node', '-pthread'])
14402+
content = read_file('a.out.js')
14403+
self.assertContained('This page was compiled without support for Safari browser', content)
14404+
self.assertContained('This page was compiled without support for Firefox browser', content)
14405+
self.assertContained('This page was compiled without support for Chrome browser', content)
14406+
1439814407
def test_signext_lowering(self):
1439914408
# Use `-v` to show the sub-commands being run by emcc.
1440014409
cmd = [EMCC, test_file('other/test_signext_lowering.c'), '-v']

tools/link.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,16 @@ def setup_environment_settings():
165165
# The worker environment is automatically added if any of the pthread or Worker features are used.
166166
# Note: we need to actually modify ENVIRONMENTS variable here before the parsing,
167167
# because some JS code reads it back so modifying parsed info alone is not sufficient.
168+
maybe_web_worker = not settings.ENVIRONMENT or 'worker' in settings.ENVIRONMENT
169+
168170
if settings.SHARED_MEMORY and settings.ENVIRONMENT:
169171
settings.ENVIRONMENT.append('worker')
170172

171173
# Environment setting based on user input
172174
if any(x for x in settings.ENVIRONMENT if x not in VALID_ENVIRONMENTS):
173175
exit_with_error(f'Invalid environment specified in "ENVIRONMENT": {settings.ENVIRONMENT}. Should be one of: {",".join(VALID_ENVIRONMENTS)}')
174176

175-
settings.ENVIRONMENT_MAY_BE_WEB = not settings.ENVIRONMENT or 'web' in settings.ENVIRONMENT or 'worker' in settings.ENVIRONMENT
177+
settings.ENVIRONMENT_MAY_BE_WEB = not settings.ENVIRONMENT or 'web' in settings.ENVIRONMENT
176178
settings.ENVIRONMENT_MAY_BE_WEBVIEW = not settings.ENVIRONMENT or 'webview' in settings.ENVIRONMENT
177179
settings.ENVIRONMENT_MAY_BE_NODE = not settings.ENVIRONMENT or 'node' in settings.ENVIRONMENT
178180
settings.ENVIRONMENT_MAY_BE_SHELL = not settings.ENVIRONMENT or 'shell' in settings.ENVIRONMENT
@@ -183,11 +185,11 @@ def setup_environment_settings():
183185
diagnostics.warning('unused-command-line-argument', 'ignoring MIN_NODE_VERSION because `node` environment is not enabled')
184186
settings.MIN_NODE_VERSION = feature_matrix.UNSUPPORTED
185187

186-
if not (settings.ENVIRONMENT_MAY_BE_WEB or settings.ENVIRONMENT_MAY_BE_WEBVIEW):
188+
if not (settings.ENVIRONMENT_MAY_BE_WEB or maybe_web_worker or settings.ENVIRONMENT_MAY_BE_WEBVIEW):
187189
for browser in ('FIREFOX', 'SAFARI', 'CHROME'):
188190
key = f'MIN_{browser}_VERSION'
189191
if key in user_settings and settings[key] != feature_matrix.UNSUPPORTED:
190-
diagnostics.warning('unused-command-line-argument', 'ignoring %s because `web` and `webview` environments are not enabled', key)
192+
diagnostics.warning('unused-command-line-argument', 'ignoring %s because `web`, `worker` and `webview` environments are not enabled', key)
191193
settings[key] = feature_matrix.UNSUPPORTED
192194

193195

0 commit comments

Comments
 (0)