Skip to contentSkip to conversation

examples: fix building with GCC 10

PATCH In review Timothy Redaelli 4 participants 9 messages Feb 5, 2020 – Mar 4, 2020

lore
Share & tools
lore
#0 lore raw

cover examples: fix building with GCC 10

GCC 10 defaults to -fno-common, this means a linker error will now be reported if the same global variable is defined in more than one compilation unit.

See https://gcc.gnu.org/gcc-10/porting_to.html for more informations.

I didn't put -fcommon to CFLAGS since:
Compiling with -fno-common is useful on targets for which it provides better performance, or if you wish to verify that the program will work on other systems that always treat uninitialized variable definitions this way.
from gcc man page

Timothy Redaelli (3):
examples/vhost_blk: fix building with GCC 10 examples/eventdev_pipeline: fix building with GCC 10 examples/qos_sched: fix building with GCC 10

 examples/eventdev_pipeline/main.c            | 2 ++
 examples/eventdev_pipeline/pipeline_common.h | 4 ++--
 examples/qos_sched/cfg_file.c                | 3 +++
 examples/qos_sched/main.h                    | 4 ++--
 examples/vhost_blk/vhost_blk.c               | 2 ++
 examples/vhost_blk/vhost_blk.h               | 4 ++--
 6 files changed, 13 insertions(+), 6 deletions(-)
Signature · 1 line
2.24.1
#1 lore raw

PATCH 1/3 examples/vhost_blk: fix building with GCC 10

GCC 10 defaults to -fno-common, this means a linker error will now be reported if the same global variable is defined in more than one compilation unit.

Fixes c19beb3f38cd ("examples/vhost_blk: introduce vhost storage sample")
---
 examples/vhost_blk/vhost_blk.c | 2 ++
 examples/vhost_blk/vhost_blk.h | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)
examples/vhost_blk/vhost_blk.c +2 -0
index e1036bf3a..143ae19f3 100644
@@ -31,6 +31,8 @@
 			    (1ULL << VIRTIO_F_NOTIFY_ON_EMPTY) | \
 			    (1ULL << VHOST_USER_F_PROTOCOL_FEATURES))
 
+struct vhost_blk_ctrlr *g_vhost_ctrlr;
+
 /* Path to folder where character device will be created. Can be set by user. */
 static char dev_pathname[PATH_MAX] = "";
 static sem_t exit_sem;
examples/vhost_blk/vhost_blk.h +2 -2
index 933e2b7c5..17258d284 100644
@@ -112,8 +112,8 @@ struct inflight_blk_task {
 	struct rte_vhost_inflight_info_packed *inflight_packed;
 };
 
-struct vhost_blk_ctrlr *g_vhost_ctrlr;
-struct vhost_device_ops vhost_blk_device_ops;
+extern struct vhost_blk_ctrlr *g_vhost_ctrlr;
+extern struct vhost_device_ops vhost_blk_device_ops;
 
 int vhost_bdev_process_blk_commands(struct vhost_block_dev *bdev,
 				     struct vhost_blk_task *task);
Signature · 1 line
2.24.1
Reviewed-by on v1 1/3
#2 lore raw

Re: [dpdk-dev] [PATCH 1/3] examples/vhost_blk: fix building with GCC 10

Quoted 4 lines · Timothy Redaelli

GCC 10 defaults to -fno-common, this means a linker error will now be reported if the same global variable is defined in more than one compilation unit.

Quoted 9 lines
Fixes c19beb3f38cd ("examples/vhost_blk: introduce vhost storage sample")
---
 examples/vhost_blk/vhost_blk.c | 2 ++
 examples/vhost_blk/vhost_blk.h | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)

Thanks,
Maxime

#3 lore raw

PATCH v2 3/3 app/test-pipeline: fix building with GCC 10

In reply to Timothy Redaelli

GCC 10 defaults to -fno-common, this means a linker error will now be reported if the same global variable is defined in more than one compilation unit.

Fixes 48f31ca50cc4 ("app/pipeline: packet framework benchmark")

---

v2:
app is already declared as extern in main.h. (as reported by David)

---
 app/test-pipeline/config.c | 2 --
 1 file changed, 2 deletions(-)
app/test-pipeline/config.c +0 -2
index 28ac9fcc0..33f3f1c82 100644
@@ -42,8 +42,6 @@
 
 #include "main.h"
 
-struct app_params app;
-
 static const char usage[] = "\n";
 
 void
Signature · 1 line
2.24.1
Acked-by on v2 3/3
#4 lore raw

Re: [dpdk-dev] [PATCH v2 3/3] app/test-pipeline: fix building with GCC 10

Quoted 41 lines

-----Original Message-----
From: Timothy Redaelli <[email protected]>
Sent: Wednesday, February 5, 2020 2:12 PM
To: [email protected]
Cc: [email protected]; [email protected]; Dumitrescu, Cristian <[email protected]>
Subject: [PATCH v2 3/3] app/test-pipeline: fix building with GCC 10

