Skip to content

Commit 955a87f

Browse files
authored
Add list of JS-only settings (#21004)
1 parent 2c95109 commit 955a87f

File tree

6 files changed

+40
-11
lines changed

6 files changed

+40
-11
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ See docs/process.md for more on how version tagging works.
2020

2121
3.1.52 (in development)
2222
-----------------------
23+
- Certain settings that only apply when generating JavaScript output will now
24+
trigger a warning if used when generating only Wasm.
2325
- Fix bug where `main` was mistakenly included in debug builds but not in
2426
release builds. (#20971)
2527
- Remove JAVA from the list of `.emscripten` config file settings. In the

test/test_browser.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3777,9 +3777,6 @@ def test_dlopen_blocking(self):
37773777
})
37783778
def test_dylink_dso_needed(self, inworker):
37793779
self.emcc_args += ['-O2']
3780-
# --proxy-to-worker only on main
3781-
if inworker:
3782-
self.emcc_args += ['--proxy-to-worker']
37833780

37843781
def do_run(src, expected_output, emcc_args):
37853782
# XXX there is no infrastructure (yet ?) to retrieve stdout from browser in tests.
@@ -3809,6 +3806,9 @@ def do_run(src, expected_output, emcc_args):
38093806
return rtn;
38103807
}
38113808
''' % expected_output)
3809+
# --proxy-to-worker only on main
3810+
if inworker:
3811+
emcc_args += ['--proxy-to-worker']
38123812
self.btest_exit(self.in_dir('test_dylink_dso_needed.c'), args=['--post-js', 'post.js'] + emcc_args)
38133813

38143814
self._test_dylink_dso_needed(do_run)

test/test_core.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9257,7 +9257,6 @@ def test_pthread_dylink_basics(self):
92579257
@node_pthreads
92589258
def test_pthread_dylink(self):
92599259
self.emcc_args += ['-Wno-experimental', '-pthread']
9260-
self.set_setting('PTHREAD_POOL_SIZE', 2)
92619260
main = test_file('core/pthread/test_pthread_dylink.c')
92629261

92639262
# test with a long .so name, as a regression test for
@@ -9266,6 +9265,7 @@ def test_pthread_dylink(self):
92669265
very_long_name = 'very_very_very_very_very_very_very_very_very_long.so'
92679266

92689267
self.dylink_testf(main, so_name=very_long_name,
9268+
main_emcc_args=['-sPTHREAD_POOL_SIZE=2'],
92699269
need_reverse=False)
92709270

92719271
@parameterized({
@@ -9276,9 +9276,8 @@ def test_pthread_dylink(self):
92769276
@node_pthreads
92779277
def test_pthread_dylink_entry_point(self, args):
92789278
self.emcc_args += ['-Wno-experimental', '-pthread']
9279-
self.set_setting('PTHREAD_POOL_SIZE', 1)
92809279
main = test_file('core/pthread/test_pthread_dylink_entry_point.c')
9281-
self.dylink_testf(main, need_reverse=False, emcc_args=args)
9280+
self.dylink_testf(main, need_reverse=False, emcc_args=args, main_emcc_args=['-sPTHREAD_POOL_SIZE=1'])
92829281

92839282
@needs_dylink
92849283
@node_pthreads
@@ -9344,17 +9343,15 @@ def test_pthread_dlsym(self):
93449343
@node_pthreads
93459344
def test_pthread_dylink_tls(self):
93469345
self.emcc_args += ['-Wno-experimental', '-pthread']
9347-
self.set_setting('PTHREAD_POOL_SIZE', 1)
93489346
main = test_file('core/pthread/test_pthread_dylink_tls.c')
9349-
self.dylink_testf(main, need_reverse=False)
9347+
self.dylink_testf(main, need_reverse=False, main_emcc_args=['-sPTHREAD_POOL_SIZE=1'])
93509348

93519349
@needs_dylink
93529350
@node_pthreads
93539351
def test_pthread_dylink_longjmp(self):
93549352
self.emcc_args += ['-Wno-experimental', '-pthread']
9355-
self.set_setting('PTHREAD_POOL_SIZE=1')
93569353
main = test_file('core/pthread/test_pthread_dylink_longjmp.c')
9357-
self.dylink_testf(main, need_reverse=False)
9354+
self.dylink_testf(main, need_reverse=False, main_emcc_args=['-sPTHREAD_POOL_SIZE=1'])
93589355

93599356
@needs_dylink
93609357
@node_pthreads

test/test_other.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14405,3 +14405,7 @@ def test_no_extra_output(self):
1440514405
def test_browser_too_old(self):
1440614406
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sMIN_CHROME_VERSION=10'])
1440714407
self.assertContained('emcc: error: MIN_CHROME_VERSION older than 32 is not supported', err)
14408+
14409+
def test_js_only_settings(self):
14410+
err = self.run_process([EMCC, test_file('hello_world.c'), '-o', 'foo.wasm', '-sDEFAULT_LIBRARY_FUNCS_TO_INCLUDE=emscripten_get_heap_max'], stderr=PIPE).stderr
14411+
self.assertContained('emcc: warning: DEFAULT_LIBRARY_FUNCS_TO_INCLUDE is only valid when generating JavaScript output', err)

tools/link.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
from .shared import in_temp, safe_copy, do_replace, run_process, OFormat
3939
from .shared import DEBUG, WINDOWS, DYNAMICLIB_ENDINGS, STATICLIB_ENDINGS
4040
from .shared import unsuffixed, unsuffixed_basename, get_file_suffix
41-
from .settings import settings, default_setting, user_settings
41+
from .settings import settings, default_setting, user_settings, JS_ONLY_SETTINGS
4242
from .minimal_runtime_shell import generate_minimal_runtime_html
4343

4444
import tools.line_endings
@@ -753,6 +753,11 @@ def phase_linker_setup(options, state, newargs):
753753
else:
754754
options.oformat = OFormat.JS
755755

756+
if options.oformat in (OFormat.WASM, OFormat.OBJECT):
757+
for s in JS_ONLY_SETTINGS:
758+
if s in user_settings:
759+
diagnostics.warning('unused-command-line-argument', f'{s} is only valid when generating JavaScript output')
760+
756761
if options.oformat == OFormat.MJS:
757762
settings.EXPORT_ES6 = 1
758763
settings.MODULARIZE = 1

tools/settings.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,27 @@
5454
'USE_SQLITE3',
5555
}
5656

57+
# Subset of settings that apply only when generating JS
58+
JS_ONLY_SETTINGS = {
59+
'DEFAULT_LIBRARY_FUNCS_TO_INCLUDE',
60+
'INCLUDE_FULL_LIBRARY',
61+
'PROXY_TO_WORKER',
62+
'PROXY_TO_WORKER_FILENAME',
63+
'BUILD_AS_WORKER',
64+
'STRICT_JS',
65+
'SMALL_XHR_CHUNKS',
66+
'HEADLESS',
67+
'MODULARIZE',
68+
'EXPORT_ES6',
69+
'USE_ES6_IMPORT_META',
70+
'EXPORT_NAME',
71+
'DYNAMIC_EXECUTION',
72+
'PTHREAD_POOL_SIZE',
73+
'PTHREAD_POOL_SIZE_STRICT',
74+
'PTHREAD_POOL_DELAY_LOAD',
75+
'DEFAULT_PTHREAD_STACK_SIZE',
76+
}
77+
5778
# Subset of settings that apply at compile time.
5879
# (Keep in sync with [compile] comments in settings.js)
5980
COMPILE_TIME_SETTINGS = {

0 commit comments

Comments
 (0)