The flag '-Wno-address-of-packed-member' is a global warning flag in DPDK. Rather than disabling this warning globally, it is better to just have it enabled for components that may need it. This patch limits the scope of it in the following ways:
* limit the use of the flag to the drivers subfolder only - all libs and apps should be buildable without the warning. * exception is made for the vhost library and the ipsec-secgw example for now, as making them buildable with the warning enabled is more complicated. This exception can hopefully be removed in future. Limiting the scope further within the drivers directory is also left for future consideration. However, since HW drivers often have to use packed structures to align with hardware-implemented data layouts, it may be more practical to keep the warning disabled in the longer term. Signed-off-by: Bruce Richardson <bruce.richard...@intel.com> Acked-by: Stephen Hemminger <step...@networkplumber.org> Acked-by: Morten Brørup <m...@smartsharesystems.com> --- config/meson.build | 1 - drivers/meson.build | 9 ++++++--- examples/ipsec-secgw/meson.build | 6 ++++++ lib/vhost/meson.build | 5 ++++- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/config/meson.build b/config/meson.build index 8dae811378..5095d2fbcb 100644 --- a/config/meson.build +++ b/config/meson.build @@ -325,7 +325,6 @@ warning_flags = [ '-Wwrite-strings', # globally disabled warnings - '-Wno-address-of-packed-member', '-Wno-packed-not-aligned', '-Wno-missing-field-initializers', ] diff --git a/drivers/meson.build b/drivers/meson.build index 5270160c56..4a27f197a8 100644 --- a/drivers/meson.build +++ b/drivers/meson.build @@ -59,9 +59,12 @@ default_cflags = machine_args default_cflags += ['-DALLOW_EXPERIMENTAL_API'] default_cflags += ['-DALLOW_INTERNAL_API'] -if cc.has_argument('-Wno-format-truncation') - default_cflags += '-Wno-format-truncation' -endif +warning_disable_cflags = ['-Wno-format-truncation', '-Wno-address-of-packed-member'] +foreach cflag:warning_disable_cflags + if cc.has_argument(cflag) + default_cflags += cflag + endif +endforeach dpdk_drivers_build_dir = meson.current_build_dir() diff --git a/examples/ipsec-secgw/meson.build b/examples/ipsec-secgw/meson.build index ccdaef1c4d..023d9cf039 100644 --- a/examples/ipsec-secgw/meson.build +++ b/examples/ipsec-secgw/meson.build @@ -23,3 +23,9 @@ sources = files( 'sp4.c', 'sp6.c', ) +app_cflags = ['-Wno-address-of-packed-member'] +foreach flag:app_cflags + if cc.has_argument(flag) + cflags += flag + endif +endforeach diff --git a/lib/vhost/meson.build b/lib/vhost/meson.build index 41b622a9be..51bcf17244 100644 --- a/lib/vhost/meson.build +++ b/lib/vhost/meson.build @@ -16,7 +16,10 @@ elif (toolchain == 'icc' and cc.version().version_compare('>=16.0.0')) cflags += '-DVHOST_ICC_UNROLL_PRAGMA' endif dpdk_conf.set('RTE_LIBRTE_VHOST_POSTCOPY', cc.has_header('linux/userfaultfd.h')) -cflags += '-fno-strict-aliasing' +cflags += [ + '-fno-strict-aliasing', + '-Wno-address-of-packed-member', +] sources = files( 'fd_man.c', -- 2.43.0