Skip to content

Commit 36d6248

Browse files
committed
a
1 parent 0ef4e6a commit 36d6248

5 files changed

Lines changed: 210 additions & 9 deletions

build.sh

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -640,6 +640,10 @@ if ! [ -f "${gcc_tarball}" ]; then
640640
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0001-Restore-source-files-with-stripped-license-headers.patch"
641641
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/texinfo-libintl.patch"
642642
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0001-gcc-derive-GCC_EXEC_PREFIX-from-argv-0.patch"
643+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0002-texinfo-guard-gettext-setup-calls-with-ENABLE_NLS.patch"
644+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0003-gcc-stop-falling-back-to-getwd-in-getpwd.patch"
645+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0004-libiberty-hide-sys_nerr-from-system-headers-in-strerror.patch"
646+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0001-strerror.c-Do-not-declare-sys_nerr-or-sys_errlist-if-already-macros.patch"
643647
fi
644648

645649
if (( gcc_major == 11 )); then

patches/gcc-2.9/0001-Add-host-support-for-x86_64.patch

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,26 @@
1-
From 5e70008857be1b4554334fbb58f8ef67d37618ea Mon Sep 17 00:00:00 2001
1+
From a4be6305984b2e8103dfc063cead14df4e30f215 Mon Sep 17 00:00:00 2001
22
From: Kartatz <105828205+Kartatz@users.noreply.github.com>
33
Date: Sat, 8 Aug 2026 21:20:44 +0000
4-
Subject: [PATCH] Add host support for x86-64
4+
Subject: [PATCH] Add host support for x86-64 and AArch64
55

66
---
7-
gcc/configure | 5 +++++
8-
gcc/configure.in | 5 +++++
9-
2 files changed, 10 insertions(+)
7+
gcc/configure | 10 ++++++++++
8+
gcc/configure.in | 10 ++++++++++
9+
2 files changed, 20 insertions(+)
1010

1111
diff --git a/gcc/configure b/gcc/configure
12-
index 38d3db4fe27..a2c5906864c 100755
12+
index 38d3db4..9810e80 100755
1313
--- a/gcc/configure
1414
+++ b/gcc/configure
15-
@@ -2947,6 +2947,11 @@ for machine in $build $host $target; do
15+
@@ -2947,6 +2947,16 @@ for machine in $build $host $target; do
1616
sparc*-*-*)
1717
cpu_type=sparc
1818
;;
19+
+ aarch64*-*-*)
20+
+ # AArch64 is the 64-bit extension of the ARM architecture; use the
21+
+ # arm host configuration for AArch64 hosts.
22+
+ cpu_type=arm
23+
+ ;;
1924
+ x86_64*-*-*)
2025
+ # x86-64 is the 64-bit extension of the i386 architecture; use the
2126
+ # i386 host configuration for x86-64 hosts.
@@ -25,13 +30,18 @@ index 38d3db4fe27..a2c5906864c 100755
2530

