Skip to contentSkip to conversation

build: fix meson warning about using compiler warning flags

PATCH Applied Bruce Richardson 3 participants 4 messages Jan 21, 2022 – Feb 2, 2022 Arm/Amlogic Meson SoC support

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 build: fix meson warning about using compiler warning flags

Each build, meson would issue a warning reporting that the "warning_level" setting should be used in place of adding -Wextra directly to our build commands. Testing with meson 0.61 shows that the only difference for gcc and clang builds between warning levels 1 and 2 is the addition of -Wextra, so we can remove the warning by deleting our explicit set of Wextra and changing the build defaults to warning_level 2.

Fixes 524a0d5d66b9 ("build: enable extra warnings with meson")

---

NOTE1: Not putting CC stable for this patch, I don't believe it's worth the risk of backporting.

NOTE2: For reference, when building a test "hello world" project with different warning levels, the following flags are used by meson:

warning_level=0: <none>
warning_level=1: -Wall -Winvalid-pch warning_level=2: -Wall -Winvalid-pch -Wextra warning_level=3: -Wall -Winvalid-pch -Wextra -Wpedantic

---
 config/meson.build | 5 ++---
 meson.build        | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)
config/meson.build +2 -3
index ee12318d4f..7134e80e8d 100644
@@ -247,10 +247,9 @@ endif
 add_project_arguments('-include', 'rte_config.h', language: 'c')
 
 # enable extra warnings and disable any unwanted warnings
