pmem / ndctl

A "device memory" enabling project encompassing tools and libraries for CXL, NVDIMMs, DAX, memory tiering and other platform memory device topics.
Other
266 stars 138 forks source link

meson.build WARNING's returned for using "-Wall" and "-O2" instead of their Meson equivalents #195

Open sscargal opened 2 years ago

sscargal commented 2 years ago

On Fedora 35, two warning messages are returned. These are harmless, but should be resolved.

# meson setup build
The Meson build system
Version: 0.59.4
Source dir: /downloads/ndctl
Build dir: /downloads/ndctl/build
Build type: native build
Project name: ndctl
Project version: 73
C compiler for the host machine: cc (gcc 11.2.1 "cc (GCC) 11.2.1 20220127 (Red Hat 11.2.1-9)")
C linker for the host machine: cc ld.bfd 2.37-10
Host machine cpu family: x86_64
Host machine cpu: x86_64
Compiler for C supports arguments -Wall: YES
Compiler for C supports arguments -Wchar-subscripts: YES
Compiler for C supports arguments -Wformat-security: YES
Compiler for C supports arguments -Wmissing-declarations: YES
Compiler for C supports arguments -Wmissing-prototypes: YES
Compiler for C supports arguments -Wnested-externs : NO
Compiler for C supports arguments -Wshadow: YES
Compiler for C supports arguments -Wsign-compare: YES
Compiler for C supports arguments -Wstrict-prototypes: YES
Compiler for C supports arguments -Wtype-limits: YES
Compiler for C supports arguments -Wmaybe-uninitialized: YES
Compiler for C supports arguments -Wdeclaration-after-statement: YES
Compiler for C supports arguments -Wunused-result: YES
Compiler for C supports arguments -D_FORTIFY_SOURCE=2: YES
Compiler for C supports arguments -O2: YES
meson.build:77: WARNING: Consider using the built-in warning_level option instead of using "-Wall".
meson.build:77: WARNING: Consider using the built-in optimization level instead of using "-O2".
Program git found: YES (/usr/bin/git)
Program env found: YES (/usr/bin/env)
Program /usr/bin/meson found: YES (/usr/bin/meson)
Found pkg-config: /usr/bin/pkg-config (1.8.0)
Run-time dependency libkmod found: YES 29
Run-time dependency libudev found: YES 249
Run-time dependency uuid found: YES 2.37.4
Run-time dependency json-c found: YES 0.15
Program asciidoctor found: YES (/usr/local/bin/asciidoctor)
Run-time dependency systemd found: YES 249
Run-time dependency udev found: YES 249
Library keyutils found: YES
Library iniparser found: YES
Has header "dlfcn.h" : YES
Has header "inttypes.h" : YES
Has header "keyutils.h" : YES
Has header "linux/version.h" : YES
Has header "memory.h" : YES
Has header "stdint.h" : YES
Has header "stdlib.h" : YES
Has header "strings.h" : YES
Has header "string.h" : YES
Has header "sys/stat.h" : YES
Has header "sys/types.h" : YES
Has header "unistd.h" : YES
Header <signal.h> has symbol "BUS_MCEERR_AR" : YES
Header <linux/mman.h> has symbol "MAP_SHARED_VALIDATE" : YES
Header <linux/mman.h> has symbol "MAP_SYNC" : YES
Checking for function "secure_getenv" : YES
Checking for function "__secure_getenv" : NO
Checking for function "json_object_new_uint64" with dependency json-c: YES
Configuring config.h using configuration
Program sed found: YES (/usr/bin/sed)
Program sed found: YES (/usr/bin/sed)
Program sed found: YES (/usr/bin/sed)
Program sed found: YES (/usr/bin/sed)
Program sed found: YES (/usr/bin/sed)
Program sed found: YES (/usr/bin/sed)
Program sed found: YES (/usr/bin/sed)
Program create.sh found: YES (/downloads/ndctl/test/create.sh)
Program clear.sh found: YES (/downloads/ndctl/test/clear.sh)
Program pmem-errors.sh found: YES (/downloads/ndctl/test/pmem-errors.sh)
Program daxdev-errors.sh found: YES (/downloads/ndctl/test/daxdev-errors.sh)
Program multi-dax.sh found: YES (/downloads/ndctl/test/multi-dax.sh)
Program btt-check.sh found: YES (/downloads/ndctl/test/btt-check.sh)
Program label-compat.sh found: YES (/downloads/ndctl/test/label-compat.sh)
Program sector-mode.sh found: YES (/downloads/ndctl/test/sector-mode.sh)
Program inject-error.sh found: YES (/downloads/ndctl/test/inject-error.sh)
Program btt-errors.sh found: YES (/downloads/ndctl/test/btt-errors.sh)
Program btt-pad-compat.sh found: YES (/downloads/ndctl/test/btt-pad-compat.sh)
Program firmware-update.sh found: YES (/downloads/ndctl/test/firmware-update.sh)
Program rescan-partitions.sh found: YES (/downloads/ndctl/test/rescan-partitions.sh)
Program inject-smart.sh found: YES (/downloads/ndctl/test/inject-smart.sh)
Program monitor.sh found: YES (/downloads/ndctl/test/monitor.sh)
Program max_available_extent_ns.sh found: YES (/downloads/ndctl/test/max_available_extent_ns.sh)
Program pfn-meta-errors.sh found: YES (/downloads/ndctl/test/pfn-meta-errors.sh)
Program track-uuid.sh found: YES (/downloads/ndctl/test/track-uuid.sh)
Program security.sh found: YES (/downloads/ndctl/test/security.sh)
Run-time dependency bash-completion found: YES 2.11
Program /usr/bin/meson found: YES (/usr/bin/meson)
Program sed found: YES (/usr/bin/sed)
Program /usr/bin/meson found: YES (/usr/bin/meson)
Program cat found: YES (/usr/bin/cat)
Program sed found: YES (/usr/bin/sed)
Build targets in project: 93

Found ninja-1.10.2 at /usr/bin/ninja
djbw commented 2 years ago

yeah, known issue, but warning_level enables even more warnings that need to be resolved first.

eli-schwartz commented 2 years ago

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.

djbw commented 2 years ago

@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', ]

djbw commented 2 years ago

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')