2631
tm_file=${cpu_type}/${cpu_type}.h
2732
diff --git a/gcc/configure.in b/gcc/configure.in
28-
index 55dcec76823..e3e7f4738ee 100644
33+
index 55dcec7..b177082 100644
2934
--- a/gcc/configure.in
3035
+++ b/gcc/configure.in
31-
@@ -513,6 +513,11 @@ changequote([,])dnl
36+
@@ -513,6 +513,16 @@ changequote([,])dnl
3237
sparc*-*-*)
3338
cpu_type=sparc
3439
;;
40+
+ aarch64*-*-*)
41+
+ # AArch64 is the 64-bit extension of the ARM architecture; use the
42+
+ # arm host configuration for AArch64 hosts.
43+
+ cpu_type=arm
44+
+ ;;
3545
+ x86_64*-*-*)
3646
+ # x86-64 is the 64-bit extension of the i386 architecture; use the
3747
+ # i386 host configuration for x86-64 hosts.
Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
From 117664643b58b9db5227a14be580e9db10ed7573 Mon Sep 17 00:00:00 2001
2+
From: Kartatz <105828205+Kartatz@users.noreply.github.com>
3+
Date: Sun, 9 Aug 2026 18:21:52 +0000
4+
Subject: [PATCH] texinfo: guard gettext setup calls with ENABLE_NLS
5+
6+
bindtextdomain() and textdomain() are called unconditionally in
7+
makeinfo, info, texindex and install-info. When the build is
8+
configured with --disable-nls the bundled intl/libintl.a is not
9+
built, so these references are left undefined on hosts whose libc
10+
lacks gettext (e.g. Android's bionic), breaking the link.
11+
12+
Guard the two calls with #ifdef ENABLE_NLS, which is only defined in
13+
config.h when --enable-nls (the default) is in effect, so the symbols
14+
are only referenced when libintl is actually available.
15+
---
16+
texinfo/info/info.c | 2 ++
17+
texinfo/makeinfo/makeinfo.c | 2 ++
18+
texinfo/util/install-info.c | 2 ++
19+
texinfo/util/texindex.c | 2 ++
20+
4 files changed, 8 insertions(+)
21+
22+
diff --git a/texinfo/info/info.c b/texinfo/info/info.c
23+
index 22b831a..6c781c4 100644
24+
--- a/texinfo/info/info.c
25+
+++ b/texinfo/info/info.c
26+
@@ -127,8 +127,10 @@ main (argc, argv)
27+
#endif
28+
29+
/* Set the text message domain. */
30+
+#ifdef ENABLE_NLS
31+
bindtextdomain (PACKAGE, LOCALEDIR);
32+
textdomain (PACKAGE);
33+
+#endif
34+
35+
while (1)
36+
{
37+
diff --git a/texinfo/makeinfo/makeinfo.c b/texinfo/makeinfo/makeinfo.c
38+
index 3094a65..f06a27b 100644
39+
--- a/texinfo/makeinfo/makeinfo.c
40+
+++ b/texinfo/makeinfo/makeinfo.c
41+
@@ -951,8 +951,10 @@ main (argc, argv)
42+
#endif
43+
44+
/* Set the text message domain. */
45+
+#ifdef ENABLE_NLS
46+
bindtextdomain (PACKAGE, LOCALEDIR);
47+
textdomain (PACKAGE);
48+
+#endif
49+
50+
/* Parse argument flags from the input line. */
51+
while ((c = getopt_long (argc, argv, "D:e:E:f:I:o:p:P:r:s:U:V",
52+
diff --git a/texinfo/util/install-info.c b/texinfo/util/install-info.c
53+
index 91b599d..3369865 100644
54+
--- a/texinfo/util/install-info.c
55+
+++ b/texinfo/util/install-info.c
56+
@@ -438,8 +438,10 @@ main (argc, argv)
57+
#endif
58+
59+
/* Set the text message domain. */
60+
+#ifdef ENABLE_NLS
61+
bindtextdomain (PACKAGE, LOCALEDIR);
62+
textdomain (PACKAGE);
63+
+#endif
64+
65+
while (1)
66+
{
67+
diff --git a/texinfo/util/texindex.c b/texinfo/util/texindex.c
68+
index 347cccb..4767602 100644
69+
--- a/texinfo/util/texindex.c
70+
+++ b/texinfo/util/texindex.c
71+
@@ -177,8 +177,10 @@ main (argc, argv)
72+
#endif
73+
74+
/* Set the text message domain. */
75+
+#ifdef ENABLE_NLS
76+
bindtextdomain (PACKAGE, LOCALEDIR);
77+
textdomain (PACKAGE);
78+
+#endif
79+
80+
/* Describe the kind of sorting to do. */
81+
/* The first keyfield uses the first braced field and folds case. */
82+
--
83+
2.54.0
84+
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
From 163c84cfa7c2354e55ab5cd895c44e510e6e6286 Mon Sep 17 00:00:00 2001
2+
From: Kartatz <105828205+Kartatz@users.noreply.github.com>
3+
Date: Sun, 9 Aug 2026 18:29:55 +0000
4+
Subject: [PATCH] gcc: stop falling back to getwd in getpwd
5+
6+
getpwd.c redirected getcwd to the obsolete getwd whenever POSIX/USG/VMS
7+
was not defined, or when autoconf detected HAVE_GETWD. Modern C
8+
libraries such as musl no longer provide getwd, so when gcc is built
9+
against such a libc the cc1 link fails with an undefined reference to
10+
getwd.
11+
12+
Drop the getwd fallback entirely and always call getcwd directly; every
13+
host in practical use today provides the POSIX getcwd.
14+
---
15+
gcc/getpwd.c | 14 +++++---------
16+
1 file changed, 5 insertions(+), 9 deletions(-)
17+
18+
diff --git a/gcc/getpwd.c b/gcc/getpwd.c
19+
index c3d155e..2f664cf 100644
20+
--- a/gcc/getpwd.c
21+
+++ b/gcc/getpwd.c
22+
@@ -3,21 +3,17 @@
23+
#include "config.h"
24+
#include "system.h"
25+
26+
-/* Virtually every UN*X system now in common use (except for pre-4.3-tahoe
27+
- BSD systems) now provides getcwd as called for by POSIX. Allow for
28+
- the few exceptions to the general rule here. */
29+
+/* Virtually every UN*X system now in common use provides getcwd as
30+
+ called for by POSIX. Modern C libraries like musl no longer ship
31+
+ getwd, so always call getcwd directly rather than falling back to
32+
+ the obsolete, buffer-overflow-prone getwd. */
33+
34+
-#if !(defined (POSIX) || defined (USG) || defined (VMS)) || defined (HAVE_GETWD)
35+
-#define getcwd(buf,len) getwd(buf)
36+
+/* We use this as a starting point, not a limit. */
37+
#ifdef MAXPATHLEN
38+
#define GUESSPATHLEN (MAXPATHLEN + 1)
39+
#else
40+
#define GUESSPATHLEN 100
41+
#endif
42+
-#else /* (defined (USG) || defined (VMS)) */
43+
-/* We actually use this as a starting point, not a limit. */
44+
-#define GUESSPATHLEN 100
45+
-#endif /* (defined (USG) || defined (VMS)) */
46+
47+
#if !(defined (VMS) || (defined(_WIN32) && !defined(__CYGWIN__)))
48+
49+
--
50+
2.54.0
51+
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
From 93e688704034d1df75f6202054ab55b27d105dca Mon Sep 17 00:00:00 2001
2+
From: Kartatz <105828205+Kartatz@users.noreply.github.com>
3+
Date: Sun, 9 Aug 2026 18:32:02 +0000
4+
Subject: [PATCH] libiberty: also hide sys_nerr from system headers in strerror
5+
6+
strerror.c already renamed sys_errlist to sys_errlist__ while
7+
including <stdio.h>/<errno.h>, so that a host declaration with
8+
incompatible qualifiers (e.g. BSD's "const char * const sys_errlist[]")
9+
would not clash with libiberty's own extern declaration. It did not do
10+
the same for sys_nerr, however, so on FreeBSD 15 -- whose <stdio.h>
11+
declares "extern const int sys_nerr" -- the libiberty extern
12+
"int sys_nerr" produced a hard "conflicting type qualifiers" error
13+
and aborted the build.
14+
15+
Rename sys_nerr the same way while including the system headers, as
16+
upstream gcc 3.1 already does.
17+
---
18+
libiberty/strerror.c | 10 ++++++----
19+
1 file changed, 6 insertions(+), 4 deletions(-)
20+
21+
diff --git a/libiberty/strerror.c b/libiberty/strerror.c
22+
index 644cc75..c788a11 100644
23+
--- a/libiberty/strerror.c
24+
+++ b/libiberty/strerror.c
25+
@@ -9,11 +9,12 @@
26+
27+
#ifdef HAVE_SYS_ERRLIST
28+
/* Note that errno.h (not sure what OS) or stdio.h (BSD 4.4, at least)
29+
- might declare sys_errlist in a way that the compiler might consider
30+
- incompatible with our later declaration, perhaps by using const
31+
- attributes. So we hide the declaration in errno.h (if any) using a
32+
- macro. */
33+
+ might declare sys_errlist or sys_nerr in a way that the compiler
34+
+ might consider incompatible with our later declaration, perhaps by
35+
+ using const attributes. So we hide the declaration in errno.h (if
36+
+ any) using a macro. */
37+
#define sys_errlist sys_errlist__
38+
+#define sys_nerr sys_nerr__
39+
#endif
40+
41+
#include <stdio.h>
42+
@@ -21,6 +22,7 @@
43+
44+
#ifdef HAVE_SYS_ERRLIST
45+
#undef sys_errlist
46+
+#undef sys_nerr
47+
#endif
48+
49+
/* Routines imported from standard C runtime libraries. */
50+
--
51+
2.54.0
52+

0 commit comments

Comments
 (0)