From 15d37ed2a891c099858abcddc1a470563b3166a4 Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Wed, 8 May 2024 11:09:50 +0300 Subject: [PATCH] [MinGW] Restore executable size check. --- platform/windows/platform_windows_builders.py | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/platform/windows/platform_windows_builders.py b/platform/windows/platform_windows_builders.py index fc52e3945601..dd480571ba7a 100644 --- a/platform/windows/platform_windows_builders.py +++ b/platform/windows/platform_windows_builders.py @@ -5,13 +5,16 @@ def make_debug_mingw(target, source, env): - objcopy = get_mingw_tool("objcopy", env["mingw_prefix"], env["arch"]) - strip = get_mingw_tool("strip", env["mingw_prefix"], env["arch"]) + dst = str(target[0]) + # Force separate debug symbols if executable size is larger than 1.9 GB. + if env["separate_debug_symbols"] or os.stat(dst).st_size >= 2040109465: + objcopy = get_mingw_tool("objcopy", env["mingw_prefix"], env["arch"]) + strip = get_mingw_tool("strip", env["mingw_prefix"], env["arch"]) - if not objcopy or not strip: - print('`separate_debug_symbols` requires both "objcopy" and "strip" to function.') - return + if not objcopy or not strip: + print('`separate_debug_symbols` requires both "objcopy" and "strip" to function.') + return - os.system("{0} --only-keep-debug {1} {1}.debugsymbols".format(objcopy, target[0])) - os.system("{0} --strip-debug --strip-unneeded {1}".format(strip, target[0])) - os.system("{0} --add-gnu-debuglink={1}.debugsymbols {1}".format(objcopy, target[0])) + os.system("{0} --only-keep-debug {1} {1}.debugsymbols".format(objcopy, dst)) + os.system("{0} --strip-debug --strip-unneeded {1}".format(strip, dst)) + os.system("{0} --add-gnu-debuglink={1}.debugsymbols {1}".format(objcopy, dst))