scripts: waifulib: add flag --enable-limited-debuginfo which enables -gline-tables-only on GCC and Clang compilers

This saves ~30mb of APK size on Android.
This commit is contained in:
Alibek Omarov 2025-03-05 02:18:49 +03:00
parent 0e90e6285e
commit 8359cbe76c
2 changed files with 13 additions and 3 deletions

View file

@ -17,7 +17,7 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
set(BUILD_TYPE "debug") set(BUILD_TYPE "debug")
else() else()
set(BUILD_TYPE "release") set(BUILD_TYPE "release")
list(APPEND WAF_EXTRA_ARGS --enable-poly-opt --enable-lto) list(APPEND WAF_EXTRA_ARGS --enable-poly-opt --enable-lto --enable-limited-debuginfo)
endif() endif()
if(ANDROID_ABI STREQUAL "x86") if(ANDROID_ABI STREQUAL "x86")
@ -75,7 +75,7 @@ ExternalProject_Add(
BUILD_CMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} BUILD_CMAKE_LIBRARY_OUTPUT_DIRECTORY=${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
WAFLOCK=.lock-waf_android_${ANDROID_ABI}_build WAFLOCK=.lock-waf_android_${ANDROID_ABI}_build
${WAF} configure -T ${BUILD_TYPE} --android=${ANDROID_ABI},,${CMAKE_SYSTEM_VERSION} ${WAF} configure -T ${BUILD_TYPE} --android=${ANDROID_ABI},,${CMAKE_SYSTEM_VERSION}
-s "${ENGINE_SOURCE_DIR}/3rdparty/SDL" --enable-bundled-deps -s "${ENGINE_SOURCE_DIR}/3rdparty/SDL" --enable-bundled-deps ${WAF_EXTRA_ARGS}
BUILD_COMMAND ${CMAKE_COMMAND} -E env BUILD_COMMAND ${CMAKE_COMMAND} -E env
WAFLOCK=.lock-waf_android_${ANDROID_ABI}_build WAFLOCK=.lock-waf_android_${ANDROID_ABI}_build

View file

@ -177,6 +177,9 @@ def options(opt):
grp.add_option('--enable-profile', action = 'store_true', dest = 'PROFILE_GENERATE', default = False, grp.add_option('--enable-profile', action = 'store_true', dest = 'PROFILE_GENERATE', default = False,
help = 'enable profile generating build (stored in xash3d-prof directory) [default: %(default)s]') help = 'enable profile generating build (stored in xash3d-prof directory) [default: %(default)s]')
grp.add_option('--enable-limited-debuginfo', action = 'store_true', dest = 'LIMITED_DEBUGINFO', default = False,
help = 'only save line debuginfo, useful for release builds [default: %(default)s]')
grp.add_option('--use-profile', action = 'store', dest = 'PROFILE_USE', default = None, grp.add_option('--use-profile', action = 'store', dest = 'PROFILE_USE', default = None,
help = 'use profile during build [default: %(default)s]') help = 'use profile during build [default: %(default)s]')
@ -254,7 +257,14 @@ def get_optimization_flags(conf):
# this port don't have stack printing support # this port don't have stack printing support
cflags.remove('-fasynchronous-unwind-tables') cflags.remove('-fasynchronous-unwind-tables')
if conf.env.COMPILER_CC == 'gcc' or conf.env.COMPILER_CC == 'clang' and conf.env.DEST_OS not in ['android']: if conf.env.COMPILER_CC in ['gcc', 'clang'] and conf.options.LIMITED_DEBUGINFO:
# probably not a good idea to do this, but it should save space on Android builds especially
# that are never going to be run under debugger, but we still want that readable fileline
# info in backtraces
# might enable this for release/fast/fastnative builds in the future
cflags = ['-gline-tables-only' if flag.startswith('-g') else flag for flag in cflags]
if conf.env.COMPILER_CC in ['gcc', 'clang'] and conf.env.DEST_OS not in ['android']:
# HLSDK by default compiles with these options under Linux # HLSDK by default compiles with these options under Linux
# no reason for us to not do the same # no reason for us to not do the same