From 9ea9b4797c447b231800694e3b11f21bc365fc48 Mon Sep 17 00:00:00 2001 From: Ben Lubar Date: Sat, 9 Aug 2025 17:36:34 -0500 Subject: [PATCH] Fix debug symbols logic on platform=web to match Godot core. --- tools/common_compiler_flags.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/common_compiler_flags.py b/tools/common_compiler_flags.py index e645f390f..05f95d7a3 100644 --- a/tools/common_compiler_flags.py +++ b/tools/common_compiler_flags.py @@ -2,6 +2,10 @@ import subprocess +def using_emcc(env): + return "emcc" in os.path.basename(env["CC"]) + + def using_clang(env): return "clang" in os.path.basename(env["CC"]) @@ -89,7 +93,13 @@ def generate(env): # Adding dwarf-4 explicitly makes stacktraces work with clang builds, # otherwise addr2line doesn't understand them. env.Append(CCFLAGS=["-gdwarf-4"]) - if env.dev_build: + if using_emcc(env): + # Emscripten only produces dwarf symbols when using "-g3". + env.AppendUnique(CCFLAGS=["-g3"]) + # Emscripten linker needs debug symbols options too. + env.AppendUnique(LINKFLAGS=["-gdwarf-4"]) + env.AppendUnique(LINKFLAGS=["-g3"]) + elif env.dev_build: env.Append(CCFLAGS=["-g3"]) else: env.Append(CCFLAGS=["-g2"])