Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update -psx builds to match PSYQ compiler default flags #29

Merged
merged 2 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions gcc-2.5.7-psx.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ RUN make --jobs $(nproc) cpp cc1 xgcc cc1plus g++ CFLAGS="-std=gnu89 -m32 -stati

COPY tests /work/tests
RUN ./cc1 -quiet -O2 /work/tests/little_endian.c && grep -E 'lbu\s\$2,0\(\$4\)' /work/tests/little_endian.s
RUN ./cc1 -quiet -help </dev/null 2>&1 | grep -- -msoft-float

RUN mv xgcc gcc
RUN mkdir /build && cp cpp cc1 gcc cc1plus g++ /build/ || true
Expand Down
3 changes: 2 additions & 1 deletion gcc-2.6.0-psx.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ RUN patch -u -p1 cccp.c -i ../patches/cccp-2.6.0.c.patch
RUN patch -u -p1 gcc.c -i ../patches/gcc-2.6.0.c.patch
RUN patch -u -p1 cp/g++.c -i ../patches/g++-2.6.0.c.patch
RUN patch -u -p1 config/mips/mips.h -i ../patches/mipsel-2.6.patch
RUN patch -su -p1 < ../patches/psx.patch
RUN patch -su -p1 < ../patches/psx-2.5.7.patch

RUN ./configure \
--target=mips-sony-psx \
Expand All @@ -33,6 +33,7 @@ RUN make --jobs $(nproc) cpp cc1 xgcc cc1plus g++ CFLAGS="-std=gnu89 -m32 -stati
COPY tests /work/tests
RUN ./cc1 -quiet -O2 /work/tests/little_endian.c && grep -E 'lbu\s\$2,0\(\$4\)' /work/tests/little_endian.s
RUN ./cc1 -quiet -O2 /work/tests/section_attribute.c
RUN ./cc1 -quiet -help </dev/null 2>&1 | grep -- -msoft-float

RUN mv xgcc gcc
RUN mkdir /build && cp cpp cc1 gcc cc1plus g++ /build/
Expand Down
3 changes: 2 additions & 1 deletion gcc-2.6.3-psx.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN sed -i -- 's/include <varargs.h>/include <stdarg.h>/g' *.c
RUN patch -u -p1 obstack.h -i ../patches/obstack-2.7.2.h.patch
RUN patch -u -p1 sdbout.c -i ../patches/sdbout-2.6.3.c.patch
RUN patch -u -p1 cp/g++.c -i ../patches/g++-2.6.3.c.patch
RUN patch -su -p1 < ../patches/psx.patch
RUN patch -su -p1 < ../patches/psx-2.5.7.patch

RUN touch -c cp/parse.y cp/parse.h cp/parse.c
RUN touch insn-config.h
Expand All @@ -32,6 +32,7 @@ RUN make --jobs $(nproc) cpp cc1 xgcc cc1plus g++ CFLAGS="-std=gnu89 -m32 -stati
COPY tests /work/tests
RUN ./cc1 -quiet -O2 /work/tests/little_endian.c && grep -E 'lbu\s\$2,0\(\$4\)' /work/tests/little_endian.s
RUN ./cc1 -quiet -O2 /work/tests/section_attribute.c
RUN ./cc1 -quiet -help </dev/null 2>&1 | grep -- -msoft-float

RUN mv xgcc gcc
RUN mkdir /build && cp cpp cc1 gcc cc1plus g++ /build/ || true
Expand Down
3 changes: 2 additions & 1 deletion gcc-2.7.2-psx.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ RUN patch -u -p1 obstack.h -i ../patches/obstack-2.7.2.h.patch
RUN patch -u -p1 configure -i ../patches/configure.patch
RUN patch -u -p1 config.sub -i ../patches/config.sub.patch
RUN patch -u -p1 config/mips/mips.h -i ../patches/mipsel-2.7.patch
RUN patch -su -p1 < ../patches/psx.patch
RUN patch -su -p1 < ../patches/psx-2.5.7.patch

RUN ./configure \
--target=mips-sony-psx \
Expand All @@ -37,6 +37,7 @@ RUN make --jobs $(nproc) cpp cc1 xgcc cc1plus g++ CFLAGS="-std=gnu89 -m32 -stati
COPY tests /work/tests
RUN ./cc1 -quiet -O2 /work/tests/little_endian.c && grep -E 'lbu\s\$2,0\(\$4\)' /work/tests/little_endian.s
RUN ./cc1 -quiet -O2 /work/tests/section_attribute.c
RUN ./cc1 -quiet -help </dev/null 2>&1 | grep -- -msoft-float

RUN mv xgcc gcc
RUN mkdir /build && cp cpp cc1 gcc cc1plus g++ /build/
Expand Down
5 changes: 4 additions & 1 deletion gcc-2.8.0-psx.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ COPY patches /work/patches
RUN sed -i -- 's/include <varargs.h>/include <stdarg.h>/g' *.c

