Skip to content

Commit 563b1a3

Browse files
stsquadbonzini
authored andcommitted
meson.build: default to -gsplit-dwarf for debug info
This option is supported by both gcc (since 4.7) and clang (since 7.0). Not only does this make the linkers job easier by reducing the amount of ELF it needs to parse it also reduces the total build size quite considerably. In my case a default build went from 5.8G to 3.9G (vs 1.9G for --disable-debug-info). The --disable-split-debug option allows distros to keep all the info together for ease of packaging. Signed-off-by: Alex Bennée <[email protected]> Reviewed-by: Daniel P. Berrangé <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 094cd35 commit 563b1a3

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

meson.build

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,10 @@ if get_option('tsan')
601601
qemu_ldflags = ['-fsanitize=thread'] + qemu_ldflags
602602
endif
603603

604+
if get_option('debug') and get_option('split_debug')
605+
qemu_cflags += '-gsplit-dwarf'
606+
endif
607+
604608
# Detect support for PT_GNU_RELRO + DT_BIND_NOW.
605609
# The combination is known as "full relro", because .got.plt is read-only too.
606610
qemu_ldflags += cc.get_supported_link_arguments('-Wl,-z,relro', '-Wl,-z,now')
@@ -4583,6 +4587,8 @@ if have_rust
45834587
summary_info += {'bindgen': bindgen.full_path()}
45844588
summary_info += {'bindgen version': bindgen.version()}
45854589
endif
4590+
# option_cflags is purely for the summary display, meson will pass
4591+
# -g/-O options directly
45864592
option_cflags = (get_option('debug') ? ['-g'] : [])
45874593
if get_option('optimization') != 'plain'
45884594
option_cflags += ['-O' + get_option('optimization')]

meson_options.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ option('debug_mutex', type: 'boolean', value: false,
362362
description: 'mutex debugging support')
363363
option('debug_stack_usage', type: 'boolean', value: false,
364364
description: 'measure coroutine stack usage')
365+
option('split_debug', type: 'boolean', value: true,
366+
description: 'split debug info from object files')
365367
option('qom_cast_debug', type: 'boolean', value: true,
366368
description: 'cast debugging support')
367369
option('slirp_smbd', type : 'feature', value : 'auto',

scripts/meson-buildoptions.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,8 @@ _meson_option_parse() {
504504
--disable-strict-rust-lints) printf "%s" -Dstrict_rust_lints=false ;;
505505
--enable-strip) printf "%s" -Dstrip=true ;;
506506
--disable-strip) printf "%s" -Dstrip=false ;;
507+
--enable-split-debug) printf "%s" -Dsplit_debug=true ;;
508+
--disable-split-debug) printf "%s" -Dsplit_debug=false ;;
507509
--sysconfdir=*) quote_sh "-Dsysconfdir=$2" ;;
508510
--enable-tcg) printf "%s" -Dtcg=enabled ;;
509511
--disable-tcg) printf "%s" -Dtcg=disabled ;;

0 commit comments

Comments
 (0)