From 4ee0dab8570c7edf8322eb4772e672277cae86a2 Mon Sep 17 00:00:00 2001 From: ser-pounce <655122+ser-pounce@users.noreply.github.com> Date: Thu, 26 Mar 2026 21:27:01 +0100 Subject: [PATCH 1/4] Add missing patches --- gcc-2.7.2-cdk.Dockerfile | 3 +- patches/psx-2.7.2-cdk.patch | 175 ++++++++++++++++++++++++++++++++++++ 2 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 patches/psx-2.7.2-cdk.patch diff --git a/gcc-2.7.2-cdk.Dockerfile b/gcc-2.7.2-cdk.Dockerfile index 804559f..9650f29 100644 --- a/gcc-2.7.2-cdk.Dockerfile +++ b/gcc-2.7.2-cdk.Dockerfile @@ -13,9 +13,10 @@ COPY patches /work/patches RUN patch -u -p1 Makefile.in -i ../patches/Makefile-2.7.2-cdk.in.patch RUN patch -u -p1 obstack.h -i ../patches/obstack-2.7.2-cdk.h.patch RUN patch -u -p1 config/mips/mips.h -i ../patches/mipsel-2.7-cdk.patch +RUN patch -su -p1 < ../patches/psx-2.7.2-cdk.patch RUN ./configure \ - --target=mips-linux-gnu \ + --target=mips-sony-psx \ --prefix=/opt/cross \ --with-endian-little \ --with-gnu-as \ diff --git a/patches/psx-2.7.2-cdk.patch b/patches/psx-2.7.2-cdk.patch new file mode 100644 index 0000000..e06fa60 --- /dev/null +++ b/patches/psx-2.7.2-cdk.patch @@ -0,0 +1,175 @@ +diff --color -ruN -p1 gcc-2.6.3/config/mips/psx.h gcc-2.6.3-psx/config/mips/psx.h +--- gcc-2.6.3/config/mips/psx.h 1970-01-01 01:00:00.000000000 +0100 ++++ gcc-2.6.3-psx/config/mips/psx.h 2023-03-26 13:52:13.400875920 +0100 +@@ -0,0 +1,108 @@ ++/* Definitions of target machine for GNU compiler. Iris version. ++ Copyright (C) 1991, 1993, 1995, 1996 Free Software Foundation, Inc. ++ ++This file is part of GNU CC. ++ ++GNU CC is free software; you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by ++the Free Software Foundation; either version 2, or (at your option) ++any later version. ++ ++GNU CC is distributed in the hope that it will be useful, ++but WITHOUT ANY WARRANTY; without even the implied warranty of ++MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++GNU General Public License for more details. ++ ++You should have received a copy of the GNU General Public License ++along with GNU CC; see the file COPYING. If not, write to ++the Free Software Foundation, 59 Temple Place - Suite 330, ++Boston, MA 02111-1307, USA. */ ++ ++ ++/* Definitions by GIL for PSX */ ++ ++#define TARGET_DEFAULT (MASK_GAS+MASK_SOFT_FLOAT) ++ ++#define CPP_PREDEFINES "-Dmips -DMIPSEL" ++ ++#define STARTFILE_SPEC "%{pg:gcrt1.o%s}%{!pg:%{p:mcrt1.o%s}%{!p:crt1.o%s}}" ++ ++#define CPP_SPEC "\ ++%{!ansi:-D__EXTENSIONS__} -D_MIPSEL \ ++%{.S: -D_LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY}} \ ++%{.s: -D_LANGUAGE_ASSEMBLY %{!ansi:-DLANGUAGE_ASSEMBLY}} \ ++%{.cc: -D_LANGUAGE_C_PLUS_PLUS} \ ++%{.cxx: -D_LANGUAGE_C_PLUS_PLUS} \ ++%{.C: -D_LANGUAGE_C_PLUS_PLUS} \ ++%{.m: -D_LANGUAGE_OBJECTIVE_C} \ ++%{!.S: %{!.s: %{!.cc: %{!.cxx: %{!.C: %{!.m: -D_LANGUAGE_C %{!ansi:-DLANGUAGE_C}}}}}}} \ ++%{mlong64:-D__SIZE_TYPE__=long\\ unsigned\\ int -D__PTRDIFF_TYPE__=long\\ int} \ ++%{!mlong64:-D__SIZE_TYPE__=unsigned\\ int -D__PTRDIFF_TYPE__=int} \ ++%{mips3:-U__mips -D__mips=3}" ++ ++#define LIB_SPEC \ ++ "%{!p:%{!pg:%{!static:%{!g*:-lc_s}} -lc}}%{p:-lc_p}%{pg:-lc_p} crtn.o%s" ++ ++#define MACHINE_TYPE "Sony Playstation" ++ ++#define TARGET_ENDIAN_DEFAULT 0 ++ ++/* A C statement to output something to the assembler file to switch to section ++ NAME for object DECL which is either a FUNCTION_DECL, a VAR_DECL or ++ NULL_TREE. Some target formats do not support arbitrary sections. Do not ++ define this macro in such cases. */ ++ ++#define ASM_OUTPUT_SECTION_NAME(FILE, NAME) \ ++ fprintf (FILE, "\t.section %s,\"aw\",@progbits\n", (NAME)) ++ ++/* GIL: R3000 machine supports ISA 1 */ ++#define MIPS_ISA_DEFAULT 1 ++/* GIL: set to r3000 */ ++#define MIPS_CPU_STRING_DEFAULT "3000" ++ ++/* End of GIL for PSX */ ++ ++ ++#define SGI_TARGET 1 /* inform other mips files this is SGI */ ++ ++/* Always use 1 for .file number. I [meissner@osf.org] wonder why ++ IRIS needs this. */ ++ ++#define SET_FILE_NUMBER() ++num_source_filenames ++ ++/* Put out a label after a .loc. I [meissner@osf.org] wonder why ++ IRIS needs this. */ ++ ++#define LABEL_AFTER_LOC(STREAM) fprintf (STREAM, "LM%d:\n", ++sym_lineno) ++ ++#define STACK_ARGS_ADJUST(SIZE) \ ++{ \ ++ SIZE.constant += 4; \ ++ if (SIZE.constant < 32) \ ++ SIZE.constant = 32; \ ++} ++ ++/* Do not allow `$' in identifiers. */ ++ ++#define DOLLARS_IN_IDENTIFIERS 0 ++ ++/* Tell G++ not to create constructors or destructors with $'s in them. */ ++ ++#define NO_DOLLAR_IN_LABEL 1 ++ ++/* Specify wchar_t type. */ ++#define WCHAR_TYPE "unsigned char" ++#define WCHAR_TYPE_SIZE BITS_PER_UNIT ++ ++/* Generate calls to memcpy, etc., not bcopy, etc. */ ++#define TARGET_MEM_FUNCTIONS ++ ++/* Xeeynamo: force to use little-endian */ ++#define MIPSEL ++#define BYTES_BIG_ENDIAN 0 ++#define WORDS_BIG_ENDIAN 0 ++ ++/* Plain char is unsigned in the SGI compiler. */ ++#define DEFAULT_SIGNED_CHAR 0 ++ ++#include "mips/mips.h" +diff --color -ruN -p1 gcc-2.6.3/config/mips/xm-psx.h gcc-2.6.3-psx/config/mips/xm-psx.h +--- gcc-2.6.3/config/mips/xm-psx.h 1970-01-01 01:00:00.000000000 +0100 ++++ gcc-2.6.3-psx/config/mips/xm-psx.h 2023-03-26 13:52:13.402875923 +0100 +@@ -0,0 +1,12 @@ ++#define USG ++ ++#include "mips/xm-mips.h" ++ ++#define USG ++#define HAVE_VPRINTF ++ ++/* ++#define bcopy(a,b,c) memcpy (b,a,c) ++#define bzero(a,b) memset (a,0,b) ++#define bcmp(a,b,c) memcmp (a,b,c) ++*/ +\ No newline at end of file +diff --color -ruN -p1 gcc-2.6.3/config.sub gcc-2.6.3-psx/config.sub +--- gcc-2.6.3/config.sub 1994-10-26 18:23:05.000000000 +0000 ++++ gcc-2.6.3-psx/config.sub 2023-03-26 13:53:36.046989327 +0100 +@@ -420,2 +420,6 @@ case $basic_machine in + ;; ++ psx) ++ basic_machine=mips-sony ++ os=-psx ++ ;; + rtpc | rtpc-*) +@@ -636,2 +640,5 @@ case $os in + ;; ++ -psx) ++ os=-psx ++ ;; + -none) +diff --color -ruN -p1 gcc-2.6.3/configure gcc-2.6.3-psx/configure +--- gcc-2.6.3/configure 1994-11-23 22:26:27.000000000 +0000 ++++ gcc-2.6.3-psx/configure 2023-03-26 13:54:03.941012094 +0100 +@@ -1471,2 +1471,20 @@ for machine in $canon_build $canon_host + ;; ++ mips-sony-psx*) # Sony Playstation ++ tm_file=mips/psx.h ++ xm_file=mips/xm-psx.h ++ elf=yes ++ gnu_ld=yes ++ gas=yes ++ DEFS=-Dpsx -D__psx__ -D__psx ++ if [ x$gas = xyes ] ++ then ++ tmake_file=mips/t-mips-gas ++ else ++ extra_passes="mips-tfile mips-tdump" ++ fi ++ if [ x$gnu_ld != xyes ] ++ then ++ use_collect2=yes ++ fi ++ ;; + mips-sony-sysv*) # Sony NEWS 3800 with NEWSOS5.0. +diff --color -ruN -p1 gcc-2.7.2/version.c gcc-2.7.2-psx/version.c +--- gcc-2.7.2/version.c 1994-11-23 22:26:27.000000000 +0000 ++++ gcc-2.7.2-psx/version.c 2023-03-26 13:54:03.941012094 +0100 +@@ -1,1 +1,1 @@ +-char *version_string = "cygnus-2.7.2-970404"; ++char *version_string = "cygnus-2.7.2-970404 SN32.3.7.0004"; From 84a01318b19aac2632779245386e6aa8df9b7f58 Mon Sep 17 00:00:00 2001 From: ser-pounce <655122+ser-pounce@users.noreply.github.com> Date: Fri, 27 Mar 2026 07:12:14 +0100 Subject: [PATCH 2/4] Patch target name --- patches/Makefile-2.7.2-cdk.in.patch | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/patches/Makefile-2.7.2-cdk.in.patch b/patches/Makefile-2.7.2-cdk.in.patch index 7e2bd39..6cde2d8 100644 --- a/patches/Makefile-2.7.2-cdk.in.patch +++ b/patches/Makefile-2.7.2-cdk.in.patch @@ -1,5 +1,5 @@ diff --git a/Makefile.in b/Makefile.in -index 15739a5..27045d2 100644 +index 15739a5..24ff26a 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1339,7 +1339,7 @@ convert.o: convert.c $(CONFIG_H) $(TREE_H) flags.h convert.h @@ -11,6 +11,15 @@ index 15739a5..27045d2 100644 # END CYGNUS LOCAL print-tree.o : print-tree.c $(CONFIG_H) $(TREE_H) stor-layout.o : stor-layout.c $(CONFIG_H) $(TREE_H) flags.h function.h +@@ -1348,7 +1348,7 @@ toplev.o : toplev.c $(CONFIG_H) $(TREE_H) $(RTL_H) bytecode.h bc-emit.h \ + flags.h input.h insn-attr.h xcoffout.h defaults.h output.h \ + $(lang_options_files) + $(CC) $(ALL_CFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) $(MAYBE_USE_COLLECT2) \ +- -DTARGET_NAME=\"$(target_alias)\" \ ++ -DTARGET_NAME=\"SonyPSX\" \ + -c `echo $(srcdir)/toplev.c | sed 's,^\./,,'` + + rtl.o : rtl.c $(CONFIG_H) $(RTL_H) @@ -1385,7 +1385,7 @@ dbxout.o : dbxout.c $(CONFIG_H) $(TREE_H) $(RTL_H) flags.h regs.h \ insn-config.h reload.h gstab.h xcoffout.h defaults.h output.h sdbout.o : sdbout.c $(CONFIG_H) $(TREE_H) $(RTL_H) flags.h except.h \ From 0f7dad15fcf0d4e09e2fda4f19ceb11880e24bae Mon Sep 17 00:00:00 2001 From: ser-pounce <655122+ser-pounce@users.noreply.github.com> Date: Fri, 27 Mar 2026 07:21:33 +0100 Subject: [PATCH 3/4] Patch compiled by message --- patches/psx-2.7.2-cdk.patch | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/patches/psx-2.7.2-cdk.patch b/patches/psx-2.7.2-cdk.patch index e06fa60..20c93a1 100644 --- a/patches/psx-2.7.2-cdk.patch +++ b/patches/psx-2.7.2-cdk.patch @@ -173,3 +173,22 @@ diff --color -ruN -p1 gcc-2.7.2/version.c gcc-2.7.2-psx/version.c @@ -1,1 +1,1 @@ -char *version_string = "cygnus-2.7.2-970404"; +char *version_string = "cygnus-2.7.2-970404 SN32.3.7.0004"; +diff --git a/toplev.c b/toplev.c +index 48722cb..c579f66 100644 +--- a/toplev.c ++++ b/toplev.c +@@ -4675,14 +4675,7 @@ print_version (file, indent) + #endif + /* END CYGNUS LOCAL -- Haifa scheduler */ + fprintf (file, " (%s)", TARGET_NAME); +-#ifdef __GNUC__ +-#ifndef __VERSION__ +-#define __VERSION__ "[unknown]" +-#endif +- fprintf (file, " compiled by GNU C version %s.\n", __VERSION__); +-#else + fprintf (file, " compiled by CC.\n"); +-#endif + } + + /* Print an option value and return the adjusted position in the line. From 5584c771c944d603aee7f75f3092a6c5fd09646b Mon Sep 17 00:00:00 2001 From: ser-pounce <655122+ser-pounce@users.noreply.github.com> Date: Sat, 28 Mar 2026 09:40:41 +0100 Subject: [PATCH 4/4] Update source zip --- gcc-2.7.2-cdk.Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc-2.7.2-cdk.Dockerfile b/gcc-2.7.2-cdk.Dockerfile index 9650f29..ef2317e 100644 --- a/gcc-2.7.2-cdk.Dockerfile +++ b/gcc-2.7.2-cdk.Dockerfile @@ -4,7 +4,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ ca-certificates build-essential gcc gcc-multilib wget byacc WORKDIR /work -RUN wget https://github.com/ser-pounce/cdk-gcc/archive/refs/tags/b18.tar.gz +RUN wget https://github.com/decompals/old-gcc/releases/download/0.14/b18.tar.gz RUN tar xzf b18.tar.gz WORKDIR /work/cdk-gcc-b18