From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master] kbuild: don't define _GNU_SOURCE if already defined
Date: Wed, 2 Jul 2025 12:59:31 +0200 [thread overview]
Message-ID: <20250702105931.2231832-1-a.fatoum@pengutronix.de> (raw)
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
next reply other threads:[~2025-07-02 12:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-02 10:59 Ahmad Fatoum [this message]
2025-07-02 12:27 ` Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250702105931.2231832-1-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox