Skip to contentSkip to conversation

package/enscript: fix build issue with musl and gcc >= 15

PATCH In review Thomas Petazzoni via buildroot 1 participant 2 messages Aug 22

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/enscript: fix build issue with musl and gcc >= 15

enscript currently fails to build with musl with gcc >= 15. In order to fix this, we need to bring a number of patches from upstream, and add 2 others that were submitted upstream.

From upstream, we bring 0002-Add-CFLAG-std-c89-so-it-compiles-with-the-old-standa.patch, which switches to -std=c89 to get the compiler back to "old" behavior.

However, as this commit patches configure.ac, we need to autoreconf, but autoreconf is broken, so we also take 0003-Automake-1.12-and-up-no-longer-supports-pre-ANSI.patch from upstream, which drops a problematic autoconf macro.

However, once you drop this problematic autoconf macro, the PROTOTYPES define is never set by anything, causing the __P macro to no longer be defined properly. This is fixed by 0004-Fix-prototype-detection-when-__STDC__-is-defined-but.patch that we have submitted upstream.

Once you're there, you realize that switching to -std=c89 has the side effect that musl's <limits.h> no longer defines PATH_MAX, because it needs one of:

  #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
   || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE)

and a side effect of -std=c89 is that none of these is defined anymore. So we introduce 0005-Use-std-gnu89-instead-of-std-c89.patch, which switches to -std=gnu89. This patch has also been submitted upstream.

With all of these efforts, we get a successful build on musl with gcc

Quoted 1 line

= 15.

This commit needs to be backported to Buildroot versions that support gcc 15.x, so that means the currently maintained 2026.x branches, but not 2025.02 as only up to gcc 14.x was supported then.

Fixes:

https://autobuild.buildroot.org/results/d39d14bbbb3a51d67fe962b877c7f66ff1204ecf/

---
Note: when there's something as atrocious as
https://cgit.git.savannah.gnu.org/cgit/enscript.git/tree/update-install.sh
in the project's official upstream repo, it's a sign the project is quite badly maintained...

---
 ...9-so-it-compiles-with-the-old-standa.patch |  29 +++++
 package/enscript/0002-enscript-c23.patch      |  19 ----
 ...2-and-up-no-longer-supports-pre-ANSI.patch |  28 +++++
 ...tection-when-__STDC__-is-defined-but.patch | 107 ++++++++++++++++++
 ...005-Use-std-gnu89-instead-of-std-c89.patch |  35 ++++++
 package/enscript/enscript.mk                  |   4 +
 6 files changed, 203 insertions(+), 19 deletions(-)
 create mode 100644 package/enscript/0002-Add-CFLAG-std-c89-so-it-compiles-with-the-old-standa.patch
 delete mode 100644 package/enscript/0002-enscript-c23.patch
 create mode 100644 package/enscript/0003-Automake-1.12-and-up-no-longer-supports-pre-ANSI.patch
 create mode 100644 package/enscript/0004-Fix-prototype-detection-when-__STDC__-is-defined-but.patch
 create mode 100644 package/enscript/0005-Use-std-gnu89-instead-of-std-c89.patch
