patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Thomas Monjalon <thomas@monjalon.net>
To: dev@dpdk.org
Cc: stable@dpdk.org, Matan Azrad <matan@mellanox.com>,
	Shahaf Shuler <shahafs@mellanox.com>,
	Viacheslav Ovsiienko <viacheslavo@mellanox.com>
Subject: [dpdk-stable] [PATCH v3 2/3] common/mlx5: fix build with -fno-common
Date: Wed,  8 Apr 2020 02:08:59 +0200	[thread overview]
Message-ID: <20200408000900.61896-3-thomas@monjalon.net> (raw)
In-Reply-To: <20200408000900.61896-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 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 <thomas@monjalon.net>
Acked-by: Matan Azrad <matan@mellanox.com>
---
 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 6238b43946..29678623e4 100644
--- a/drivers/common/mlx5/mlx5_glue.h
+++ b/drivers/common/mlx5/mlx5_glue.h
@@ -300,6 +300,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.26.0


  parent reply	other threads:[~2020-04-08  0:09 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20200210103216.1168439-1-thomas@monjalon.net>
     [not found] ` <AM0PR0502MB401926F72A8C41B49ED91296D2F60@AM0PR0502MB4019.eurprd05.prod.outlook.com>
2020-04-07  0:19   ` [dpdk-stable] [dpdk-dev] [PATCH 0/3] mlx: fix build with -fno-common (gcc 10) Thomas Monjalon
     [not found] ` <20200407230647.59478-1-thomas@monjalon.net>
2020-04-07 23:06   ` [dpdk-stable] [PATCH v2 2/3] common/mlx5: fix build with -fno-common Thomas Monjalon
2020-04-07 23:06   ` [dpdk-stable] [PATCH v2 3/3] net/mlx4: " Thomas Monjalon
     [not found] ` <20200408000900.61896-1-thomas@monjalon.net>
2020-04-08  0:08   ` Thomas Monjalon [this message]
2020-04-08  0:09   ` [dpdk-stable] [PATCH v3 " Thomas Monjalon

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=20200408000900.61896-3-thomas@monjalon.net \
    --to=thomas@monjalon.net \
    --cc=dev@dpdk.org \
    --cc=matan@mellanox.com \
    --cc=shahafs@mellanox.com \
    --cc=stable@dpdk.org \
    --cc=viacheslavo@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).