GCC 10 defaults to -fno-common, this means a linker error will now be reported if the same global variable is defined in more than one compilation unit.

Fixes 48f31ca50cc4 ("app/pipeline: packet framework benchmark")

---

v2:
app is already declared as extern in main.h. (as reported by David)

---
 app/test-pipeline/config.c | 2 --
 1 file changed, 2 deletions(-)
app/test-pipeline/config.c +0 -3
index 28ac9fcc0..33f3f1c82 100644
@@ -42,8 +42,6 @@
 
 #include "main.h"
 
-struct app_params app;
-
 static const char usage[] = "\n";
 
 void
--
Quoted 1 line

2.24.1

Yes, app is declared in main.h and defined & initialized in init.c, no need to have it defined the second time in config.c.

#5 lore raw

PATCH 2/3 examples/eventdev_pipeline: fix building with GCC 10

In reply to Timothy Redaelli
Fixes 3d1b33e44ae2 ("examples/eventdev: move common data into pipeline common")
---
 examples/eventdev_pipeline/main.c            | 2 ++
 examples/eventdev_pipeline/pipeline_common.h | 4 ++--
 2 files changed, 4 insertions(+), 2 deletions(-)
examples/eventdev_pipeline/main.c +2 -0
index d3ff1bbe4..d0da51b1c 100644
@@ -10,6 +10,8 @@
 
 #include "pipeline_common.h"
 
+struct fastpath_data *fdata;
+
 struct config_data cdata = {
 	.num_packets = (1L << 25), /* do ~32M packets */
 	.num_fids = 512,
examples/eventdev_pipeline/pipeline_common.h +2 -2
index 8e30393d0..c7245f7f0 100644
@@ -93,8 +93,8 @@ struct port_link {
 	uint8_t priority;
 };
 
-struct fastpath_data *fdata;
-struct config_data cdata;
+extern struct fastpath_data *fdata;
+extern struct config_data cdata;
 
 static __rte_always_inline void
 exchange_mac(struct rte_mbuf *m)
Signature · 1 line
2.24.1
#6 lore raw

PATCH 3/3 examples/qos_sched: fix building with GCC 10

In reply to Timothy Redaelli

GCC 10 defaults to -fno-common, this means a linker error will now be reported if the same global variable is defined in more than one compilation unit.

Fixes be1e533238c0 ("examples/qos_sched: add TC and queue config flexibility")
---
 examples/qos_sched/cfg_file.c | 3 +++
 examples/qos_sched/main.h     | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)
examples/qos_sched/cfg_file.c +3 -0
index 5714c3f36..f078e4f7d 100644
@@ -20,6 +20,9 @@
  * for new entries do we add in */
 #define CFG_ALLOC_ENTRY_BATCH 16
 
+uint32_t active_queues[RTE_SCHED_QUEUES_PER_PIPE];
+uint32_t n_active_queues;
+
 int
 cfg_load_port(struct rte_cfgfile *cfg, struct rte_sched_port_params *port_params)
 {
examples/qos_sched/main.h +2 -2
index baa2b3ead..23bc418d9 100644
@@ -148,8 +148,8 @@ extern struct burst_conf burst_conf;
 extern struct ring_thresh rx_thresh;
 extern struct ring_thresh tx_thresh;
 
-uint32_t active_queues[RTE_SCHED_QUEUES_PER_PIPE];
-uint32_t n_active_queues;
+extern uint32_t active_queues[RTE_SCHED_QUEUES_PER_PIPE];
+extern uint32_t n_active_queues;
 
 extern struct rte_sched_port_params port_params;
 extern struct rte_sched_subport_params subport_params[MAX_SCHED_SUBPORTS];
Signature · 1 line
2.24.1
Acked-by on the v1 series
#7 lore raw
In reply to Timothy Redaelli
Quoted 5 lines · Timothy Redaelli

GCC 10 defaults to -fno-common, this means a linker error will now be reported if the same global variable is defined in more than one compilation unit.

Quoted 8 lines

See https://gcc.gnu.org/gcc-10/porting_to.html for more informations.

I didn't put -fcommon to CFLAGS since:
Compiling with -fno-common is useful on targets for which it provides better performance, or if you wish to verify that the program will work on other systems that always treat uninitialized variable definitions this way.
from gcc man page

For the series,

Signature · 1 line
David Marchand
#8 lore raw
Quoted 16 lines · David Marchand
Quoted 5 lines · Timothy Redaelli

GCC 10 defaults to -fno-common, this means a linker error will now be reported if the same global variable is defined in more than one compilation unit.

Quoted 8 lines

See https://gcc.gnu.org/gcc-10/porting_to.html for more informations.

I didn't put -fcommon to CFLAGS since:
Compiling with -fno-common is useful on targets for which it provides better performance, or if you wish to verify that the program will work on other systems that always treat uninitialized variable definitions this way.
from gcc man page

Quoted 2 lines

For the series,

Series applied, thanks.

Signature · 1 line
David Marchand