Skip to contentSkip to conversation

meson: disable "maybe uninitilized" errors with -Og

PATCH In review Michael S. Tsirkin 2 participants 4 messages Jul 27 – Aug 10 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 meson: disable "maybe uninitilized" errors with -Og

GCC's "maybe uninitilized" warnings depend on optimizations for code flow analysis, and produce false positive errors with -Og. Default build gives us coverage with that, so let's just disable with -Og.

---
 meson.build | 4 ++++
 1 file changed, 4 insertions(+)
meson.build +4 -0
index 164328ded8..a119dae6ac 100644
@@ -742,6 +742,10 @@ warn_flags = [
   '-Wno-typedef-redefinition',
 ]
 
+if get_option('optimization') == 'g'
+  warn_flags += ['-Wno-error=maybe-uninitialized']
+endif
+
 if host_os != 'darwin'
   tsa_has_cleanup = cc.compiles('''
     struct __attribute__((capability("mutex"))) mutex {};
Signature · 1 line
MST
#1 lore raw
Quoted 6 lines · Michael S. Tsirkin

GCC's "maybe uninitilized" warnings depend on optimizations for code flow analysis, and produce false positive errors with -Og. Default build gives us coverage with that, so let's just disable with -Og.

ping, comments on this?

As an alternative, I can see us doing this for everyone and only adding -Werror=maybe-uninitialized in CI for known good compiler/flag combos which do not produce too many false positives.

Quoted 21 lines
---
 meson.build | 4 ++++
 1 file changed, 4 insertions(+)
meson.build +4 -0
index 164328ded8..a119dae6ac 100644
@@ -742,6 +742,10 @@ warn_flags = [
   '-Wno-typedef-redefinition',
 ]
 
+if get_option('optimization') == 'g'
+  warn_flags += ['-Wno-error=maybe-uninitialized']
+endif
+
 if host_os != 'darwin'
   tsa_has_cleanup = cc.compiles('''
     struct __attribute__((capability("mutex"))) mutex {};
Signature · 1 line
MST
#2 lore raw
Quoted 6 lines · Michael S. Tsirkin
Quoted 5 lines · Michael S. Tsirkin

GCC's "maybe uninitilized" warnings depend on optimizations for code flow analysis, and produce false positive errors with -Og. Default build gives us coverage with that, so let's just disable with -Og.

Quoted 8 lines
Quoted 1 line

ping, comments on this?

As an alternative, I can see us doing this for everyone and only adding -Werror=maybe-uninitialized in CI for known good compiler/flag combos which do not produce too many false positives.

I see no compelling reason to disable it universally - the problems are not too numerous, and IMHO if the code is complex enough that the compiler is worried, then it is better to have explicit initializers as that makes the code easier to interpret for humans too.

Quoted 14 lines
Quoted 14 lines

---
 meson.build | 4 ++++
 1 file changed, 4 insertions(+)
meson.build +0 -0
index 164328ded8..a119dae6ac 100644
@@ -742,6 +742,10 @@ warn_flags = [
   '-Wno-typedef-redefinition',
 ]
 
Quoted 10 lines
Quoted 9 lines
meson.build +4 -0
+if get_option('optimization') == 'g'
+  warn_flags += ['-Wno-error=maybe-uninitialized']
+endif
+
 if host_os != 'darwin'
   tsa_has_cleanup = cc.compiles('''
     struct __attribute__((capability("mutex"))) mutex {};
Signature · 1 line
MST

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|
Reviewed-by on v1 1/1
#3 lore raw
In reply to Michael S. Tsirkin
Quoted 15 lines · Michael S. Tsirkin

GCC's "maybe uninitilized" warnings depend on optimizations for code flow analysis, and produce false positive errors with -Og. Default build gives us coverage with that, so let's just disable with -Og.

---
 meson.build | 4 ++++
 1 file changed, 4 insertions(+)
meson.build +0 -0
index 164328ded8..a119dae6ac 100644

meson.build warn_flags = [ · line 747

Quoted 6 lines
meson.build +3 -0
@@ -742,6 +742,10 @@ warn_flags = [
   '-Wno-typedef-redefinition',
 ]
 
+if get_option('optimization') == 'g'
+  warn_flags += ['-Wno-error=maybe-uninitialized']
+endif

With regards,
Daniel

Signature · 3 lines
|: https://berrange.com       ~~        https://hachyderm.io/@berrange :|
|: https://libvirt.org          ~~          https://entangle-photo.org :|
|: https://pixelfed.art/berrange   ~~    https://fstop138.berrange.com :|