Skip to content

Commit 90fc077

Browse files
committed
Support compiling GCC 2.95
1 parent 975fd07 commit 90fc077

21 files changed

Lines changed: 2307 additions & 10 deletions

.github/workflows/build.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ permissions: write-all
1212
env:
1313
OBGGCC_BUILD_PARALLEL_LEVEL: 40
1414
OBGGCC_BUILD_DIRECTORY: /tmp
15-
OBGGCC_RELEASE: '16'
15+
OBGGCC_RELEASE: '2.95'
1616
OBGGCC_TARGETS: '*'
1717

1818
jobs:
@@ -42,6 +42,9 @@ jobs:
4242
- name: Build OBGGCC
4343
if: ${{ steps.check-cache.outputs.cache-hit != 'true' }}
4444
run: |
45+
if [ "${OBGGCC_RELEASE}" = '2.95' ]; then
46+
export OBGGCC_BUILD_PARALLEL_LEVEL='1'
47+
fi
4548
zsh './build.sh'
4649
- name: Generate tarball
4750
if: ${{ steps.check-cache.outputs.cache-hit != 'true' }}
@@ -143,7 +146,7 @@ jobs:
143146
source './tools/setup_toolchain.sh'
144147
145148
if [[ '${{ matrix.target }}' = *'-linux-musl'* ]]; then
146-
declare -r RAIDEN_TAG='gcc-15'
149+
declare -r RAIDEN_TAG='gcc-16'
147150
declare -r RAIDEN_TARBALL='/tmp/toolchain.tar.xz'
148151
declare -r RAIDEN_URL="https://github.com/AmanoTeam/musl-gcc-cross/releases/download/${RAIDEN_TAG}/x86_64-unknown-linux-gnu.tar.xz"
149152
@@ -183,7 +186,7 @@ jobs:
183186
184187
source "${LOKI_HOME}/build/autotools/${{ matrix.target }}.sh"
185188
elif [[ '${{ matrix.target }}' = *'-netbsd'* ]]; then
186-
declare -r DAKINI_TAG='gcc-15'
189+
declare -r DAKINI_TAG='gcc-16'
187190
declare -r DAKINI_TARBALL='/tmp/toolchain.tar.xz'
188191
declare -r DAKINI_URL="https://github.com/AmanoTeam/netbsd-gcc-cross/releases/download/${DAKINI_TAG}/x86_64-unknown-linux-gnu.tar.xz"
189192
@@ -244,6 +247,10 @@ jobs:
244247
source "${DARWIN_HOME}/build/autotools/${{ matrix.target }}.sh"
245248
fi
246249
250+
if [ "${OBGGCC_RELEASE}" = '2.95' ]; then
251+
export OBGGCC_BUILD_PARALLEL_LEVEL='1'
252+
fi
253+
247254
zsh './build.sh'
248255
- name: Create logs
249256
if: always()

build.sh

Lines changed: 92 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -627,12 +627,19 @@ if ! [ -f "${gcc_tarball}" ]; then
627627

628628
if (( gcc_major >= 4.0 && gcc_major <= 4.2 )); then
629629
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-4.0/0001-Add-host-support-for-x64-MinGW.patch"
630+
elif (( gcc_major == 2.95 )); then
631+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0001-Add-host-support-for-x64-MinGW.patch"
630632
elif (( gcc_major <= 3.3 )); then
631633
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.1/0001-Add-host-support-for-x64-MinGW.patch"
632634
elif (( gcc_major <= 3.4 )); then
633635
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.4/0001-Add-host-support-for-x64-MinGW.patch"
634636
fi
635637

638+
if (( gcc_major == 2.95 )); then
639+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0001-Add-host-support-for-x86_64.patch"
640+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0001-Restore-source-files-with-stripped-license-headers.patch"
641+
fi
642+
636643
if (( gcc_major == 11 )); then
637644
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-11/0001-Unpoison-calloc-on-musl-hosts.patch"
638645
fi
@@ -653,6 +660,8 @@ if ! [ -f "${gcc_tarball}" ]; then
653660
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-5/0001-Fix-definition-of-abort-on-Windows.patch"
654661
elif (( gcc_major >= 3.4 && gcc_major <= 4.9 )); then
655662
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.4/0001-Fix-definition-of-abort-on-Windows.patch"
663+
elif (( gcc_major == 2.95 )); then
664+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0001-Fix-definition-of-abort-on-Windows.patch"
656665
elif (( gcc_major <= 3.3 )); then
657666
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.1/0001-Fix-definition-of-abort-on-Windows.patch"
658667
fi
@@ -667,6 +676,11 @@ if ! [ -f "${gcc_tarball}" ]; then
667676

