From 2889d38256906a5cbff717e7e524ec645c89c794 Mon Sep 17 00:00:00 2001 From: Thomas Monjalon Date: Wed, 8 Apr 2020 02:08:59 +0200 Subject: [PATCH] common/mlx5: fix build with -fno-common The variable storages of the same name are merged together if compiled with -fcommon. This is the default. This default behaviour allows to declare a variable in a header file and share the variable in every .o binaries thanks to merge at link-time. In the case of dlopen linking of the glue library, the pointer mlx5_glue is referencing the glue functions struct and is set after calling dlopen. If compiling with -fno-common (default in GCC 10), the variable must be declared as extern to avoid multiple re-definitions. In case the glue layer is split in glue library, the variable mlx5_glue needs to have its own storage for the rest of the PMD. Cc: stable@dpdk.org Signed-off-by: Thomas Monjalon Acked-by: Matan Azrad --- drivers/common/mlx5/mlx5_common.c | 3 +++ drivers/common/mlx5/mlx5_glue.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/common/mlx5/mlx5_common.c b/drivers/common/mlx5/mlx5_common.c index d8c01a5d14..42610459f7 100644 --- a/drivers/common/mlx5/mlx5_common.c +++ b/drivers/common/mlx5/mlx5_common.c @@ -18,6 +18,9 @@ int mlx5_common_logtype; +#ifdef MLX5_GLUE +const struct mlx5_glue *mlx5_glue; +#endif /** * Get PCI information by sysfs device path. diff --git a/drivers/common/mlx5/mlx5_glue.h b/drivers/common/mlx5/mlx5_glue.h index cd1136f382..184c41071e 100644 --- a/drivers/common/mlx5/mlx5_glue.h +++ b/drivers/common/mlx5/mlx5_glue.h @@ -304,6 +304,6 @@ struct mlx5_glue { size_t event_resp_len); }; -const struct mlx5_glue *mlx5_glue; +extern const struct mlx5_glue *mlx5_glue; #endif /* MLX5_GLUE_H_ */ -- 2.20.1