Skip to contentSkip to conversation

tools: Stop re-defining -std= when building tools

PATCH In review Tom Rini 1 participant 2 messages Oct 11, 2021 – Oct 20, 2021 Kbuild

lore
Share & tools
lore

Tom Rini

author
#0 lore raw

PATCH v2 1/1 tools: Stop re-defining -std= when building tools

While we intentionally set -std=gnu11 for building host tools, and have
for quite some time, we never dropped -std=gnu99 from tools/Makefile.
This resulted in passing -std=gnu11 ... -std=gnu99 when building, and
gnu99 would win. This in turn would result now in warnings such as:
tools/mkeficapsule.c:25:15: warning: redefinition of typedef 'u32' is a C11 feature [-Wtypedef-redefinition]

typedef __u32 u32;
              ^

---
Changes in v2:
- Always use -std=gnu11 after Bin pointed out that we have only been enforcing this for Linux hosts.

---
 Makefile       | 2 --
 tools/Makefile | 3 +--
 2 files changed, 1 insertion(+), 4 deletions(-)
Makefile +0 -2
index f911f7034430..723f80e34459 100644
@@ -299,9 +299,7 @@ KBUILD_HOSTLDLIBS   := $(HOST_LFS_LIBS) $(HOSTLDLIBS)
 # have older compilers as their default, so we make it explicit for
 # these that our host tools are GNU11 (i.e. C11 w/ GNU extensions).
 CSTD_FLAG := -std=gnu11
-ifeq ($(HOSTOS),linux)
 KBUILD_HOSTCFLAGS += $(CSTD_FLAG)
-endif
 
 ifeq ($(HOSTOS),cygwin)
 KBUILD_HOSTCFLAGS	+= -ansi
tools/Makefile +1 -2
index 999fd4653166..b45219e2c30c 100644
@@ -295,8 +295,7 @@ HOST_EXTRACFLAGS += -include $(srctree)/include/compiler.h \
 		-I$(srctree)/tools \
 		-DUSE_HOSTCC \
 		-D__KERNEL_STRICT_NAMES \
-		-D_GNU_SOURCE \
-		-std=gnu99
+		-D_GNU_SOURCE
 
 __build:	$(LOGO-y)
 
Signature · 1 line
2.25.1
author
#1 lore raw
Quoted 9 lines · Tom Rini

While we intentionally set -std=gnu11 for building host tools, and have
for quite some time, we never dropped -std=gnu99 from tools/Makefile.
This resulted in passing -std=gnu11 ... -std=gnu99 when building, and
gnu99 would win. This in turn would result now in warnings such as:
tools/mkeficapsule.c:25:15: warning: redefinition of typedef 'u32' is a C11 feature [-Wtypedef-redefinition]

typedef __u32 u32;
              ^

Applied to u-boot/master, thanks!

Signature · 1 line
Tom