Skip to content

Commit

Permalink
[MinGW] Force separate debug symbols if executable size is larger tha…
Browse files Browse the repository at this point in the history
…n 1.9 GB.
  • Loading branch information
bruvzg committed Dec 3, 2023
1 parent d76c1d0 commit 6cb5256
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
2 changes: 1 addition & 1 deletion platform/windows/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ if env["vsproj"]:
env.vs_srcs += ["platform/windows/" + str(x)]

if not os.getenv("VCINSTALLDIR"):
if env["debug_symbols"] and env["separate_debug_symbols"]:
if env["debug_symbols"]:
env.AddPostAction(prog, run_in_subprocess(platform_windows_builders.make_debug_mingw))
if env["windows_subsystem"] == "gui":
env.AddPostAction(prog_wrap, run_in_subprocess(platform_windows_builders.make_debug_mingw))
28 changes: 15 additions & 13 deletions platform/windows/platform_windows_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,21 @@


def make_debug_mingw(target, source, env):
mingw_bin_prefix = get_mingw_bin_prefix(env["mingw_prefix"], env["arch"])
if try_cmd("objcopy --version", env["mingw_prefix"], env["arch"]):
os.system(mingw_bin_prefix + "objcopy --only-keep-debug {0} {0}.debugsymbols".format(target[0]))
else:
os.system("objcopy --only-keep-debug {0} {0}.debugsymbols".format(target[0]))
if try_cmd("strip --version", env["mingw_prefix"], env["arch"]):
os.system(mingw_bin_prefix + "strip --strip-debug --strip-unneeded {0}".format(target[0]))
else:
os.system("strip --strip-debug --strip-unneeded {0}".format(target[0]))
if try_cmd("objcopy --version", env["mingw_prefix"], env["arch"]):
os.system(mingw_bin_prefix + "objcopy --add-gnu-debuglink={0}.debugsymbols {0}".format(target[0]))
else:
os.system("objcopy --add-gnu-debuglink={0}.debugsymbols {0}".format(target[0]))
# Force separate debug symbols if executable size is larger than 1.9 GB.
if env["separate_debug_symbols"] or os.stat(target[0]).st_size >= 2040109465:
mingw_bin_prefix = get_mingw_bin_prefix(env["mingw_prefix"], env["arch"])
if try_cmd("objcopy --version", env["mingw_prefix"], env["arch"]):
os.system(mingw_bin_prefix + "objcopy --only-keep-debug {0} {0}.debugsymbols".format(target[0]))
else:
os.system("objcopy --only-keep-debug {0} {0}.debugsymbols".format(target[0]))
if try_cmd("strip --version", env["mingw_prefix"], env["arch"]):
os.system(mingw_bin_prefix + "strip --strip-debug --strip-unneeded {0}".format(target[0]))
else:
os.system("strip --strip-debug --strip-unneeded {0}".format(target[0]))
if try_cmd("objcopy --version", env["mingw_prefix"], env["arch"]):
os.system(mingw_bin_prefix + "objcopy --add-gnu-debuglink={0}.debugsymbols {0}".format(target[0]))
else:
os.system("objcopy --add-gnu-debuglink={0}.debugsymbols {0}".format(target[0]))


if __name__ == "__main__":
Expand Down

0 comments on commit 6cb5256

Please sign in to comment.