Skip to content

Commit

Permalink
Add list of JS-only settings
Browse files Browse the repository at this point in the history
  • Loading branch information
sbc100 committed Jan 4, 2024
1 parent aa88b69 commit 7506c70
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ See docs/process.md for more on how version tagging works.

3.1.52 (in development)
-----------------------
- Certain settings that only apply when generating JavaScript output will now
trigger a warning if used when generating only Wasm.
- Fix bug where `main` was mistakenly included in debug builds but not in
release builds. (#20971)
- Remove JAVA from the list of `.emscripten` config file settings. In the
Expand Down
4 changes: 4 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -14414,3 +14414,7 @@ def test_no_extra_output(self):
def test_browser_too_old(self):
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sMIN_CHROME_VERSION=10'])
self.assertContained('emcc: error: MIN_CHROME_VERSION older than 32 is not supported', err)

def test_js_only_settings(self):
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
self.assertContained('emcc: warning: DEFAULT_LIBRARY_FUNCS_TO_INCLUDE is only valid when generated JavaScript output', err)
7 changes: 6 additions & 1 deletion tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
from .shared import in_temp, safe_copy, do_replace, run_process, OFormat
from .shared import DEBUG, WINDOWS, DYNAMICLIB_ENDINGS, STATICLIB_ENDINGS
from .shared import unsuffixed, unsuffixed_basename, get_file_suffix
from .settings import settings, default_setting, user_settings
from .settings import settings, default_setting, user_settings, JS_ONLY_SETTINGS
from .minimal_runtime_shell import generate_minimal_runtime_html

import tools.line_endings
Expand Down Expand Up @@ -753,6 +753,11 @@ def phase_linker_setup(options, state, newargs):
else:
options.oformat = OFormat.JS

if options.oformat in (OFormat.WASM, OFormat.OBJECT):
for s in JS_ONLY_SETTINGS:
if s in user_settings:
diagnostics.warning('unused-command-line-argument', f'{s} is only valid when generated JavaScript output')

if options.oformat == OFormat.MJS:
settings.EXPORT_ES6 = 1
settings.MODULARIZE = 1
Expand Down
21 changes: 21 additions & 0 deletions tools/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,27 @@
'USE_SQLITE3',
}

# Subset of settings that apply only when generating JS
JS_ONLY_SETTINGS = {
'DEFAULT_LIBRARY_FUNCS_TO_INCLUDE',
'INCLUDE_FULL_LIBRARY',
'PROXY_TO_WORKER',
'PROXY_TO_WORKER_FILENAME',
'BUILD_AS_WORKER',
'STRICT_JS',
'SMALL_XHR_CHUNKS',
'HEADLESS',
'MODULARIZE',
'EXPORT_ES6',
'USE_ES6_IMPORT_META',
'EXPORT_NAME',
'DYNAMIC_EXECUTION',
'PTHREAD_POOL_SIZE',
'PTHREAD_POOL_SIZE_STRICT',
'PTHREAD_POOL_DELAY_LOAD',
'DEFAULT_PTHREAD_STACK_SIZE',
}

# Subset of settings that apply at compile time.
# (Keep in sync with [compile] comments in settings.js)
COMPILE_TIME_SETTINGS = {
Expand Down

0 comments on commit 7506c70

Please sign in to comment.