meson.build: default to -gsplit-dwarf for debug info
PATCH v2 1/1 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.
The --disable-split-debug option allows distros to keep all the info together for ease of packaging.
---
v1
- add --disable/enable-split-debug
- move to option_cflags
v2
- removed unneeded []'s
- fix stray whitespace
--- meson.build | 5 ++++- meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-)
meson.build +4 -1
@@ -4589,7 +4589,10 @@ if have_rust summary_info += {'bindgen': bindgen.full_path()} summary_info += {'bindgen version': bindgen.version()} endif -option_cflags = (get_option('debug') ? ['-g'] : []) +option_cflags = [] +if get_option('debug') + option_cflags += get_option('split_debug') ? ['-gsplit-dwarf'] : ['-g'] +endif if get_option('optimization') != 'plain' option_cflags += ['-O' + get_option('optimization')] endif
meson_options.txt +2 -0
@@ -362,6 +362,8 @@ option('debug_mutex', type: 'boolean', value: false, description: 'mutex debugging support') option('debug_stack_usage', type: 'boolean', value: false, description: 'measure coroutine stack usage') +option('split_debug', type: 'boolean', value: true, + description: 'split debug info from object files') option('qom_cast_debug', type: 'boolean', value: true, description: 'cast debugging support') option('slirp_smbd', type : 'feature', value : 'auto',
scripts/meson-buildoptions.sh +2 -0
@@ -504,6 +504,8 @@ _meson_option_parse() { --disable-strict-rust-lints) printf "%s" -Dstrict_rust_lints=false ;; --enable-strip) printf "%s" -Dstrip=true ;; --disable-strip) printf "%s" -Dstrip=false ;; + --enable-split-debug) printf "%s" -Dsplit_debug=true ;; + --disable-split-debug) printf "%s" -Dsplit_debug=false ;; --sysconfdir=*) quote_sh "-Dsysconfdir=$2" ;; --enable-tcg) printf "%s" -Dtcg=enabled ;; --disable-tcg) printf "%s" -Dtcg=disabled ;;
Signature · 1 line
2.39.5
Quoted 17 lines · Alex Bennée
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.
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]>---
v1
- add --disable/enable-split-debug
- move tooption_cflags
v2
- removed unneeded []'s
- fix stray whitespace
Quoted 5 lines
--- meson.build | 5 ++++- meson_options.txt | 2 ++ scripts/meson-buildoptions.sh | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-)
With regards,
Daniel
Signature · 3 lines
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|
Il gio 6 mar 2025, 11:53 Alex Bennée <[email protected]> ha scritto:
meson.build if have_rust · line 4595
Quoted 6 lines
meson.build +4
-1-option_cflags = (get_option('debug') ? ['-g'] : []) +option_cflags = [] +if get_option('debug') + option_cflags += get_option('split_debug') ? ['-gsplit-dwarf'] : ['-g'] +endif
option_cflags does nothing, it's only for clarity in the final summary. So you need
if get_option('debug') and get_option('split_debug')
qemu_cflags += '-gsplit-dwarf'
endif
(I wonder if it should be implemented in meson instead... It should be beneficial for other projects surely).
Paolo
if get_option('optimization') != 'plain'
Quoted 32 lines
option_cflags += ['-O' + get_option('optimization')]endif
meson_options.txt +2
-0@@ -362,6 +362,8 @@ option('debug_mutex', type: 'boolean', value: false, description: 'mutex debugging support') option('debug_stack_usage', type: 'boolean', value: false, description: 'measure coroutine stack usage') +option('split_debug', type: 'boolean', value: true, + description: 'split debug info from object files') option('qom_cast_debug', type: 'boolean', value: true, description: 'cast debugging support') option('slirp_smbd', type : 'feature', value : 'auto',scripts/meson-buildoptions.sh +2
-1@@ -504,6 +504,8 @@ _meson_option_parse() { --disable-strict-rust-lints) printf "%s" -Dstrict_rust_lints=false ;; --enable-strip) printf "%s" -Dstrip=true ;; --disable-strip) printf "%s" -Dstrip=false ;; + --enable-split-debug) printf "%s" -Dsplit_debug=true ;; + --disable-split-debug) printf "%s" -Dsplit_debug=false ;; --sysconfdir=*) quote_sh "-Dsysconfdir=$2" ;; --enable-tcg) printf "%s" -Dtcg=enabled ;; --disable-tcg) printf "%s" -Dtcg=disabled ;; --2.39.5
Quoted 8 lines · Paolo Bonzini
Il gio 6 mar 2025, 11:53 Alex Bennée <[email protected]> ha scritto:
-option_cflags = (
get_option('debug')? ['-g'] : []) +option_cflags = []
+ifget_option('debug')
+option_cflags+=get_option('split_debug')? ['-gsplit-dwarf'] : ['-g'] +endif
Quoted 5 lines
option_cflagsdoes nothing, it's only for clarity in the final summary. So you needif
get_option('debug')andget_option('split_debug')
qemu_cflags+= '-gsplit-dwarf'
endif
Should I update the optimization field as well? is this the reason why I wasn't seeing changes occur for the tests that meson builds?
Quoted 36 lines
(I wonder if it should be implemented in meson instead... It should be beneficial for other projects surely).
Paolo
if
get_option('optimization')!= 'plain'option_cflags += ['-O' + get_option('optimization')] endif diff --git a/meson_options.txt b/meson_options.txt index 59d973bca0..3432123fee 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -362,6 +362,8 @@ option('debug_mutex', type: 'boolean', value: false, description: 'mutex debugging support') option('debug_stack_usage', type: 'boolean', value: false, description: 'measure coroutine stack usage') +option('split_debug', type: 'boolean', value: true, + description: 'split debug info from object files') option('qom_cast_debug', type: 'boolean', value: true, description: 'cast debugging support') option('slirp_smbd', type : 'feature', value : 'auto', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 3e8e00852b..aca6e68830 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -504,6 +504,8 @@ _meson_option_parse() { --disable-strict-rust-lints) printf "%s" -Dstrict_rust_lints=false ;; --enable-strip) printf "%s" -Dstrip=true ;; --disable-strip) printf "%s" -Dstrip=false ;; + --enable-split-debug) printf "%s" -Dsplit_debug=true ;; + --disable-split-debug) printf "%s" -Dsplit_debug=false ;; --sysconfdir=*) quote_sh "-Dsysconfdir=$2" ;; --enable-tcg) printf "%s" -Dtcg=enabled ;; --disable-tcg) printf "%s" -Dtcg=disabled ;;--
2.39.5
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro
Il gio 6 mar 2025, 13:20 Alex Bennée <[email protected]> ha scritto:
Quoted 13 lines
Quoted 1 line · Paolo Bonzini
Il gio 6 mar 2025, 11:53 Alex Bennée <[email protected]> ha
scritto:
Quoted 5 lines
-option_cflags = (
get_option('debug')? ['-g'] : []) +option_cflags = []
+ifget_option('debug')
+option_cflags+=get_option('split_debug')? ['-gsplit-dwarf'] :['-g']
Quoted 3 lines
+endif
option_cflagsdoes nothing, it's only for clarity in the final summary.
Quoted 9 lines
So you need
Quoted 4 lines
if
get_option('debug')andget_option('split_debug')
qemu_cflags+= '-gsplit-dwarf'
endifShould I update the optimization field as well? is this the reason why I wasn't seeing changes occur for the tests that meson builds?
I am not sure what you mean by optimization field; anyway, qemu_cflags applies to all C sources and qemu_ldflags to all programs linked with the C compiler. As I understand it, '-gsplit-dwarf' should go in qemu_cflags.
Paolo
Quoted 45 lines
Quoted 2 lines
(I wonder if it should be implemented in meson instead... It should be
beneficial for other projects surely).
Quoted 5 lines
Paolo
if
get_option('optimization')!= 'plain'option_cflags += ['-O' + get_option('optimization')]Quoted 15 lines
endif
diff --gita/meson_options.txtb/meson_options.txt
index59d973bca0..3432123fee100644
---a/meson_options.txt
+++b/meson_options.txt
@@ -362,6 +362,8 @@ option('debug_mutex', type: 'boolean', value: false,
description: 'mutex debugging support')
option('debug_stack_usage', type: 'boolean', value: false,
description: 'measure coroutine stack usage')
+option('split_debug', type: 'boolean', value: true,
+ description: 'split debug info from object files')
option('qom_cast_debug', type: 'boolean', value: true,
description: 'cast debugging support')
option('slirp_smbd', type : 'feature', value : 'auto',
diff --gita/scripts/meson-buildoptions.sh
b/scripts/meson-buildoptions.shQuoted 5 lines
index
3e8e00852b..aca6e68830100644
---a/scripts/meson-buildoptions.sh
+++b/scripts/meson-buildoptions.sh
@@ -504,6 +504,8 @@_meson_option_parse(){
--disable-strict-rust-lints) printf "%s" -Dstrict_rust_lints=false;;
Quoted 9 lines
--enable-strip) printf "%s" -Dstrip=true ;; --disable-strip) printf "%s" -Dstrip=false ;; + --enable-split-debug) printf "%s" -Dsplit_debug=true ;; + --disable-split-debug) printf "%s" -Dsplit_debug=false ;; --sysconfdir=*) quote_sh "-Dsysconfdir=$2" ;; --enable-tcg) printf "%s" -Dtcg=enabled ;; --disable-tcg) printf "%s" -Dtcg=disabled ;;--
2.39.5--
Alex Bennée
Virtualisation Tech Lead @ Linaro
Quoted 18 lines · Paolo Bonzini
Il gio 6 mar 2025, 13:20 Alex Bennée <[email protected]> ha scritto:
Quoted 8 lines · Paolo Bonzini
Il gio 6 mar 2025, 11:53 Alex Bennée <[email protected]> ha scritto:
-option_cflags = (
get_option('debug')? ['-g'] : []) +option_cflags = []
+ifget_option('debug')
+option_cflags+=get_option('split_debug')? ['-gsplit-dwarf'] : ['-g'] +endifQuoted 5 lines
option_cflagsdoes nothing, it's only for clarity in the final summary. So you needif
get_option('debug')andget_option('split_debug')
qemu_cflags+= '-gsplit-dwarf'
endif
Quoted 6 lines
Should I update the optimization field as well? is this the reason why I wasn't seeing changes occur for the tests that meson builds?
I am not sure what you mean by optimization field; anyway,
qemu_cflagsapplies to all C sources andqemu_ldflagsto all programs linked with the C compiler. As I understand it,
'-gsplit-dwarf' should go inqemu_cflags.
if get_option('optimization') != 'plain'
option_cflags += ['-O' + get_option('optimization')]
endif
Are you saying this is never applied to the build?
Quoted 43 lines
Paolo
Quoted 34 lines
(I wonder if it should be implemented in meson instead... It should be beneficial for other projects surely).
Paolo
if
get_option('optimization')!= 'plain'option_cflags += ['-O' + get_option('optimization')] endif diff --git a/meson_options.txt b/meson_options.txt index 59d973bca0..3432123fee 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -362,6 +362,8 @@ option('debug_mutex', type: 'boolean', value: false, description: 'mutex debugging support') option('debug_stack_usage', type: 'boolean', value: false, description: 'measure coroutine stack usage') +option('split_debug', type: 'boolean', value: true, + description: 'split debug info from object files') option('qom_cast_debug', type: 'boolean', value: true, description: 'cast debugging support') option('slirp_smbd', type : 'feature', value : 'auto', diff --git a/scripts/meson-buildoptions.sh b/scripts/meson-buildoptions.sh index 3e8e00852b..aca6e68830 100644 --- a/scripts/meson-buildoptions.sh +++ b/scripts/meson-buildoptions.sh @@ -504,6 +504,8 @@ _meson_option_parse() { --disable-strict-rust-lints) printf "%s" -Dstrict_rust_lints=false ;; --enable-strip) printf "%s" -Dstrip=true ;; --disable-strip) printf "%s" -Dstrip=false ;; + --enable-split-debug) printf "%s" -Dsplit_debug=true ;; + --disable-split-debug) printf "%s" -Dsplit_debug=false ;; --sysconfdir=*) quote_sh "-Dsysconfdir=$2" ;; --enable-tcg) printf "%s" -Dtcg=enabled ;; --disable-tcg) printf "%s" -Dtcg=disabled ;;Quoted 2 lines
--
2.39.5--
Alex Bennée
Virtualisation Tech Lead @ Linaro
Signature · 2 lines
Alex Bennée Virtualisation Tech Lead @ Linaro