54
54
from tools import webassembly
55
55
from tools import config
56
56
from 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
58
58
from tools .utils import read_file , write_file , read_binary , delete_file , removeprefix
59
59
60
60
logger = logging .getLogger ('emcc' )
@@ -417,15 +417,15 @@ def default_setting(name, new_default):
417
417
setattr (settings , name , new_default )
418
418
419
419
420
- def apply_user_settings ( ):
420
+ def apply_setting ( cmdline_settings ):
421
421
"""Take a map of users settings {NAME: VALUE} and apply them to the global
422
422
settings object.
423
423
"""
424
424
425
425
# Stash a copy of all available incoming APIs before the user can potentially override it
426
426
settings .ALL_INCOMING_MODULE_JS_API = settings .INCOMING_MODULE_JS_API + EXTRA_INCOMING_JS_API
427
427
428
- for key , value in user_settings . items () :
428
+ for key , value in cmdline_settings :
429
429
if key in settings .internal_settings :
430
430
exit_with_error ('%s is an internal setting and cannot be set from command line' , key )
431
431
@@ -459,6 +459,10 @@ def apply_user_settings():
459
459
except Exception as e :
460
460
exit_with_error ('a problem occurred in evaluating the content after a "-s", specifically "%s=%s": %s' , key , value , str (e ))
461
461
462
+ if key in APPENDING_SETTINGS :
463
+ value += getattr (settings , key )
464
+
465
+ user_settings [user_key ] = value
462
466
setattr (settings , user_key , value )
463
467
464
468
if key == 'EXPORTED_FUNCTIONS' :
@@ -1426,23 +1430,22 @@ def phase_parse_arguments(state):
1426
1430
explicit_settings_changes , newargs = parse_s_args (newargs )
1427
1431
settings_changes += explicit_settings_changes
1428
1432
1433
+ cmdline_settings = []
1429
1434
for s in settings_changes :
1430
1435
key , value = s .split ('=' , 1 )
1431
1436
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 ))
1439
1442
1440
1443
# Apply user -jsD settings
1441
1444
for s in user_js_defines :
1442
1445
settings [s [0 ]] = s [1 ]
1443
1446
1444
1447
# Apply -s settings in newargs here (after optimization levels, so they can override them)
1445
- apply_user_settings ( )
1448
+ apply_setting ( cmdline_settings )
1446
1449
1447
1450
return options , newargs
1448
1451
@@ -1629,7 +1632,7 @@ def phase_setup(options, state, newargs):
1629
1632
# If we get here then the user specified both DISABLE_EXCEPTION_CATCHING and EXCEPTION_CATCHING_ALLOWED
1630
1633
# on the command line. This is no longer valid so report either an error or a warning (for
1631
1634
# 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 ):
1633
1636
diagnostics .warning ('deprecated' , 'DISABLE_EXCEPTION_CATCHING=X is no longer needed when specifying EXCEPTION_CATCHING_ALLOWED' )
1634
1637
else :
1635
1638
exit_with_error ('DISABLE_EXCEPTION_CATCHING and EXCEPTION_CATCHING_ALLOWED are mutually exclusive' )
@@ -1638,9 +1641,9 @@ def phase_setup(options, state, newargs):
1638
1641
settings .DISABLE_EXCEPTION_CATCHING = 0
1639
1642
1640
1643
if settings .WASM_EXCEPTIONS :
1641
- if user_settings .get ('DISABLE_EXCEPTION_CATCHING' ) == '0' :
1644
+ if user_settings .get ('DISABLE_EXCEPTION_CATCHING' ) == 0 :
1642
1645
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 :
1644
1647
exit_with_error ('DISABLE_EXCEPTION_THROWING=0 is not compatible with -fwasm-exceptions' )
1645
1648
# -fwasm-exceptions takes care of enabling them, so users aren't supposed to
1646
1649
# pass them explicitly, regardless of their values
@@ -1649,7 +1652,7 @@ def phase_setup(options, state, newargs):
1649
1652
settings .DISABLE_EXCEPTION_CATCHING = 1
1650
1653
settings .DISABLE_EXCEPTION_THROWING = 1
1651
1654
1652
- if user_settings .get ('ASYNCIFY' ) == '1' :
1655
+ if user_settings .get ('ASYNCIFY' ) == 1 :
1653
1656
diagnostics .warning ('emcc' , 'ASYNCIFY=1 is not compatible with -fwasm-exceptions. Parts of the program that mix ASYNCIFY and exceptions will not compile.' )
1654
1657
1655
1658
if user_settings .get ('SUPPORT_LONGJMP' ) == 'emscripten' :
@@ -1672,11 +1675,11 @@ def phase_setup(options, state, newargs):
1672
1675
# Wasm SjLj cannot be used with Emscripten EH. We error out if
1673
1676
# DISABLE_EXCEPTION_THROWING=0 is explicitly requested by the user;
1674
1677
# otherwise we disable it here.
1675
- if user_settings .get ('DISABLE_EXCEPTION_THROWING' ) == '0' :
1678
+ if user_settings .get ('DISABLE_EXCEPTION_THROWING' ) == 0 :
1676
1679
exit_with_error ('SUPPORT_LONGJMP=wasm cannot be used with DISABLE_EXCEPTION_THROWING=0' )
1677
1680
# We error out for DISABLE_EXCEPTION_CATCHING=0, because it is 1 by default
1678
1681
# 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 :
1680
1683
exit_with_error ('SUPPORT_LONGJMP=wasm cannot be used with DISABLE_EXCEPTION_CATCHING=0' )
1681
1684
default_setting ('DISABLE_EXCEPTION_THROWING' , 1 )
1682
1685
@@ -1991,7 +1994,7 @@ def phase_linker_setup(options, state, newargs):
1991
1994
1992
1995
# For users that opt out of WARN_ON_UNDEFINED_SYMBOLS we assume they also
1993
1996
# 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 :
1995
1998
default_setting ('ERROR_ON_UNDEFINED_SYMBOLS' , 0 )
1996
1999
1997
2000
# It is unlikely that developers targeting "native web" APIs with MINIMAL_RUNTIME need
0 commit comments