From ed7515a5c07addaa3338a24efb36b74fbd1844dc Mon Sep 17 00:00:00 2001
From: Christopher Larson <chris_larson@mentor.com>
Date: Mon, 21 Jul 2025 13:52:00 +0800
Subject: [PATCH] bash: fix mkbuiltins build failure

On hosts with FORTIFY_SOURCES, stringize support is required, as it's used by
the macros to wrap functions (e.g. read and open in unistd.h). Those wrappers
use the STRING() macro from unistd.h. A header in the bash sources overrides
the unistd.h macro to 'x' when HAVE_STRINGIZE is not defined, causing the
wrappers to generate calls to 'xread' and 'xopen', which do not exist,
resulting in a failure to link.

Assume we have stringize support when cross-compiling, which works around the
issue.

It may be best for upstream to either give up on supporting compilers without
stringize support, or to not define STRING() at all when FORTIFY_SOURCES is
defined, letting the unistd.h one be used, instead.

Upstream-Status: Pending

Signed-off-by: Christopher Larson <chris_larson@mentor.com>

Rebase to 5.3
Signed-off-by: Hongxu Jia <hongxu.jia@windriver.com>
---
 builtins/mkbuiltins.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/builtins/mkbuiltins.c b/builtins/mkbuiltins.c
index c4cacdf..05d1db1 100644
--- a/builtins/mkbuiltins.c
+++ b/builtins/mkbuiltins.c
@@ -24,6 +24,7 @@
 #else	/* CROSS_COMPILING */
 /* A conservative set of defines based on POSIX/SUS3/XPG6 */
 #  include <buildconf.h>
+# define HAVE_STRINGIZE
 #endif /* CROSS_COMPILING */
 
 #if defined (HAVE_UNISTD_H)
-- 
2.34.1

