* [PATCH v2] meson.build: default to -gsplit-dwarf for debug info
@ 2025-03-06 10:53 Alex Bennée
2025-03-06 10:57 ` Daniel P. Berrangé
2025-03-06 11:36 ` Paolo Bonzini
0 siblings, 2 replies; 6+ messages in thread
From: Alex Bennée @ 2025-03-06 10:53 UTC (permalink / raw)
To: qemu-devel
Cc: Alex Bennée, Paolo Bonzini, Marc-André Lureau,
Daniel P. Berrangé, Philippe Mathieu-Daudé
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 <alex.bennee@linaro.org>
---
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(-)
diff --git a/meson.build b/meson.build
index 8d0abe7f12..09e34a6d63 100644
--- a/meson.build
+++ b/meson.build
@@ -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
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH v2] meson.build: default to -gsplit-dwarf for debug info
2025-03-06 10:53 [PATCH v2] meson.build: default to -gsplit-dwarf for debug info Alex Bennée
@ 2025-03-06 10:57 ` Daniel P. Berrangé
2025-03-06 11:36 ` Paolo Bonzini
1 sibling, 0 replies; 6+ messages in thread
From: Daniel P. Berrangé @ 2025-03-06 10:57 UTC (permalink / raw)
To: Alex Bennée
Cc: qemu-devel, Paolo Bonzini, Marc-André Lureau,
Philippe Mathieu-Daudé
On Thu, Mar 06, 2025 at 10:53:06AM +0000, Alex Bennée wrote:
> 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 <alex.bennee@linaro.org>
>
> ---
> 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(-)
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
With regards,
Daniel
--
|: 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 :|
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] meson.build: default to -gsplit-dwarf for debug info
2025-03-06 10:53 [PATCH v2] meson.build: default to -gsplit-dwarf for debug info Alex Bennée
2025-03-06 10:57 ` Daniel P. Berrangé
@ 2025-03-06 11:36 ` Paolo Bonzini
2025-03-06 12:20 ` Alex Bennée
1 sibling, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2025-03-06 11:36 UTC (permalink / raw)
To: Alex Bennée
Cc: qemu-devel, Marc-André Lureau, Daniel P. Berrangé,
Philippe Mathieu-Daudé
[-- Attachment #1: Type: text/plain, Size: 2113 bytes --]
Il gio 6 mar 2025, 11:53 Alex Bennée <alex.bennee@linaro.org> ha scritto:
> -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'
> 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
>
>
[-- Attachment #2: Type: text/html, Size: 3305 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] meson.build: default to -gsplit-dwarf for debug info
2025-03-06 11:36 ` Paolo Bonzini
@ 2025-03-06 12:20 ` Alex Bennée
2025-03-06 13:38 ` Paolo Bonzini
0 siblings, 1 reply; 6+ messages in thread
From: Alex Bennée @ 2025-03-06 12:20 UTC (permalink / raw)
To: Paolo Bonzini
Cc: qemu-devel, Marc-André Lureau, Daniel P. Berrangé,
Philippe Mathieu-Daudé
Paolo Bonzini <pbonzini@redhat.com> writes:
> Il gio 6 mar 2025, 11:53 Alex Bennée <alex.bennee@linaro.org> ha scritto:
>
> -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
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 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
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] meson.build: default to -gsplit-dwarf for debug info
2025-03-06 12:20 ` Alex Bennée
@ 2025-03-06 13:38 ` Paolo Bonzini
2025-03-06 14:42 ` Alex Bennée
0 siblings, 1 reply; 6+ messages in thread
From: Paolo Bonzini @ 2025-03-06 13:38 UTC (permalink / raw)
To: Alex Bennée
Cc: qemu-devel, Marc-André Lureau, Daniel P. Berrangé,
Philippe Mathieu-Daudé
[-- Attachment #1: Type: text/plain, Size: 2855 bytes --]
Il gio 6 mar 2025, 13:20 Alex Bennée <alex.bennee@linaro.org> ha scritto:
> Paolo Bonzini <pbonzini@redhat.com> writes:
>
> > Il gio 6 mar 2025, 11:53 Alex Bennée <alex.bennee@linaro.org> ha
> scritto:
> >
> > -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
>
> 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_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
> >
> > (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
>
> --
> Alex Bennée
> Virtualisation Tech Lead @ Linaro
>
>
[-- Attachment #2: Type: text/html, Size: 4314 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH v2] meson.build: default to -gsplit-dwarf for debug info
2025-03-06 13:38 ` Paolo Bonzini
@ 2025-03-06 14:42 ` Alex Bennée
0 siblings, 0 replies; 6+ messages in thread
From: Alex Bennée @ 2025-03-06 14:42 UTC (permalink / raw)
To: Paolo Bonzini
Cc: qemu-devel, Marc-André Lureau, Daniel P. Berrangé,
Philippe Mathieu-Daudé
Paolo Bonzini <pbonzini@redhat.com> writes:
> Il gio 6 mar 2025, 13:20 Alex Bennée <alex.bennee@linaro.org> ha scritto:
>
> Paolo Bonzini <pbonzini@redhat.com> writes:
>
> > Il gio 6 mar 2025, 11:53 Alex Bennée <alex.bennee@linaro.org> ha scritto:
> >
> > -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
>
> 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_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.
if get_option('optimization') != 'plain'
option_cflags += ['-O' + get_option('optimization')]
endif
Are you saying this is never applied to the build?
>
> Paolo
>
> >
> > (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
>
> --
> Alex Bennée
> Virtualisation Tech Lead @ Linaro
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2025-03-06 14:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-06 10:53 [PATCH v2] meson.build: default to -gsplit-dwarf for debug info Alex Bennée
2025-03-06 10:57 ` Daniel P. Berrangé
2025-03-06 11:36 ` Paolo Bonzini
2025-03-06 12:20 ` Alex Bennée
2025-03-06 13:38 ` Paolo Bonzini
2025-03-06 14:42 ` Alex Bennée
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).