+# -Wall is added by default at warning level 1, and -Wextra
+# at warning level 2 (DPDK default)
 warning_flags = [
-        # -Wall is added by meson by default, so add -Wextra only
-        '-Wextra',
-
         # additional warnings in alphabetical order
         '-Wcast-qual',
         '-Wdeprecated',
meson.build +1 -1
index 1223b79d74..070243a33d 100644
@@ -7,7 +7,7 @@ project('DPDK', 'C',
         version: run_command(find_program('cat', 'more'),
             files('VERSION'), check: true).stdout().strip(),
         license: 'BSD',
-        default_options: ['buildtype=release', 'default_library=static'],
+        default_options: ['buildtype=release', 'default_library=static', 'warning_level=2'],
         meson_version: '>= 0.49.2'
 )
 
Signature · 1 line
2.32.0
#1 lore raw

PATCH v2 1/1 build: fix meson warning about using compiler warning flags

Each build, meson would issue a warning reporting that the "warning_level" setting should be used in place of adding -Wextra directly to our build commands. Testing with meson 0.61 shows that the only difference for gcc and clang builds between warning levels 1 and 2 is the addition of -Wextra, so we can remove the warning by deleting our explicit set of Wextra and changing the build defaults to warning_level 2.

Fixes 524a0d5d66b9 ("build: enable extra warnings with meson")

---
V2: fixed CI apply issues due to V1 being based on top of patch
'build: fix warnings when running external commands'

NOTE1: Not putting CC stable for this patch, I don't believe it's worth the risk of backporting.

NOTE2: For reference, when building a test "hello world" project with different warning levels, the following flags are used by meson:

warning_level=0: <none>
warning_level=1: -Wall -Winvalid-pch warning_level=2: -Wall -Winvalid-pch -Wextra warning_level=3: -Wall -Winvalid-pch -Wextra -Wpedantic

---
 config/meson.build | 5 ++---
 meson.build        | 2 +-
 2 files changed, 3 insertions(+), 4 deletions(-)
config/meson.build +2 -3
index 805d5d51d0..cb236d9187 100644
@@ -246,10 +246,9 @@ endif
 add_project_arguments('-include', 'rte_config.h', language: 'c')
 
 # enable extra warnings and disable any unwanted warnings
+# -Wall is added by default at warning level 1, and -Wextra
+# at warning level 2 (DPDK default)
 warning_flags = [
-        # -Wall is added by meson by default, so add -Wextra only
-        '-Wextra',
-
         # additional warnings in alphabetical order
         '-Wcast-qual',
         '-Wdeprecated',
meson.build +1 -1
index 12cb6e0e83..0a844bce9e 100644
@@ -7,7 +7,7 @@ project('DPDK', 'C',
         version: run_command(find_program('cat', 'more'),
             files('VERSION')).stdout().strip(),
         license: 'BSD',
-        default_options: ['buildtype=release', 'default_library=static'],
+        default_options: ['buildtype=release', 'default_library=static', 'warning_level=2'],
         meson_version: '>= 0.49.2'
 )
 
Signature · 1 line
2.32.0
Acked-by on v1 1/1
#2 lore raw
In reply to Bruce Richardson
Quoted 56 lines · Bruce Richardson

Each build, meson would issue a warning reporting that the "warning_level" setting should be used in place of adding -Wextra directly to our build commands. Testing with meson 0.61 shows that the only difference for gcc and clang builds between warning levels 1 and 2 is the addition of -Wextra, so we can remove the warning by deleting our explicit set of Wextra and changing the build defaults to warning_level 2.

Fixes 524a0d5d66b9 ("build: enable extra warnings with meson")

---

NOTE1: Not putting CC stable for this patch, I don't believe it's worth the risk of backporting.

NOTE2: For reference, when building a test "hello world" project with different warning levels, the following flags are used by meson:

warning_level=0: <none>
warning_level=1: -Wall -Winvalid-pch warning_level=2: -Wall -Winvalid-pch -Wextra warning_level=3: -Wall -Winvalid-pch -Wextra -Wpedantic
---
 config/meson.build | 5 ++---
 meson.build | 2 +-

 2 files changed, 3 insertions(+), 4 deletions(-)
config/meson.build +0 -0
index ee12318d4f..7134e80e8d 100644
@@ -247,10 +247,9 @@ endif
  add_project_arguments('-include', 'rte_config.h', language: 'c')

 # enable extra warnings and disable any unwanted warnings
config/meson.build +2 -0
+# -Wall is added by default at warning level 1, and -Wextra
+# at warning level 2 (DPDK default)

 warning_flags = [

config/meson.build +0 -3
-        # -Wall is added by meson by default, so add -Wextra only
-        '-Wextra',
-
         # additional warnings in alphabetical order
         '-Wcast-qual',
         '-Wdeprecated',
meson.build +1 -1
index 1223b79d74..070243a33d 100644
@@ -7,7 +7,7 @@ project('DPDK', 'C',
          version: run_command(find_program('cat', 'more'),
              files('VERSION'), check: true).stdout().strip(),
          license: 'BSD',
-        default_options: ['buildtype=release', 'default_library=static'],
+        default_options: ['buildtype=release', 'default_library=static', 'warning_level=2'],
Quoted 4 lines

         meson_version: '>= 0.49.2'
 )

Signature · 2 lines
Kind regards,
Luca Boccassi
#3 lore raw

21/01/2022 17:41, Luca Boccassi:

Quoted 20 lines · Bruce Richardson
Quoted 19 lines

Each build, meson would issue a warning reporting that the "warning_level" setting should be used in place of adding -Wextra directly to our build commands. Testing with meson 0.61 shows that the only difference for gcc and clang builds between warning levels 1 and 2 is the addition of -Wextra, so we can remove the warning by deleting our explicit set of Wextra and changing the build defaults to warning_level 2.

Fixes 524a0d5d66b9 ("build: enable extra warnings with meson")

---

NOTE1: Not putting CC stable for this patch, I don't believe it's worth the risk of backporting.

NOTE2: For reference, when building a test "hello world" project with different warning levels, the following flags are used by meson:

Quoted 7 lines
Quoted 5 lines

warning_level=0: <none>
warning_level=1: -Wall -Winvalid-pch warning_level=2: -Wall -Winvalid-pch -Wextra warning_level=3: -Wall -Winvalid-pch -Wextra -Wpedantic
---

Applied, thanks.