668677
if (( gcc_major <= 4.9 )); then
669678
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.1/0001-strerror.c-Do-not-declare-sys_nerr-or-sys_errlist-if-already-macros.patch"
679+
fi
680+
681+
if (( gcc_major == 2.95 )); then
682+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0001-Avoid-incorrectly-declaring-the-caddr_t-alias-on-Linux.patch"
683+
elif (( gcc_major <= 4.9 )); then
670684
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.1/0001-Avoid-incorrectly-declaring-the-caddr_t-alias-on-Linux.patch"
671685
fi
672686

@@ -682,18 +696,26 @@ if ! [ -f "${gcc_tarball}" ]; then
682696
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.1/0001-Allow-compilation-with-GCC-4.4-and-up.patch"
683697
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.1/0001-Fix-redeclaration-error.patch"
684698
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.1/0001-Fix-locale-support-for-glibc-2.3.patch"
699+
elif (( gcc_major == 2.95 )); then
700+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0001-Allow-compilation-with-GCC-4.4-and-up.patch"
701+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0001-Fix-redeclaration-error.patch"
702+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0001-Fix-locale-support-for-glibc-2.3.patch"
685703
fi
686704

687705
if (( gcc_major >= 3.1 && gcc_major <= 3.2 )); then
688706
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.1/0001-Don-t-error-out-for-unknown-platforms.patch"
689707
elif (( gcc_major == 3.3 )); then
690708
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.3/0001-Don-t-error-out-for-unknown-platforms.patch"
709+
elif (( gcc_major == 2.95 )); then
710+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0001-Don-t-error-out-for-unknown-platforms.patch"
691711
fi
692712

693713
if (( gcc_major >= 3.3 && gcc_major <= 3.4 )); then
694714
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-${gcc_major}/0001-Handle-enable-checking-release.patch"
695715
elif (( gcc_major >= 3.1 && gcc_major <= 3.2 )); then
696716
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.1/0001-Handle-enable-checking-release.patch"
717+
elif (( gcc_major == 2.95 )); then
718+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0001-Handle-enable-checking-release.patch"
697719
fi
698720

699721
if (( gcc_major >= 4.5 && gcc_major <= 4.8 )); then
@@ -704,6 +726,8 @@ if ! [ -f "${gcc_tarball}" ]; then
704726
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.1/0001-Add-missing-_attribute__-__gnu_inline__.patch"
705727
elif (( gcc_major == 3.3 )); then
706728
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.3/0001-Add-missing-_attribute__-__gnu_inline__.patch"
729+
elif (( gcc_major == 2.95 )); then
730+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0001-Add-missing-_attribute__-__gnu_inline__.patch"
707731
fi
708732

709733
if (( gcc_major >= 4.1 && gcc_major <= 4.7 )); then
@@ -714,6 +738,8 @@ if ! [ -f "${gcc_tarball}" ]; then
714738
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.1/0001-Disable-building-documentation.patch"
715739
elif (( gcc_major == 3.3 )); then
716740
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.3/0001-Disable-building-documentation.patch"
741+
elif (( gcc_major == 2.95 )); then
742+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0001-Disable-building-documentation.patch"
717743
fi
718744

719745
if (( gcc_major >= 4.2 && gcc_major <= 4.4 )); then
@@ -734,6 +760,8 @@ if ! [ -f "${gcc_tarball}" ]; then
734760
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-${gcc_major}/0001-Prevent-use-of-_unlocked-functions-and-disable-inclusion-of-malloc.h.patch"
735761
elif (( gcc_major >= 3.1 && gcc_major <= 3.3 )); then
736762
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.1/0001-Prevent-use-of-_unlocked-functions-and-disable-inclusion-of-malloc.h.patch"
763+
elif (( gcc_major == 2.95 )); then
764+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0001-Prevent-use-of-_unlocked-functions-and-disable-inclusion-of-malloc.h.patch"
737765
fi
738766

