Open sscargal opened 2 years ago
yeah, known issue, but warning_level enables even more warnings that need to be resolved first.
It shouldn't, Meson's default warning_level is 1
and enables -Wall. So adding -Wall yourself is redundant, but I guess if you really wanted you could set it in default_options
.
Is -O2
really necessary? Could that be left to the buildtype? Under release you get -O3
and under debugoptimized you get -O2
.
@eli-schwartz this is what was inherited from our autotools conversion. Perhaps I was tripping over trying to get those extra warnings enabled via warning-level without pulling in others. Perhaps I can just do warning_level 1 and have leave the rest in cc_flags. Yes, the manual -O2 is indeed bogus.
cc_flags = [ '-Wall', '-Wchar-subscripts', '-Wformat-security', '-Wmissing-declarations', '-Wmissing-prototypes', '-Wnested-externs ', '-Wshadow', '-Wsign-compare', '-Wstrict-prototypes', '-Wtype-limits', '-Wmaybe-uninitialized', '-Wdeclaration-after-statement', '-Wunused-result', '-D_FORTIFY_SOURCE=2', '-O2', ]
ok, this seems to work. Thanks for the nudges:
diff --git a/meson.build b/meson.build
index 5e97e1ce3068..a4149bb7b08c 100644
--- a/meson.build
+++ b/meson.build
@@ -57,7 +57,6 @@ sed -e s,@VERSION@,@0@,g
'''.format(meson.project_version(), prefixdir, libdir, includedir).split()
cc_flags = [
- '-Wall',
'-Wchar-subscripts',
'-Wformat-security',
'-Wmissing-declarations',
@@ -70,9 +69,12 @@ cc_flags = [
'-Wmaybe-uninitialized',
'-Wdeclaration-after-statement',
'-Wunused-result',
- '-D_FORTIFY_SOURCE=2',
- '-O2',
]
+
+if get_option('optimization') != '0'
+ cc_flags += [ '-D_FORTIFY_SOURCE=2' ]
+endif
+
cc = meson.get_compiler('c')
add_project_arguments(cc.get_supported_arguments(cc_flags), language : 'c')
On Fedora 35, two warning messages are returned. These are harmless, but should be resolved.