From a0fb1478bf7defe0cb4a2ff8858bdb166aa0136e Mon Sep 17 00:00:00 2001 From: Sebastian Zaha Date: Sat, 12 Aug 2023 22:46:22 +0200 Subject: [PATCH] Meta: Add options for lldb and gdb output to gn This makes it possible to specify (instead of is_debug) a more specialized is_debug_lldb or is_debug_gdb, so that clang outputs the proper symbols. (For lldb this fixes issues with formatting by setting -fstandalone-debug) --- Meta/gn/build/BUILD.gn | 9 ++++++++- Meta/gn/build/buildflags.gni | 12 ++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/Meta/gn/build/BUILD.gn b/Meta/gn/build/BUILD.gn index 4095cdd829..1ee4742465 100644 --- a/Meta/gn/build/BUILD.gn +++ b/Meta/gn/build/BUILD.gn @@ -24,7 +24,14 @@ config("compiler_defaults") { ldflags = [] if (symbol_level == 2) { - cflags += [ "-g" ] + if (is_debug_gdb) { + cflags += [ "-ggdb" ] + } else if (is_clang && is_debug_lldb) { + # GCC (as of version 13) does not support lldb-specific debug information + cflags += [ "-glldb" ] + } else { + cflags += [ "-g" ] + } # For full debug-info -g builds, --gdb-index makes links ~15% slower, and # gdb symbol reading time 1500% faster (lld links in 4.4 instead of 3.9s, diff --git a/Meta/gn/build/buildflags.gni b/Meta/gn/build/buildflags.gni index 782cd0d79d..c3c7e77051 100644 --- a/Meta/gn/build/buildflags.gni +++ b/Meta/gn/build/buildflags.gni @@ -1,9 +1,17 @@ declare_args() { - # Build for debugging. Equivalent to is_optimized=false symbol_level=2. - is_debug = false + # https://clang.llvm.org/docs/UsersManual.html#controlling-debugger-tuning + # Build with clang for debugging, tuned for a specific debugger. + # Both imply is_debug = true. + is_debug_lldb = false + is_debug_gdb = false } # args that depend on other args must live in a later declare_args() block. +declare_args() { + # Build for debugging. Equivalent to is_optimized=false symbol_level=2. + is_debug = is_debug_lldb || is_debug_gdb +} + declare_args() { # Whether to build with optimizations. is_optimized = !is_debug