739767
if (( gcc_major == 6 )); then
@@ -777,6 +805,8 @@ if ! [ -f "${gcc_tarball}" ]; then
777805
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-6/0007-Add-relative-RPATHs-to-GCC-host-tools.patch"
778806
elif (( gcc_major >= 3.1 && gcc_major <= 3.3 )); then
779807
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.1/0007-Add-relative-RPATHs-to-GCC-host-tools.patch"
808+
elif (( gcc_major == 2.95 )); then
809+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0007-Add-relative-RPATHs-to-GCC-host-tools.patch"
780810
else
781811
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-${gcc_major}/0007-Add-relative-RPATHs-to-GCC-host-tools.patch"
782812
fi
@@ -793,6 +823,8 @@ if ! [ -f "${gcc_tarball}" ]; then
793823
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-${gcc_major}/0010-Prefer-DT_RPATH-over-DT_RUNPATH.patch"
794824
elif (( gcc_major >= 3.1 )); then
795825
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-3.1/0010-Prefer-DT_RPATH-over-DT_RUNPATH.patch"
826+
elif (( gcc_major == 2.95 )); then
827+
patch --directory="${gcc_directory}" --strip='1' --input="${workdir}/patches/gcc-2.9/0010-Prefer-DT_RPATH-over-DT_RUNPATH.patch"
796828
fi
797829

798830
if (( gcc_major == 3.1 )); then
@@ -1183,6 +1215,10 @@ if (( gcc_major <= 4.0 )); then
11831215
targets=("${(@)targets:#arm-unknown-linux-gnueabi}")
11841216
fi
11851217

1218+
if (( gcc_major <= 3.0 )); then
1219+
targets=("${(@)targets:#x86_64-unknown-linux-gnu}")
1220+
fi
1221+
11861222
for target in "${targets[@]}"; do
11871223
check_target_exists "${gcc_targets}" "${target}" || continue
11881224

@@ -1302,6 +1338,18 @@ for target in "${targets[@]}"; do
13021338
cp "${binutils_gnu_wrapper}" "${bin}"
13031339
done
13041340

1341+
if (( gcc_major == 2.95 )); then
1342+
# This version of GCC looks up the target's system headers in
1343+
# '<tooldir>/bin/include' (the C-preprocessor adds '/include'
1344+
# to every -B directory it was started with)
1345+
ln \
1346+
--symbolic \
1347+
--relative \
1348+
--force \
1349+
"${toolchain_directory}/${triplet}/include" \
1350+
"${toolchain_directory}/${triplet}/bin/include"
1351+
fi
1352+
13051353
rm --force --recursive "${PWD}"
13061354

13071355
if (( gcc_major >= 6 )) && ( [ "${triplet}" = 'x86_64-unknown-linux-gnu' ] || [ "${triplet}" = 'i386-unknown-linux-gnu' ] ); then
@@ -1461,10 +1509,18 @@ for target in "${targets[@]}"; do
14611509
unlink "${toolchain_directory}/${triplet}/usr"
14621510
fi
14631511

1464-
if (( gcc_major <= 4.1 )); then
1512+
if (( gcc_major >= 3.0 && gcc_major <= 4.1 )); then
1513+
# GCC 2.95 keeps its C++ headers in '<prefix>/include/g++-3',
1514+
# whose path is hard-coded into the compiler
14651515
mv \
14661516
"${toolchain_directory}/include/c++" \
14671517
"${toolchain_directory}/${triplet}/include"
1518+
elif (( gcc_major == 2.95 )); then
1519+
mkdir --parent "${toolchain_directory}/${triplet}/include/c++"
1520+
1521+
mv \
1522+
"${toolchain_directory}/include/g++-3" \
1523+
"${toolchain_directory}/${triplet}/include/c++/${gcc_major}"
14681524
fi
14691525

14701526
if (( gcc_major <= 3.3 )); then
@@ -1497,11 +1553,13 @@ for target in "${targets[@]}"; do
14971553
"${toolchain_directory}/lib/gcc/${triplet}/${gcc_major}."* \
14981554
"${toolchain_directory}/lib/gcc/${triplet}/${gcc_major}"
14991555

