From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: Matan Azrad <matan@mellanox.com>, Shahaf Shuler <shahafs@mellanox.com>
Subject: [dpdk-dev] [PATCH 3/3] net/mlx4: fix build with -fno-common
Date: Mon, 10 Feb 2020 11:32:16 +0100 [thread overview]
Message-ID: <20200210103216.1168439-4-thomas@monjalon.net> (raw)
In-Reply-To: <20200210103216.1168439-1-thomas@monjalon.net>
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 mlx4_glue
is referencing the glue functions struct and is set after calling dlopen.
If compiling with -fno-common (default in GCC 10), the variables
must be declared as extern to avoid multiple re-definitions.
In case the glue layer is split in glue library, the variable mlx4_glue
needs to have its own storage for the rest of the PMD.
Signed-off-by: Thomas Monjalon <thomas@monjalon.net>
---
drivers/net/mlx4/mlx4.c | 4 ++++
drivers/net/mlx4/mlx4_glue.h | 2 +-
drivers/net/mlx4/mlx4_rxtx.h | 2 +-
3 files changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/mlx4/mlx4.c b/drivers/net/mlx4/mlx4.c
index a1dd658176..49e721df5f 100644
--- a/drivers/net/mlx4/mlx4.c
+++ b/drivers/net/mlx4/mlx4.c
@@ -47,6 +47,10 @@
#include "mlx4_rxtx.h"
#include "mlx4_utils.h"
+#ifdef MLX4_GLUE
+const struct mlx4_glue *mlx4_glue = NULL;
+#endif
+
static const char *MZ_MLX4_PMD_SHARED_DATA = "mlx4_pmd_shared_data";
/* Shared memory between primary and secondary processes. */
diff --git a/drivers/net/mlx4/mlx4_glue.h b/drivers/net/mlx4/mlx4_glue.h
index 668ca86700..5d9e985495 100644
--- a/drivers/net/mlx4/mlx4_glue.h
+++ b/drivers/net/mlx4/mlx4_glue.h
@@ -84,6 +84,6 @@ struct mlx4_glue {
void *attr);
};
-const struct mlx4_glue *mlx4_glue;
+extern const struct mlx4_glue *mlx4_glue;
#endif /* MLX4_GLUE_H_ */
diff --git a/drivers/net/mlx4/mlx4_rxtx.h b/drivers/net/mlx4/mlx4_rxtx.h
index 8baf33fa94..9de6c59411 100644
--- a/drivers/net/mlx4/mlx4_rxtx.h
+++ b/drivers/net/mlx4/mlx4_rxtx.h
@@ -124,7 +124,7 @@ struct txq {
/* mlx4_rxq.c */
-uint8_t mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE];
+extern uint8_t mlx4_rss_hash_key_default[MLX4_RSS_HASH_KEY_SIZE];
int mlx4_rss_init(struct mlx4_priv *priv);
void mlx4_rss_deinit(struct mlx4_priv *priv);
struct mlx4_rss *mlx4_rss_get(struct mlx4_priv *priv, uint64_t fields,
--
2.25.0
next prev parent reply other threads:[~2020-02-10 10:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-10 10:32 [dpdk-dev] [PATCH 0/3] mlx: fix build with -fno-common (gcc 10) Thomas Monjalon
2020-02-10 10:32 ` [dpdk-dev] [PATCH 1/3] common/mlx5: split glue initialization Thomas Monjalon
2020-02-10 10:32 ` [dpdk-dev] [PATCH 2/3] common/mlx5: fix build with -fno-common Thomas Monjalon
2020-02-10 10:32 ` Thomas Monjalon [this message]
2020-03-17 8:34 ` [dpdk-dev] [PATCH 0/3] mlx: fix build with -fno-common (gcc 10) Matan Azrad
2020-04-07 0:19 ` Thomas Monjalon
2020-04-07 23:06 ` [dpdk-dev] [PATCH v2 " Thomas Monjalon
2020-04-07 23:06 ` [dpdk-dev] [PATCH v2 1/3] common/mlx5: split glue initialization Thomas Monjalon
2020-04-07 23:06 ` [dpdk-dev] [PATCH v2 2/3] common/mlx5: fix build with -fno-common Thomas Monjalon
2020-04-07 23:06 ` [dpdk-dev] [PATCH v2 3/3] net/mlx4: " Thomas Monjalon
2020-04-08 0:08 ` [dpdk-dev] [PATCH v3 0/3] mlx: fix build with -fno-common (gcc 10) Thomas Monjalon
2020-04-08 0:08 ` [dpdk-dev] [PATCH v3 1/3] common/mlx5: split glue initialization Thomas Monjalon
2020-04-08 0:08 ` [dpdk-dev] [PATCH v3 2/3] common/mlx5: fix build with -fno-common Thomas Monjalon
2020-04-08 0:09 ` [dpdk-dev] [PATCH v3 3/3] net/mlx4: " Thomas Monjalon
2020-04-12 15:51 ` [dpdk-dev] [PATCH v3 0/3] mlx: fix build with -fno-common (gcc 10) Raslan Darawsheh
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200210103216.1168439-4-thomas@monjalon.net \
--to=thomas@monjalon.net \
--cc=dev@dpdk.org \
--cc=matan@mellanox.com \
--cc=shahafs@mellanox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).