RUN patch -u -p1 obstack.h -i ../patches/obstack-2.8.0.h.patch
RUN patch -u -p1 config/mips/mips.h -i ../patches/mipsel-2.8.patch
RUN patch -u -p1 config/mips/mips.h -i ../patches/mips.patch
RUN patch -su -p1 < ../patches/psx.patch

RUN ./configure \
Expand All @@ -35,6 +35,9 @@ RUN make --jobs $(nproc) cpp cc1 xgcc cc1plus g++ CFLAGS="-std=gnu89 -m32 -stati
COPY tests /work/tests
RUN ./cc1 -quiet -O2 /work/tests/little_endian.c && grep -E 'lbu\s\$2,0\(\$4\)' /work/tests/little_endian.s
RUN ./cc1 -quiet -O2 /work/tests/section_attribute.c
RUN ./cc1 -version </dev/null 2>&1 | grep -- -msoft-float
RUN ./cc1 -version </dev/null 2>&1 | grep -- -msplit-addresses
RUN ./cc1 -version </dev/null 2>&1 | grep -- -mgpopt

RUN mv xgcc gcc
RUN mkdir /build && cp cpp cc1 gcc cc1plus g++ /build/
Expand Down
5 changes: 4 additions & 1 deletion gcc-2.8.1-psx.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ COPY patches /work/patches
RUN sed -i -- 's/include <varargs.h>/include <stdarg.h>/g' *.c

RUN patch -u -p1 obstack.h -i ../patches/obstack-2.8.1.h.patch
RUN patch -u -p1 config/mips/mips.h -i ../patches/mipsel-2.8.patch
RUN patch -u -p1 config/mips/mips.h -i ../patches/mips.patch
RUN patch -su -p1 < ../patches/psx.patch

RUN ./configure \
Expand All @@ -37,6 +37,9 @@ RUN make --jobs $(nproc) cpp cc1 xgcc cc1plus g++ CFLAGS="-std=gnu89 -m32 -stati
COPY tests /work/tests
RUN ./cc1 -quiet -O2 /work/tests/little_endian.c && grep -E 'lbu\s\$2,0\(\$4\)' /work/tests/little_endian.s
RUN ./cc1 -quiet -O2 /work/tests/section_attribute.c
RUN ./cc1 -version </dev/null 2>&1 | grep -- -msoft-float
RUN ./cc1 -version </dev/null 2>&1 | grep -- -msplit-addresses
RUN ./cc1 -version </dev/null 2>&1 | grep -- -mgpopt

RUN mv xgcc gcc
RUN mkdir /build && cp cpp cc1 gcc cc1plus g++ /build/
Expand Down
7 changes: 5 additions & 2 deletions gcc-2.91.66-psx.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ COPY patches /work/patches

RUN sed -i -- 's/include <varargs.h>/include <stdarg.h>/g' **/*.c
RUN patch -u -p1 gcc/obstack.h -i ../patches/obstack-${VERSION}.h.patch
RUN patch -u -p1 gcc/config/mips/mips.h -i ../patches/mipsel-2.8.patch
RUN patch -su -p1 < ../patches/psx.patch
RUN patch -u -p1 gcc/config/mips/mips.h -i ../patches/mips.patch
RUN patch -su -p1 < ../patches/psx-2.91.patch

RUN for dir in libiberty gcc; do \
cd /work/gcc-${VERSION}/${dir}; \
Expand All @@ -39,6 +39,9 @@ RUN make -C gcc/ --jobs $(nproc) cpp cc1 xgcc cc1plus g++ CFLAGS="-std=gnu89 -m3
COPY tests /work/tests
RUN ./gcc/cc1 -quiet -O2 /work/tests/little_endian.c && grep -E 'lbu\s\$2,0\(\$4\)' /work/tests/little_endian.s
RUN ./gcc/cc1 -quiet -O2 /work/tests/section_attribute.c
RUN ./gcc/cc1 -version </dev/null 2>&1 | grep -- -msoft-float
RUN ./gcc/cc1 -version </dev/null 2>&1 | grep -- -msplit-addresses
RUN ./gcc/cc1 -version </dev/null 2>&1 | grep -- -mgpopt

RUN mv ./gcc/xgcc ./gcc/gcc
RUN mkdir /build && cp ./gcc/cpp ./gcc/cc1 ./gcc/gcc ./gcc/cc1plus ./gcc/g++ /build/
Expand Down
8 changes: 6 additions & 2 deletions gcc-2.95.2-psx.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ COPY patches /work/patches

RUN sed -i -- 's/include <varargs.h>/include <stdarg.h>/g' **/*.c
RUN patch -u -p1 include/obstack.h -i ../patches/obstack-${VERSION}.h.patch
RUN patch -u -p1 gcc/config/mips/mips.h -i ../patches/mipsel-2.8.patch
RUN patch -su -p1 < ../patches/psx.patch
RUN patch -u -p1 gcc/config/mips/mips.h -i ../patches/mips.patch
RUN patch -su -p1 < ../patches/psx-2.91.patch