1500-
ln \
1501-
--symbolic \
1502-
--relative \
1503-
"${toolchain_directory}/${triplet}/include/c++/${gcc_major}."* \
1504-
"${toolchain_directory}/${triplet}/include/c++/${gcc_major}"
1556+
if (( gcc_major >= 3.0 )); then
1557+
ln \
1558+
--symbolic \
1559+
--relative \
1560+
"${toolchain_directory}/${triplet}/include/c++/${gcc_major}."* \
1561+
"${toolchain_directory}/${triplet}/include/c++/${gcc_major}"
1562+
fi
15051563
fi
15061564

15071565
if (( gcc_major >= 4.3 && gcc_major <= 11 )); then
@@ -1526,6 +1584,22 @@ for target in "${targets[@]}"; do
15261584
cd '../lib'
15271585
fi
15281586

1587+
if (( gcc_major == 2.95 )); then
1588+
ln \
1589+
--symbolic \
1590+
--relative \
1591+
--force \
1592+
'libstdc++-libc6.1-2.so.3' \
1593+
'libstdc++.so'
1594+
1595+
ln \
1596+
--symbolic \
1597+
--relative \
1598+
--force \
1599+
'libstdc++-3-libc6.1-2-2.10.0.a' \
1600+
'libstdc++.a'
1601+
fi
1602+
15291603
"${triplet}-strip" "${PWD}/lib"*'.so' 2>/dev/null || true
15301604

15311605
if (( gcc_major >= 13 && gcc_major <= 15 )); then
@@ -1542,6 +1616,10 @@ for target in "${targets[@]}"; do
15421616
LDFLAGS="${linkflags}"
15431617
fi
15441618

1619+
if (( gcc_major == 2.95 )); then
1620+
rm "${toolchain_directory}/lib/gcc/${triplet}/${gcc_major}/libstdc++"*
1621+
fi
1622+
15451623
ln \
15461624
--symbolic \
15471625
--relative \
@@ -1595,7 +1673,9 @@ for target in "${targets[@]}"; do
15951673
cp "${toolchain_directory}/bin/${triplet}-g++${exe}" "${toolchain_directory}/bin/${triplet}-c++${exe}"
15961674
fi
15971675

1598-
cat "${workdir}/patches/c++config.h" >> "${toolchain_directory}/${triplet}/include/c++/${gcc_major}/${triplet}/bits/c++config.h"
1676+
if (( gcc_major >= 3.0 )); then
1677+
cat "${workdir}/patches/c++config.h" >> "${toolchain_directory}/${triplet}/include/c++/${gcc_major}/${triplet}/bits/c++config.h"
1678+
fi
15991679

16001680
if (( gcc_major >= 4.6 )); then
16011681
if [[ "${host}" = *'-mingw32' ]]; then
@@ -1889,6 +1969,10 @@ while read item; do
18891969
continue
18901970
fi
18911971

1972+
if (( gcc_major <= 3.0 )) && [[ "${triplet}" = 'x86_64-'* ]]; then
1973+
continue
1974+
fi
1975+
18921976
declare repository="$(jq --raw-output '.repository.url' <<< "${item}")"
18931977
declare release="$(jq --raw-output '.repository.release' <<< "${item}")"
18941978
declare resource="$(jq --raw-output '.repository.resource' <<< "${item}")"
@@ -2213,3 +2297,4 @@ if ( find "${toolchain_directory}" -xtype 'l' -print -quit | grep -q . ); then
22132297
fi
22142298

