From 39b207f5fd700210b687e86ad7eb34eb6fd235cd Mon Sep 17 00:00:00 2001 From: dskiba Date: Thu, 12 May 2016 12:00:45 -0700 Subject: [PATCH] Don't omit frame pointers in profiling Android GN builds. This CL makes sure that frame pointers (used for fast stack unwinding) are not omitted when enable_profiling is true. There are two changes: 1. Don't add -fomit-frame-pointer flag (Android-specific change). 2. Add -fno-omit-frame-pointer flag even in debug builds. This is needed for Android where debug builds are optimized too (-Os). BUG=602701 Review-Url: https://codereview.chromium.org/1965143003 Cr-Original-Commit-Position: refs/heads/master@{#393320} Cr-Mirrored-From: https://chromium.googlesource.com/chromium/src Cr-Mirrored-Commit: 14430a4de781aca8e67f6ec7b8893647d7ee26d9 --- config/compiler/BUILD.gn | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/config/compiler/BUILD.gn b/config/compiler/BUILD.gn index 0ae9cb050..490208313 100644 --- a/config/compiler/BUILD.gn +++ b/config/compiler/BUILD.gn @@ -241,17 +241,19 @@ config("compiler") { # Non-Mac Posix compiler flags setup. # ----------------------------------- if (is_posix && !(is_mac || is_ios)) { - if (enable_profiling && !is_debug) { - cflags += [ - "-fno-omit-frame-pointer", - "-g", - ] + if (enable_profiling) { + # Explicitly ask for frame pointers. Otherwise they are omitted when + # any optimization level is used (and Android debug builds use -Os). + cflags += [ "-fno-omit-frame-pointer" ] + if (!is_debug) { + cflags += [ "-g" ] - if (enable_full_stack_frames_for_profiling) { - cflags += [ - "-fno-inline", - "-fno-optimize-sibling-calls", - ] + if (enable_full_stack_frames_for_profiling) { + cflags += [ + "-fno-inline", + "-fno-optimize-sibling-calls", + ] + } } } @@ -1209,7 +1211,7 @@ if (is_win) { # We don't omit frame pointers on arm64 since they are required # to correctly unwind stackframes which contain system library # function frames (crbug.com/391706). - if (!using_sanitizer && target_cpu != "arm64") { + if (!using_sanitizer && !enable_profiling && target_cpu != "arm64") { common_optimize_on_cflags += [ "-fomit-frame-pointer" ] } @@ -1299,7 +1301,7 @@ config("no_optimize") { # We don't omit frame pointers on arm64 since they are required # to correctly unwind stackframes which contain system library # function frames (crbug.com/391706). - if (!using_sanitizer && target_cpu != "arm64") { + if (!using_sanitizer && !enable_profiling && target_cpu != "arm64") { cflags += [ "-fomit-frame-pointer" ] }