meson/mlx5: Suppress -Wunused-value diagnostic

Message ID (mailing list archive)
State Not Applicable
Delegated to: Raslan Darawsheh
Series meson/mlx5: Suppress -Wunused-value diagnostic |


Context Check Description
ci/checkpatch warning coding style issues
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/intel-Functional success Functional PASS
ci/iol-abi-testing success Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Sebastian Brzezinka April 5, 2024, 11:13 a.m. UTC
  From: Alexey Marchuk <>

mlx5 common library checks if several symbols/definitions
are presented in system header files. If some are not
presented, they will be enabled by mlx5_glue library.
The problem appears with clang and '-Werror' - code
generated by meson is not compiled due to unused variable:


        #include <infiniband/mlx5dv.h>
        int main(void) {
            /* If it's not defined as a macro, try to use as a symbol */
            #ifndef mlx5dv_create_flow_action_packet_reformat
            return 0;
Compiler stdout:

Compiler stderr:
 /hpc/local/work/alexeymar/repo/spdk/dpdk/build-tmp/meson-private/tmp5obnak86/testfile.c:6:17: error: expression result unused [-Werror,-Wunused-value]

As result, almost all symbols are enabled in mlx5_glue while
they exist is system headers. As result, we get multiple
symbols redefenitions when we compile mlx5_common.
As a solution for this problem we can suppress
-Wunused-vaurable using pragma

DPDK 23.11 note:
Starting with commit bellow, all cflags are passed to the has_header_symbol().
(33d6694) build: use C11 standard
To make sure that the symbol is properly detected, the pedantic flags needs to
be removed.

Signed-off-by: Alexey Marchuk <>
Signed-off-by: Sebastian Brzezinka <>
 drivers/common/mlx5/linux/ | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)


diff --git a/drivers/common/mlx5/linux/ b/drivers/common/mlx5/linux/
index b3a64547c5..84b2c64041 100644
--- a/drivers/common/mlx5/linux/
+++ b/drivers/common/mlx5/linux/
@@ -231,7 +231,11 @@  if  libmtcr_ul_found
 foreach arg:has_sym_args
-    mlx5_config.set(arg[0], cc.has_header_symbol(arg[1], arg[2], dependencies: libs, args: cflags))
+    file_prefix = '#pragma clang diagnostic ignored "-Wunused-value"'
+    cflags += [
+            '-Wno-pedantic',
+    ]
+    mlx5_config.set(arg[0], cc.has_header_symbol(arg[1], arg[2], prefix : file_prefix, dependencies: libs, args: cflags))
 foreach arg:has_member_args
     file_prefix = '#include <' + arg[1] + '>'