22152299
cp "${workdir}/README.md" "${toolchain_directory}"
2300+
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
From 0751a06c08a0585fcdb7c22346527702f698f1a5 Mon Sep 17 00:00:00 2001
2+
From: Kartatz <105828205+Kartatz@users.noreply.github.com>
3+
Date: Sat, 8 Aug 2026 18:02:39 +0000
4+
Subject: [PATCH] Add host support for x64 MinGW
5+
6+
---
7+
gcc/configure | 4 ++--
8+
gcc/configure.in | 4 ++--
9+
2 files changed, 4 insertions(+), 4 deletions(-)
10+
11+
diff --git a/gcc/configure b/gcc/configure
12+
index 38d3db4fe27..4ca45c280fe 100755
13+
--- a/gcc/configure
14+
+++ b/gcc/configure
15+
@@ -3866,7 +3866,7 @@ for machine in $build $host $target; do
16+
fi
17+
exeext=.exe
18+
;;
19+
- i[34567]86-*-pe | i[34567]86-*-cygwin*)
20+
+ *-*-pe | *-*-cygwin*)
21+
xm_file="${xm_file} i386/xm-cygwin.h"
22+
tmake_file=i386/t-cygwin
23+
tm_file=i386/cygwin.h
24+
@@ -3877,7 +3877,7 @@ for machine in $build $host $target; do
25+
fi
26+
exeext=.exe
27+
;;
28+
- i[34567]86-*-mingw32*)
29+
+ *-*-mingw32*)
30+
tm_file=i386/mingw32.h
31+
xm_file="${xm_file} i386/xm-mingw32.h"
32+
tmake_file="i386/t-cygwin i386/t-mingw32"
33+
diff --git a/gcc/configure.in b/gcc/configure.in
34+
index 55dcec76823..f2fe9e8220b 100644
35+
--- a/gcc/configure.in
36+
+++ b/gcc/configure.in
37+
@@ -1527,7 +1527,7 @@ changequote([,])dnl
38+
exeext=.exe
39+
;;
40+
changequote(,)dnl
41+
- i[34567]86-*-pe | i[34567]86-*-cygwin*)
42+
+ *-*-pe | *-*-cygwin*)
43+
changequote([,])dnl
44+
xm_file="${xm_file} i386/xm-cygwin.h"
45+
tmake_file=i386/t-cygwin
46+
@@ -1540,7 +1540,7 @@ changequote([,])dnl
47+
exeext=.exe
48+
;;
49+
changequote(,)dnl
50+
- i[34567]86-*-mingw32*)
51+
+ *-*-mingw32*)
52+
changequote([,])dnl
53+
tm_file=i386/mingw32.h
54+
xm_file="${xm_file} i386/xm-mingw32.h"
55+
--
56+
2.54.0
57+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
From 5e70008857be1b4554334fbb58f8ef67d37618ea Mon Sep 17 00:00:00 2001
2+
From: Kartatz <105828205+Kartatz@users.noreply.github.com>
3+
Date: Sat, 8 Aug 2026 21:20:44 +0000
4+
Subject: [PATCH] Add host support for x86-64
5+
6+
---
7+
gcc/configure | 5 +++++
8+
gcc/configure.in | 5 +++++
9+
2 files changed, 10 insertions(+)
10+
11+
diff --git a/gcc/configure b/gcc/configure
12+
index 38d3db4fe27..a2c5906864c 100755
13+
--- a/gcc/configure
14+
+++ b/gcc/configure
15+
@@ -2947,6 +2947,11 @@ for machine in $build $host $target; do
16+
sparc*-*-*)
17+
cpu_type=sparc
18+
;;
19+
+ x86_64*-*-*)
20+
+ # x86-64 is the 64-bit extension of the i386 architecture; use the
21+
+ # i386 host configuration for x86-64 hosts.
22+
+ cpu_type=i386
23+
+ ;;
24+
esac
25+
26+
tm_file=${cpu_type}/${cpu_type}.h
27+
diff --git a/gcc/configure.in b/gcc/configure.in
28+
index 55dcec76823..e3e7f4738ee 100644
29+
--- a/gcc/configure.in
30+
+++ b/gcc/configure.in
31+
@@ -513,6 +513,11 @@ changequote([,])dnl
32+
sparc*-*-*)
33+
cpu_type=sparc
34+
;;
35+
+ x86_64*-*-*)
36+
+ # x86-64 is the 64-bit extension of the i386 architecture; use the
37+
+ # i386 host configuration for x86-64 hosts.
38+
+ cpu_type=i386
39+
+ ;;
40+
esac
41+
42+
tm_file=${cpu_type}/${cpu_type}.h
43+
--
44+
2.54.0
45+

0 commit comments

Comments
 (0)