@@ -1259,6 +1259,13 @@ def consume_arg_file():
12591259 if is_int (requested_level ):
12601260 # the -gX value is the debug level (-g1, -g2, etc.)
12611261 settings .DEBUG_LEVEL = validate_arg_level (requested_level , 4 , 'invalid debug level: ' + arg )
1262+ if settings .DEBUG_LEVEL == 0 :
1263+ # Set these explicitly so -g0 overrides previous -g on the cmdline
1264+ settings .GENERATE_DWARF = 0
1265+ settings .GENERATE_SOURCE_MAP = 0
1266+ settings .EMIT_NAME_SECTION = 0
1267+ elif settings .DEBUG_LEVEL > 1 :
1268+ settings .EMIT_NAME_SECTION = 1
12621269 # if we don't need to preserve LLVM debug info, do not keep this flag
12631270 # for clang
12641271 if settings .DEBUG_LEVEL < 3 :
@@ -1289,17 +1296,20 @@ def consume_arg_file():
12891296 settings .GENERATE_DWARF = 1
12901297 elif requested_level == 'source-map' :
12911298 settings .GENERATE_SOURCE_MAP = 1
1299+ settings .EMIT_NAME_SECTION = 1
12921300 newargs [i ] = '-g'
12931301 else :
12941302 # Other non-integer levels (e.g. -gline-tables-only or -gdwarf-5) are
12951303 # usually clang flags that emit DWARF. So we pass them through to
12961304 # clang and make the emscripten code treat it like any other DWARF.
12971305 settings .GENERATE_DWARF = 1
1306+ settings .EMIT_NAME_SECTION = 1
12981307 # In all cases set the emscripten debug level to 3 so that we do not
12991308 # strip during link (during compile, this does not make a difference).
13001309 settings .DEBUG_LEVEL = 3
13011310 elif check_flag ('-profiling' ) or check_flag ('--profiling' ):
13021311 settings .DEBUG_LEVEL = max (settings .DEBUG_LEVEL , 2 )
1312+ settings .EMIT_NAME_SECTION = 1
13031313 elif check_flag ('-profiling-funcs' ) or check_flag ('--profiling-funcs' ):
13041314 settings .EMIT_NAME_SECTION = 1
13051315 elif newargs [i ] == '--tracing' or newargs [i ] == '--memoryprofiler' :
0 commit comments