From 9e2d167656583875c47b5927e95a7a1fa5304f0b Mon Sep 17 00:00:00 2001 From: liyanjin <36877356+grab-liyanjin@users.noreply.github.com> Date: Thu, 23 Apr 2026 10:06:09 +0800 Subject: [PATCH] (android): apply size optimization flags to RelWithDebInfo build config (#4247) Co-authored-by: Claude Sonnet 4.6 Co-authored-by: Bart Louwers --- platform/android/android.cmake | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/platform/android/android.cmake b/platform/android/android.cmake index 106764ac7..4ae596b3a 100644 --- a/platform/android/android.cmake +++ b/platform/android/android.cmake @@ -11,20 +11,24 @@ include(${PROJECT_SOURCE_DIR}/vendor/icu.cmake) include(${PROJECT_SOURCE_DIR}/vendor/sqlite.cmake) # cmake-format: off -target_compile_options(mbgl-vendor-csscolorparser PRIVATE $<$:-Oz> $<$:-Qunused-arguments> $<$:-flto>) -target_compile_options(mbgl-vendor-icu PRIVATE $<$:-Oz> $<$:-Qunused-arguments> $<$:-flto>) -target_compile_options(mbgl-vendor-parsedate PRIVATE $<$:-Oz> $<$:-Qunused-arguments> $<$:-flto>) -target_compile_options(mbgl-vendor-sqlite PRIVATE $<$:-Oz> $<$:-Qunused-arguments> $<$:-flto>) -target_compile_options(mbgl-compiler-options INTERFACE $<$:-Oz> $<$:-Qunused-arguments> $<$:-flto>) +# Apply size optimizations for both Release and RelWithDebInfo configs. +# Android AGP maps the release build variant to RelWithDebInfo (not Release), so we must +# include RelWithDebInfo here to ensure these flags are actually applied. +set(_OPT_CONFIGS "$,$>") +target_compile_options(mbgl-vendor-csscolorparser PRIVATE $<${_OPT_CONFIGS}:-Oz> $<${_OPT_CONFIGS}:-Qunused-arguments> $<${_OPT_CONFIGS}:-flto>) +target_compile_options(mbgl-vendor-icu PRIVATE $<${_OPT_CONFIGS}:-Oz> $<${_OPT_CONFIGS}:-Qunused-arguments> $<${_OPT_CONFIGS}:-flto>) +target_compile_options(mbgl-vendor-parsedate PRIVATE $<${_OPT_CONFIGS}:-Oz> $<${_OPT_CONFIGS}:-Qunused-arguments> $<${_OPT_CONFIGS}:-flto>) +target_compile_options(mbgl-vendor-sqlite PRIVATE $<${_OPT_CONFIGS}:-Oz> $<${_OPT_CONFIGS}:-Qunused-arguments> $<${_OPT_CONFIGS}:-flto>) +target_compile_options(mbgl-compiler-options INTERFACE $<${_OPT_CONFIGS}:-Oz> $<${_OPT_CONFIGS}:-Qunused-arguments> $<${_OPT_CONFIGS}:-flto>) # cmake-format: on target_link_libraries( mbgl-compiler-options INTERFACE - $<$:-O2> - $<$:-Wl,--icf=all> - $<$:-flto> - $<$:-fuse-ld=gold> + $<${_OPT_CONFIGS}:-O2> + $<${_OPT_CONFIGS}:-Wl,--icf=all> + $<${_OPT_CONFIGS}:-flto> + $<${_OPT_CONFIGS}:-fuse-ld=lld> ) target_sources(