package/enscript/0002-Add-CFLAG-std-c89-so-it-compiles-with-the-old-standa.patch new file +29 -0
new file mode 100644
index 0000000000..a75454af7b
@@ -0,0 +1,29 @@
+From c0c7e9ad51b2e9aebea46f0179446fcf896f8d63 Mon Sep 17 00:00:00 2001
+From: Wim Stockman <[email protected]>
+Date: Fri, 20 Feb 2026 10:51:37 +0100
+Subject: [PATCH] Add CFLAG=-std=c89 so it compiles with the old standard,
+ modern standard gives problems
+
+Upstream: https://git.savannah.gnu.org/cgit/enscript.git/commit/?id=111ad375a6e598c896441e10f4cf1e2fc1496c42
+Signed-off-by: Thomas Petazzoni <[email protected]>
+---
+ configure.ac | 3 +++
+ 1 file changed, 3 insertions(+)
+
+diff --git a/configure.ac b/configure.ac
+index 465100a..b867912 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -10,6 +10,9 @@ AC_PROG_INSTALL
+ 
+ AC_PROG_CC
+ 
++# Force C89 standard and fix modern GCC global variable handling
++CFLAGS="$CFLAGS -std=c89"
++
+ AC_USE_SYSTEM_EXTENSIONS
+ AM_C_PROTOTYPES
+ 
+-- 
+2.55.0
+
package/enscript/0002-enscript-c23.patch deleted +0 -19
deleted file mode 100644
index 707674935d..0000000000
@@ -1,19 +0,0 @@
-Fix build with gcc 15.x
-
-Upstream: https://savannah.gnu.org/bugs/?66845
-
-Signed-off-by: Bernd Kuhls <[email protected]>
-
-diff --git a/compat/regex.c b/compat/regex.c
-index c6907f3..87f2840 100644
---- a/compat/regex.c
-+++ b/compat/regex.c
-@@ -336,7 +336,7 @@ typedef char boolean;
- #define false 0
- #define true 1
- 
--static int re_match_2_internal ();
-+static int re_match_2_internal (struct re_pattern_buffer*, const char*, int, const char*, int, int, struct re_registers*, int);
- 
- /* These are the command codes that appear in compiled regular
-    expressions.  Some opcodes are followed by argument bytes.  A
package/enscript/0003-Automake-1.12-and-up-no-longer-supports-pre-ANSI.patch new file +28 -0
new file mode 100644
index 0000000000..241c87493f
@@ -0,0 +1,28 @@
+From d74ef70aec3fe9e5e27468f31532eb41188707cf Mon Sep 17 00:00:00 2001
+From: Werner Fink <[email protected]>
+Date: Tue, 23 Jan 2018 15:26:45 +0100
+Subject: [PATCH] Automake 1.12 and up no longer supports pre-ANSI
+
+Signed-off-by: Werner Fink <[email protected]>
+Signed-off-by: James Cloos <[email protected]>
+Upstream: https://git.savannah.gnu.org/cgit/enscript.git/commit/?id=a356d343aa9db52b75432cde927b6f9bad6a7c44
+Signed-off-by: Thomas Petazzoni <[email protected]>
+---
+ configure.ac | 1 -
+ 1 file changed, 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index b867912..4431cb1 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -14,7 +14,6 @@ AC_PROG_CC
+ CFLAGS="$CFLAGS -std=c89"
+ 
+ AC_USE_SYSTEM_EXTENSIONS
+-AM_C_PROTOTYPES
+ 
+ AC_C_CONST
+ AC_FUNC_ALLOCA
+-- 
+2.55.0
+
package/enscript/0004-Fix-prototype-detection-when-__STDC__-is-defined-but.patch new file +107 -0

107 lines not on this page · raw message

package/enscript/0005-Use-std-gnu89-instead-of-std-c89.patch new file +35 -0
new file mode 100644
index 0000000000..4e42d75aa5
@@ -0,0 +1,35 @@
+From be920933dbe1fb73c27fecb280200f6f06abfdc2 Mon Sep 17 00:00:00 2001
+From: Thomas Petazzoni <[email protected]>
+Date: Sat, 22 Aug 2026 15:19:17 +0200
+Subject: [PATCH] Use -std=gnu89 instead of -std=c89
+
+-std=c89 suppresses feature test macros, which causes <limits.h> to
+not define PATH_MAX on certain C libraries (e.g. musl). Using
+-std=gnu89 enables _GNU_SOURCE and other extensions, ensuring
+PATH_MAX and other POSIX constants are available.
+
+This most notably fixes the build with the musl C library.
+
+Upstream: https://savannah.gnu.org/bugs/index.php?68634
+Signed-off-by: Thomas Petazzoni <[email protected]>
+---
+ configure.ac | 3 ++-
+ 1 file changed, 2 insertions(+), 1 deletion(-)
+
+diff --git a/configure.ac b/configure.ac
+index 4431cb1..46ea59d 100644
+--- a/configure.ac
++++ b/configure.ac
+@@ -11,7 +11,8 @@ AC_PROG_INSTALL
+ AC_PROG_CC
+ 
+ # Force C89 standard and fix modern GCC global variable handling
+-CFLAGS="$CFLAGS -std=c89"
++# Use GNU89 to access PATH_MAX in <limits.h>
++CFLAGS="$CFLAGS -std=gnu89"
+ 
+ AC_USE_SYSTEM_EXTENSIONS
+ 
+-- 
+2.55.0
+
package/enscript/enscript.mk +4 -0
index 441ae3dad4..1eb5d6d854 100644
@@ -9,6 +9,10 @@ ENSCRIPT_SITE = $(BR2_GNU_MIRROR)/enscript
 ENSCRIPT_LICENSE = GPL-3.0+
 ENSCRIPT_LICENSE_FILES = COPYING
 ENSCRIPT_CPE_ID_VENDOR = gnu
+# 0002-Add-CFLAG-std-c89-so-it-compiles-with-the-old-standa.patch
+# 0003-Automake-1.12-and-up-no-longer-supports-pre-ANSI.patch
+# 0005-Use-std-gnu89-instead-of-std-c89.patch
+ENSCRIPT_AUTORECONF = YES
 
 # Enable pthread threads if toolchain supports threads
 ifeq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
Signature · 6 lines
2.55.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw
Quoted 39 lines · Thomas Petazzoni via buildroot

enscript currently fails to build with musl with gcc >= 15. In order to fix this, we need to bring a number of patches from upstream, and add 2 others that were submitted upstream.

From upstream, we bring 0002-Add-CFLAG-std-c89-so-it-compiles-with-the-old-standa.patch, which switches to -std=c89 to get the compiler back to "old" behavior.

However, as this commit patches configure.ac, we need to autoreconf, but autoreconf is broken, so we also take 0003-Automake-1.12-and-up-no-longer-supports-pre-ANSI.patch from upstream, which drops a problematic autoconf macro.

However, once you drop this problematic autoconf macro, the PROTOTYPES define is never set by anything, causing the __P macro to no longer be defined properly. This is fixed by 0004-Fix-prototype-detection-when-__STDC__-is-defined-but.patch that we have submitted upstream.

Once you're there, you realize that switching to -std=c89 has the side effect that musl's <limits.h> no longer defines PATH_MAX, because it needs one of:

  #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
   || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || 

defined(_BSD_SOURCE)

and a side effect of -std=c89 is that none of these is defined anymore. So we introduce 0005-Use-std-gnu89-instead-of-std-c89.patch, which switches to -std=gnu89. This patch has also been submitted upstream.

With all of these efforts, we get a successful build on musl with gcc

Quoted 1 line

= 15.

This commit needs to be backported to Buildroot versions that support gcc 15.x, so that means the currently maintained 2026.x branches, but not 2025.02 as only up to gcc 14.x was supported then.

Quoted 6 lines

Fixes:

https://autobuild.buildroot.org/results/d39d14bbbb3a51d67fe962b877c7f66ff1204ecf/

Applied to master, thanks.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot