DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH v2] mk: suppress error for reference of packed members
@ 2017-01-24 21:04 Emmanuel Roullit
  2017-01-25 10:08 ` Thomas Monjalon
  0 siblings, 1 reply; 3+ messages in thread
From: Emmanuel Roullit @ 2017-01-24 21:04 UTC (permalink / raw)
  To: thomas.monjalon; +Cc: dev, stable

Found with clang build:
error: taking address of packed member 'mlock' of class or structure
'rte_mem_config' may result in an unaligned pointer value
[-Werror,-Waddress-of-packed-member]

Fixes: 29361d4c91ed ("mk: fix build with clang < 3.5")
Fixes: b2bb3a5daaac ("mk: stop on warning only in developer build")

Signed-off-by: Emmanuel Roullit <emmanuel.roullit@gmail.com>
---

v2:
* Only apply compiler flag on clang >= 4.0

 mk/toolchain/clang/rte.toolchain-compat.mk | 4 ++++
 mk/toolchain/clang/rte.vars.mk             | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/mk/toolchain/clang/rte.toolchain-compat.mk b/mk/toolchain/clang/rte.toolchain-compat.mk
index b734413b6..153d2f005 100644
--- a/mk/toolchain/clang/rte.toolchain-compat.mk
+++ b/mk/toolchain/clang/rte.toolchain-compat.mk
@@ -47,3 +47,7 @@ CLANG_MINOR_VERSION := $(shell echo $(CLANG_VERSION) | cut -f2 -d.)
 ifeq ($(shell test $(CLANG_MAJOR_VERSION)$(CLANG_MINOR_VERSION) -lt 35 && echo 1), 1)
 	CC_SUPPORTS_Z := false
 endif
+
+ifeq ($(shell test $(CLANG_MAJOR_VERSION)$(CLANG_MINOR_VERSION) -ge 40 && echo 1), 1)
+	CC_PACKED_MEMBER_WERROR := true
+endif
diff --git a/mk/toolchain/clang/rte.vars.mk b/mk/toolchain/clang/rte.vars.mk
index 7749b991b..a797b7aab 100644
--- a/mk/toolchain/clang/rte.vars.mk
+++ b/mk/toolchain/clang/rte.vars.mk
@@ -76,6 +76,10 @@ endif
 # process cpu flags
 include $(RTE_SDK)/mk/toolchain/$(RTE_TOOLCHAIN)/rte.toolchain-compat.mk
 
+ifeq ($(CC_PACKED_MEMBER_WERROR),true)
+WERROR_FLAGS += -Wno-address-of-packed-member
+endif
+
 # workaround clang bug with warning "missing field initializer" for "= {0}"
 WERROR_FLAGS += -Wno-missing-field-initializers
 
-- 
2.11.0

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-01-25 20:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-01-24 21:04 [dpdk-dev] [PATCH v2] mk: suppress error for reference of packed members Emmanuel Roullit
2017-01-25 10:08 ` Thomas Monjalon
2017-01-25 20:52   ` Emmanuel Roullit

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).