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)
This commit is contained in:
Sebastian Zaha 2023-08-12 22:46:22 +02:00 committed by Andrew Kaster
parent 1b395a3df9
commit a0fb1478bf
Notes: sideshowbarker 2024-07-17 05:05:51 +09:00
2 changed files with 18 additions and 3 deletions

View file

@ -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,

View file

@ -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