5454from tools import webassembly
5555from tools import config
5656from tools import cache
57- from tools .settings import user_settings , settings , MEM_SIZE_SETTINGS , COMPILE_TIME_SETTINGS
57+ from tools .settings import user_settings , settings , MEM_SIZE_SETTINGS , COMPILE_TIME_SETTINGS , APPENDING_SETTINGS
5858from tools .utils import read_file , write_file , read_binary , delete_file , removeprefix
5959
6060logger = logging .getLogger ('emcc' )
@@ -417,15 +417,15 @@ def default_setting(name, new_default):
417417 setattr (settings , name , new_default )
418418
419419
420- def apply_user_settings ( ):
420+ def apply_setting ( cmdline_settings ):
421421 """Take a map of users settings {NAME: VALUE} and apply them to the global
422422 settings object.
423423 """
424424
425425 # Stash a copy of all available incoming APIs before the user can potentially override it
426426 settings .ALL_INCOMING_MODULE_JS_API = settings .INCOMING_MODULE_JS_API + EXTRA_INCOMING_JS_API
427427
428- for key , value in user_settings . items () :
428+ for key , value in cmdline_settings :
429429 if key in settings .internal_settings :
430430 exit_with_error ('%s is an internal setting and cannot be set from command line' , key )
431431
@@ -459,6 +459,10 @@ def apply_user_settings():
459459 except Exception as e :
460460 exit_with_error ('a problem occurred in evaluating the content after a "-s", specifically "%s=%s": %s' , key , value , str (e ))
461461
462+ if key in APPENDING_SETTINGS :
463+ value += getattr (settings , key )
464+
465+ user_settings [user_key ] = value
462466 setattr (settings , user_key , value )
463467
464468 if key == 'EXPORTED_FUNCTIONS' :
@@ -1426,23 +1430,22 @@ def phase_parse_arguments(state):
14261430 explicit_settings_changes , newargs = parse_s_args (newargs )
14271431 settings_changes += explicit_settings_changes
14281432
1433+ cmdline_settings = []
14291434 for s in settings_changes :
14301435 key , value = s .split ('=' , 1 )
14311436 key , value = normalize_boolean_setting (key , value )
1432- user_settings [key ] = value
1433-
1434- # STRICT is used when applying settings so it needs to be applied first before
1435- # calling `apply_user_settings`.
1436- strict_cmdline = user_settings .get ('STRICT' )
1437- if strict_cmdline :
1438- settings .STRICT = int (strict_cmdline )
1437+ # STRICT is used when applying settings so it needs to be applied first before
1438+ # calling `apply_setting`.
1439+ if key == 'STRICT' and value :
1440+ settings .STRICT = int (value )
1441+ cmdline_settings .append ((key , value ))
14391442
14401443 # Apply user -jsD settings
14411444 for s in user_js_defines :
14421445 settings [s [0 ]] = s [1 ]
14431446
14441447 # Apply -s settings in newargs here (after optimization levels, so they can override them)
1445- apply_user_settings ( )
1448+ apply_setting ( cmdline_settings )
14461449
14471450 return options , newargs
14481451
@@ -1629,7 +1632,7 @@ def phase_setup(options, state, newargs):
16291632 # If we get here then the user specified both DISABLE_EXCEPTION_CATCHING and EXCEPTION_CATCHING_ALLOWED
16301633 # on the command line. This is no longer valid so report either an error or a warning (for
16311634 # backwards compat with the old `DISABLE_EXCEPTION_CATCHING=2`
1632- if user_settings ['DISABLE_EXCEPTION_CATCHING' ] in ('0' , '2' ):
1635+ if user_settings ['DISABLE_EXCEPTION_CATCHING' ] in (0 , 2 ):
16331636 diagnostics .warning ('deprecated' , 'DISABLE_EXCEPTION_CATCHING=X is no longer needed when specifying EXCEPTION_CATCHING_ALLOWED' )
16341637 else :
16351638 exit_with_error ('DISABLE_EXCEPTION_CATCHING and EXCEPTION_CATCHING_ALLOWED are mutually exclusive' )
@@ -1638,9 +1641,9 @@ def phase_setup(options, state, newargs):
16381641 settings .DISABLE_EXCEPTION_CATCHING = 0
16391642
16401643 if settings .WASM_EXCEPTIONS :
1641- if user_settings .get ('DISABLE_EXCEPTION_CATCHING' ) == '0' :
1644+ if user_settings .get ('DISABLE_EXCEPTION_CATCHING' ) == 0 :
16421645 exit_with_error ('DISABLE_EXCEPTION_CATCHING=0 is not compatible with -fwasm-exceptions' )
1643- if user_settings .get ('DISABLE_EXCEPTION_THROWING' ) == '0' :
1646+ if user_settings .get ('DISABLE_EXCEPTION_THROWING' ) == 0 :
16441647 exit_with_error ('DISABLE_EXCEPTION_THROWING=0 is not compatible with -fwasm-exceptions' )
16451648 # -fwasm-exceptions takes care of enabling them, so users aren't supposed to
16461649 # pass them explicitly, regardless of their values
@@ -1649,7 +1652,7 @@ def phase_setup(options, state, newargs):
16491652 settings .DISABLE_EXCEPTION_CATCHING = 1
16501653 settings .DISABLE_EXCEPTION_THROWING = 1
16511654
1652- if user_settings .get ('ASYNCIFY' ) == '1' :
1655+ if user_settings .get ('ASYNCIFY' ) == 1 :
16531656 diagnostics .warning ('emcc' , 'ASYNCIFY=1 is not compatible with -fwasm-exceptions. Parts of the program that mix ASYNCIFY and exceptions will not compile.' )
16541657
16551658 if user_settings .get ('SUPPORT_LONGJMP' ) == 'emscripten' :
@@ -1672,11 +1675,11 @@ def phase_setup(options, state, newargs):
16721675 # Wasm SjLj cannot be used with Emscripten EH. We error out if
16731676 # DISABLE_EXCEPTION_THROWING=0 is explicitly requested by the user;
16741677 # otherwise we disable it here.
1675- if user_settings .get ('DISABLE_EXCEPTION_THROWING' ) == '0' :
1678+ if user_settings .get ('DISABLE_EXCEPTION_THROWING' ) == 0 :
16761679 exit_with_error ('SUPPORT_LONGJMP=wasm cannot be used with DISABLE_EXCEPTION_THROWING=0' )
16771680 # We error out for DISABLE_EXCEPTION_CATCHING=0, because it is 1 by default
16781681 # and this can be 0 only if the user specifies so.
1679- if user_settings .get ('DISABLE_EXCEPTION_CATCHING' ) == '0' :
1682+ if user_settings .get ('DISABLE_EXCEPTION_CATCHING' ) == 0 :
16801683 exit_with_error ('SUPPORT_LONGJMP=wasm cannot be used with DISABLE_EXCEPTION_CATCHING=0' )
16811684 default_setting ('DISABLE_EXCEPTION_THROWING' , 1 )
16821685
@@ -1991,7 +1994,7 @@ def phase_linker_setup(options, state, newargs):
19911994
19921995 # For users that opt out of WARN_ON_UNDEFINED_SYMBOLS we assume they also
19931996 # want to opt out of ERROR_ON_UNDEFINED_SYMBOLS.
1994- if user_settings .get ('WARN_ON_UNDEFINED_SYMBOLS' ) == '0' :
1997+ if user_settings .get ('WARN_ON_UNDEFINED_SYMBOLS' ) == 0 :
19951998 default_setting ('ERROR_ON_UNDEFINED_SYMBOLS' , 0 )
19961999
19972000 # It is unlikely that developers targeting "native web" APIs with MINIMAL_RUNTIME need
0 commit comments