* [PATCH master] kbuild: don't define _GNU_SOURCE if already defined
@ 2025-07-02 10:59 Ahmad Fatoum
2025-07-02 12:27 ` Sascha Hauer
0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2025-07-02 10:59 UTC (permalink / raw)
To: barebox; +Cc: Ahmad Fatoum
When built with PTXdist, compilation of some files like
scripts/kconfig/lxdialog/yesno.c ends up with multiple differing definitions
for _GNU_SOURCE:
gcc [...] -std=gnu11 -D_GNU_SOURCE="" -D_GNU_SOURCE -I/usr/include/ncursesw
This leads to ugly warnings when running ptxdist menuconfig.
This is due to a hardcoded `echo -D_GNU_SOURCE > ${cflags}` we fall back
to in mconf-cfg.sh, when there is no pkg-config file for ncurses, which
seems to be the case for PTXdist.
Fix the warnings by defining _GNU_SOURCE only if it's not already
defined.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
Makefile | 2 +-
scripts/include/defines.h | 6 ++++++
2 files changed, 7 insertions(+), 1 deletion(-)
create mode 100644 scripts/include/defines.h
diff --git a/Makefile b/Makefile
index d9bfaa8cce1b..59531a326d81 100644
--- a/Makefile
+++ b/Makefile
@@ -406,7 +406,7 @@ endif
KBUILD_USERHOSTCFLAGS := -Wall -Wmissing-prototypes -Wstrict-prototypes \
-O2 -fomit-frame-pointer -std=gnu11 \
- -D_GNU_SOURCE=""
+ -include $(srctree)/scripts/include/defines.h
KBUILD_USERCFLAGS := $(KBUILD_USERHOSTCFLAGS) $(USERCFLAGS)
KBUILD_USERLDFLAGS := $(USERLDFLAGS)
diff --git a/scripts/include/defines.h b/scripts/include/defines.h
new file mode 100644
index 000000000000..dd28765f9e7d
--- /dev/null
+++ b/scripts/include/defines.h
@@ -0,0 +1,6 @@
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/* This file is autoincluded for all user programs */
+
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
--
2.39.5
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-07-02 12:46 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-07-02 10:59 [PATCH master] kbuild: don't define _GNU_SOURCE if already defined Ahmad Fatoum
2025-07-02 12:27 ` Sascha Hauer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox