[1/2] meson/mlx5: Suppress -Wunused-value diagnostic

Message ID 20240412111317.3530529-1-sebastian.brzezinka@intel.com (mailing list archive)
State New
Delegated to: Thomas Monjalon
Headers
Series [1/2] meson/mlx5: Suppress -Wunused-value diagnostic |

Checks

Context Check Description
ci/checkpatch warning coding style issues

Commit Message

Sebastian Brzezinka April 12, 2024, 11:13 a.m. UTC
From: Alexey Marchuk <alexeymar@mellanox.com>

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:

Code:

        #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
                mlx5dv_create_flow_action_packet_reformat;
            #endif
            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]
                mlx5dv_create_flow_action_packet_reformat;
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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 below, 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 <alexeymar@mellanox.com>
Signed-off-by: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
---
 drivers/common/mlx5/linux/meson.build | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Comments

Stephen Hemminger Oct. 13, 2024, 9:16 p.m. UTC | #1
On Fri, 12 Apr 2024 13:13:16 +0200
Sebastian Brzezinka <sebastian.brzezinka@intel.com> wrote:

> From: Alexey Marchuk <alexeymar@mellanox.com>
> 
> 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:
> 
> Code:
> 
>         #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
>                 mlx5dv_create_flow_action_packet_reformat;
>             #endif
>             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]
>                 mlx5dv_create_flow_action_packet_reformat;
>                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> 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 below, 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 <alexeymar@mellanox.com>
> Signed-off-by: Sebastian Brzezinka <sebastian.brzezinka@intel.com>
> ---
>  drivers/common/mlx5/linux/meson.build | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build
> index cdee40c553..f3b8e5741b 100644
> --- a/drivers/common/mlx5/linux/meson.build
> +++ b/drivers/common/mlx5/linux/meson.build
> @@ -209,7 +209,11 @@ if  libmtcr_ul_found
>  endif
>  
>  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))
>  endforeach
>  foreach arg:has_member_args
>      file_prefix = '#include <' + arg[1] + '>'


Sigh, never liked that mlx5 decided to use pedantic unlike other drivers.
And the build process for this driver has become more baroque and unique compared
to all the other drivers in DPDK. What value to the user is this complexity?
  

Patch

diff --git a/drivers/common/mlx5/linux/meson.build b/drivers/common/mlx5/linux/meson.build
index cdee40c553..f3b8e5741b 100644
--- a/drivers/common/mlx5/linux/meson.build
+++ b/drivers/common/mlx5/linux/meson.build
@@ -209,7 +209,11 @@  if  libmtcr_ul_found
 endif
 
 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))
 endforeach
 foreach arg:has_member_args
     file_prefix = '#include <' + arg[1] + '>'