[PATCH master 1/2] scripts: define _GNU_SOURCE for every user tool build

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Feb 19 22:46:11 PST 2025


Defining _GNU_SOURCE via userccflags (for target tools) and KBUILD_HOSTCFLAGS
(for host tools) works, but needs to be repeated in subdirectories like i.MX
as well. As we make ample use of the asprintf GNU extension anyway, let's just
define it in the top-level makefile for build of all user code.

Fixes: 02a61edc1842 ("scripts: define _GNU_SOURCE for all source files")
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 Makefile         | 3 ++-
 scripts/Makefile | 4 ----
 2 files changed, 2 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 5488f9d97251..4e6ac5a10a97 100644
--- a/Makefile
+++ b/Makefile
@@ -399,7 +399,8 @@ HOSTCXX	= g++
 endif
 
 KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
-			      -O2 -fomit-frame-pointer -std=gnu11
+			      -O2 -fomit-frame-pointer -std=gnu11 \
+			      -D_GNU_SOURCE=""
 KBUILD_USERCFLAGS  := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS)
 KBUILD_USERLDFLAGS := $(USERLDFLAGS)
 
diff --git a/scripts/Makefile b/scripts/Makefile
index bb4e85b0a639..6d89af7d4f35 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -60,10 +60,6 @@ rk-usb-loader-target-userldlibs += `$(CROSS_PKG_CONFIG) --libs libusb-1.0`
 
 userccflags += -I $(srctree)/$(src)/include -isystem $(srctree)/scripts/include
 
-# We need to explicitly set the macro to empty, otherwise it's defined to =1
-userccflags += -D_GNU_SOURCE=""
-KBUILD_HOSTCFLAGS += -D_GNU_SOURCE=""
-
 subdir-y			+= mod
 subdir-y			+= imx
 subdir-$(CONFIG_ARCH_TEGRA)	+= tegra
-- 
2.39.5




More information about the barebox mailing list