RUN for dir in libiberty gcc; do \
cd /work/gcc-${VERSION}/${dir}; \
Expand All @@ -39,6 +40,9 @@ RUN make -C gcc/ --jobs $(nproc) cpp cc1 xgcc cc1plus g++ CFLAGS="-std=gnu89 -m3
COPY tests /work/tests
RUN ./gcc/cc1 -mel -quiet -O2 /work/tests/little_endian.c && grep -E 'lbu\s\$2,0\(\$4\)' /work/tests/little_endian.s
RUN ./gcc/cc1 -quiet -O2 /work/tests/section_attribute.c
RUN ./gcc/cc1 -version </dev/null 2>&1 | grep -- -msoft-float
RUN ./gcc/cc1 -version </dev/null 2>&1 | grep -- -msplit-addresses
RUN ./gcc/cc1 -version </dev/null 2>&1 | grep -- -mgpopt

RUN mv ./gcc/xgcc ./gcc/gcc
RUN mkdir /build && cp ./gcc/cpp ./gcc/cc1 ./gcc/gcc ./gcc/cc1plus ./gcc/g++ /build/
Expand Down
25 changes: 25 additions & 0 deletions patches/mips.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--- config/mips/mips.h 1997-12-29 00:34:57.000000000 +0000
+++ config/mips/mips-patched.h 2023-11-14 22:29:18.785172634 +0000
@@ -1153,6 +1156,22 @@
#define ASM_OUTPUT_DESTRUCTOR(file, name)

#endif /* 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(F, DECL, NAME, RELOC) \
+do { \
+ extern FILE *asm_out_text_file; \
+ if ((DECL) && TREE_CODE (DECL) == FUNCTION_DECL) \
+ fprintf (asm_out_text_file, "\t.section %s,\"ax\",@progbits\n", (NAME)); \
+ else if ((DECL) && DECL_READONLY_SECTION (DECL, RELOC)) \
+ fprintf (F, "\t.section %s,\"a\",@progbits\n", (NAME)); \
+ else \
+ fprintf (F, "\t.section %s,\"aw\",@progbits\n", (NAME)); \
+} while (0)

/* Target machine storage layout */

7 changes: 3 additions & 4 deletions patches/mipsel-2.8.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
@@ -441,6 +441,9 @@
| TARGET_ENDIAN_DEFAULT)} \
}

+/* Default little-endian */
+#define TARGET_ENDIAN_DEFAULT -MASK_BIG_ENDIAN
+
/* Default target_flags if no switches are specified */

#ifndef TARGET_DEFAULT
@@ -1153,6 +1156,22 @@
#define ASM_OUTPUT_DESTRUCTOR(file, name)

#endif /* 0 */
+
+/* A C statement to output something to the assembler file to switch to section
Expand All @@ -32,4 +32,3 @@
+} while (0)

/* Target machine storage layout */

169 changes: 169 additions & 0 deletions patches/psx-2.91.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
diff --color -ruN -p1 gcc-2.6.3/gcc/config/mips/psx.h gcc-2.6.3-psx/gcc/config/mips/psx.h
--- gcc-2.6.3/gcc/config/mips/psx.h 1970-01-01 01:00:00.000000000 +0100
+++ gcc-2.6.3-psx/gcc/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+MASK_GPOPT+MASK_SPLIT_ADDR)
+
+#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 "R3000"
+
+/* End of GIL for PSX */
+
+
+#define SGI_TARGET 1 /* inform other mips files this is SGI */
+
+/* Always use 1 for .file number. I [[email protected]] wonder why
+ IRIS needs this. */
+
+#define SET_FILE_NUMBER() ++num_source_filenames
+
+/* Put out a label after a .loc. I [[email protected]] 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/gcc/config/mips/xm-psx.h gcc-2.6.3-psx/gcc/config/mips/xm-psx.h
--- gcc-2.6.3/gcc/config/mips/xm-psx.h 1970-01-01 01:00:00.000000000 +0100
+++ gcc-2.6.3-psx/gcc/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/gcc/configure gcc-2.6.3-psx/gcc/configure
--- gcc-2.6.3/gcc/configure 1994-11-23 22:26:27.000000000 +0000
+++ gcc-2.6.3-psx/gcc/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.
2 changes: 1 addition & 1 deletion patches/psx.patch
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ diff --color -ruN -p1 gcc-2.6.3/config/mips/psx.h gcc-2.6.3-psx/config/mips/psx.
+
+/* Definitions by GIL for PSX */
+
+#define TARGET_DEFAULT (MASK_GAS+MASK_SOFT_FLOAT+MASK_GPOPT)
+#define TARGET_DEFAULT (MASK_GAS+MASK_SOFT_FLOAT+MASK_GPOPT+MASK_SPLIT_ADDR)
+
+#define CPP_PREDEFINES "-Dmips -DMIPSEL"
+
Expand Down