From 8d8e172a64d05cd24e568a1dfe3446ff2e37edfa Mon Sep 17 00:00:00 2001 From: John Liljegren Date: Sat, 8 Aug 2026 14:17:38 -0400 Subject: [PATCH 1/4] ido7.1_irix4 added as script in ido7.1 --- platforms/n64/ido7.1/cc-irix4 | 144 +++++++++++++++++++++++++ platforms/n64/ido7.1/darwin/Dockerfile | 1 + platforms/n64/ido7.1/linux/Dockerfile | 1 + templates/common/default.j2 | 4 + values.yaml | 4 + 5 files changed, 154 insertions(+) create mode 100755 platforms/n64/ido7.1/cc-irix4 diff --git a/platforms/n64/ido7.1/cc-irix4 b/platforms/n64/ido7.1/cc-irix4 new file mode 100755 index 0000000..1b0bc82 --- /dev/null +++ b/platforms/n64/ido7.1/cc-irix4 @@ -0,0 +1,144 @@ +#!/bin/sh +# IDO 7.1 with the IRIX 4 compatibility frontend. +# +# Reproduces what the stock IDO 7.1 driver does for `cc -irix4`: preprocessing +# and the C frontend come from the IRIX 4 toolchain (acpp + accom, run under +# qemu-irix), and the backend is stock IDO 7.1 (uopt/ugen/as1). Verified to +# produce byte-identical objects to `cc -c -irix4` run against a full IRIX 4 +# subtree. +# +# It exists because the two halves live in different compiler packages: the +# frontend in ido4.1, the backend in ido7.1. Both are used unmodified, so no +# new compiler package is needed - hence this script living in the repo rather +# than being shipped inside one. +# +# usage: cc-irix4 --frontend --backend \ +# [flags] -o output.o input.c +set -e + +frontend= +backend= +opt=-O1 +debug=-g0 +mips=-mips2 +# The driver's own default is 8, but this compiler is N64-only and every other +# N64 IDO entry on the site compiles at -G 0. Defaulting to 8 would silently +# change codegen for anyone carrying flags over from ido7.1. -G8 stays +# selectable for the driver default. +gpsize=0 +ansi=-Xxansi +prototypes=-Xprototypes +sopt=0 +verbose=0 +out= +input= +cppargs="" +accomargs="" + +add_cpp() { cppargs="$cppargs $1"; } +add_accom() { accomargs="$accomargs $1"; } + +while [ $# -gt 0 ]; do + case "$1" in + --frontend) shift; frontend=$1 ;; + --backend) shift; backend=$1 ;; + -O0|-O1|-O2|-O3) opt=$1 ;; + # accom implements -Xg0/-Xg1 only, and knows mips1/mips2 only. The + # stock driver fails the same way on -g2, -g3 and -mips3 under -irix4. + -g0|-g1|-g2|-g3) debug=$1 ;; + -mips1|-mips2|-mips3) mips=$1 ;; + # -G accepted as -G0, -G 0 and -G=0; the site's flagset emits -G0. + -G) shift; gpsize=$1 ;; + -G=*) gpsize=${1#-G=} ;; + -G*) gpsize=${1#-G} ;; + -Xansi|-Xxansi) ansi=$1 ;; + -Xprototypes) prototypes=-Xprototypes ;; + -Xnoprototypes) prototypes= ;; + -sopt) sopt=1 ;; + # accom is strict C89, but acpp's -+ strips // comments before it ever + # sees them. This is what the driver's -Xcpluscomm/-Wp,-+ reach. + -Xcpluscomm) add_cpp "-+" ;; + -Wp,*) + IFS=, + for wparg in ${1#-Wp,}; do [ -n "$wparg" ] && add_cpp "$wparg"; done + unset IFS + ;; + -X*) add_accom "$1" ;; + -D*|-U*) add_cpp "$1" ;; + -I) shift; add_cpp "-I$1" ;; + -I*) add_cpp "$1" ;; + -trigraphs|-nostdinc) add_cpp "$1" ;; + -v) verbose=1 ;; + -o) shift; out=$1 ;; + # Driver-level flags with no meaning once the passes are run directly. + # -irix4 is accepted as a no-op: it is what this compiler *is*, and + # scratches carried over from a driver-based setup will still pass it. + -c|-non_shared|-KPIC|-32|-EB|-irix4) ;; + -woff) shift ;; + -woff*) ;; + -*) echo "cc-irix4: unsupported flag: $1" >&2; exit 1 ;; + *) input=$1 ;; + esac + shift +done + +[ -n "$frontend" ] || { echo "cc-irix4: --frontend not set" >&2; exit 1; } +[ -n "$backend" ] || { echo "cc-irix4: --backend not set" >&2; exit 1; } +[ -n "$input" ] || { echo "cc-irix4: no input file" >&2; exit 1; } +[ -n "$out" ] || { echo "cc-irix4: no output file (-o)" >&2; exit 1; } + +qemu="$frontend/usr/bin/qemu-irix-4.0" +for needed in "$qemu" "$frontend/usr/lib/acpp" "$frontend/usr/lib/accom" \ + "$backend/uopt" "$backend/ugen" "$backend/as1"; do + [ -x "$needed" ] || { + echo "cc-irix4: missing $needed (are the ido4.1 and ido7.1" \ + "compilers installed?)" >&2 + exit 1 + } +done + +work="$out.irix4work" +rm -rf "$work" +mkdir -p "$work" +trap 'rm -rf "$work"' EXIT + +mipsnum=${mips#-mips} + +run() { + [ "$verbose" -eq 1 ] && echo "+ $*" >&2 + "$@" +} + +# 1. IRIX 4 preprocessor. Define set matches what the 7.1 driver passes to +# acpp under -irix4, minus the /usr/irix4 system include path (the site +# compiles self-contained translation units). +run "$qemu" -silent -L "$frontend" "$frontend/usr/lib/acpp" \ + -D__EXTENSIONS__ -trigraphs -undef -p \ + -DLANGUAGE_C -D_LANGUAGE_C -D__INLINE_INTRINSICS \ + -Dsgi -DSVR3 -D__SVR3 -D__sgi -Dunix -Dmips -Dhost_mips \ + -D__unix -D__host_mips -D__DSO__ \ + -DSYSTYPE_SYSV -D_SYSTYPE_SYSV -D_LONGLONG \ + "-D__mips=$mipsnum" -D_MIPSEB -DMIPSEB \ + $cppargs "$input" > "$work/src.i" + +# 2. Optional external source optimiser. The driver runs copt between acpp and +# accom under -sopt, on the preprocessed source rather than on ucode. +source_i="$work/src.i" +if [ "$sopt" -eq 1 ]; then + run "$qemu" -silent -L "$frontend" "$frontend/usr/lib/copt" \ + "-I=$work/src.i" "-CMP=$work/src.copt.i" -cp=i + source_i="$work/src.copt.i" +fi + +# 3. IRIX 4 C frontend -> ucode (.B) + symbol table (.T). +run "$qemu" -silent -L "$frontend" "$frontend/usr/lib/accom" \ + -Xv "$mips" -EB "-X${debug#-}" "$opt" $prototypes "$ansi" $accomargs \ + -XS"$work/src.T" < "$source_i" > "$work/src.B" + +# 4. Stock IDO 7.1 backend, native. +run "$backend/uopt" -G "$gpsize" "$mips" -EB "$debug" "$opt" \ + "$work/src.B" "$work/src.O" -t "$work/src.T" "$work/uo" +run "$backend/ugen" -G "$gpsize" "$mips" -EB "$debug" "$opt" \ + "$work/src.O" -o "$work/src.G" -t "$work/src.T" -temp "$work/ug" +run "$backend/as1" -t5_ll_sc_bug -elf -G "$gpsize" -p0 "$mips" -EB "$debug" "$opt" \ + "$work/src.G" -o "$out" -t "$work/src.T" diff --git a/platforms/n64/ido7.1/darwin/Dockerfile b/platforms/n64/ido7.1/darwin/Dockerfile index 944e166..65a8a4a 100644 --- a/platforms/n64/ido7.1/darwin/Dockerfile +++ b/platforms/n64/ido7.1/darwin/Dockerfile @@ -7,6 +7,7 @@ RUN mkdir -p /compilers/n64/ido7.1 RUN wget -O ido-7.1-recomp-macos.tar.gz "https://github.com/decompals/ido-static-recomp/releases/download/v1.2/ido-7.1-recomp-macos.tar.gz" RUN tar xvzf ido-7.1-recomp-macos.tar.gz -C /compilers/n64/ido7.1 +COPY platforms/n64/ido7.1/cc-irix4 /compilers/n64/ido7.1/cc-irix4 RUN chown -R root:root /compilers/n64/ido7.1/ RUN chmod +x /compilers/n64/ido7.1/* diff --git a/platforms/n64/ido7.1/linux/Dockerfile b/platforms/n64/ido7.1/linux/Dockerfile index 4bdc372..a299f8a 100644 --- a/platforms/n64/ido7.1/linux/Dockerfile +++ b/platforms/n64/ido7.1/linux/Dockerfile @@ -7,6 +7,7 @@ RUN mkdir -p /compilers/n64/ido7.1 RUN wget -O ido-7.1-recomp-linux.tar.gz "https://github.com/decompals/ido-static-recomp/releases/download/v1.2/ido-7.1-recomp-linux.tar.gz" RUN tar xvzf ido-7.1-recomp-linux.tar.gz -C /compilers/n64/ido7.1 +COPY platforms/n64/ido7.1/cc-irix4 /compilers/n64/ido7.1/cc-irix4 RUN chown -R root:root /compilers/n64/ido7.1/ RUN chmod +x /compilers/n64/ido7.1/* diff --git a/templates/common/default.j2 b/templates/common/default.j2 index 9ad581c..2c04ed7 100644 --- a/templates/common/default.j2 +++ b/templates/common/default.j2 @@ -24,6 +24,10 @@ RUN wget -O /compilers/{{ platform }}/{{ id }}/{{ filename }} "{{ url }}" RUN rm -rf /compilers/{{ platform }}/{{ id }}/{{ dir }} {%- endfor %} +{%- for src in copy_files | default([]) %} +COPY {{ src }} /compilers/{{ platform }}/{{ id }}/{{ src.split("/")[-1] }} +{%- endfor %} + RUN chown -R root:root /compilers/{{ platform }}/{{ id }}/ RUN chmod +x /compilers/{{ platform }}/{{ id }}/* diff --git a/values.yaml b/values.yaml index 2cb511e..b0e6c2c 100644 --- a/values.yaml +++ b/values.yaml @@ -116,11 +116,15 @@ compilers: template: common/default arch: linux file: https://github.com/decompals/ido-static-recomp/releases/download/v1.2/ido-7.1-recomp-linux.tar.gz + copy_files: + - platforms/n64/ido7.1/cc-irix4 - id: ido7.1 platform: n64 template: common/default arch: darwin file: https://github.com/decompals/ido-static-recomp/releases/download/v1.2/ido-7.1-recomp-macos.tar.gz + copy_files: + - platforms/n64/ido7.1/cc-irix4 - id: mips_pro_744 platform: n64 From 34937f863bf6f95d6c4aeeaf53d5f288dfcbde16 Mon Sep 17 00:00:00 2001 From: John Liljegren Date: Sun, 9 Aug 2026 12:14:38 -0400 Subject: [PATCH 2/4] make cc-irix4 loaded from external gist source --- platforms/n64/ido7.1/darwin/Dockerfile | 1 - platforms/n64/ido7.1/linux/Dockerfile | 1 - templates/common/default.j2 | 4 ---- values.yaml | 8 +++----- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/platforms/n64/ido7.1/darwin/Dockerfile b/platforms/n64/ido7.1/darwin/Dockerfile index 65a8a4a..944e166 100644 --- a/platforms/n64/ido7.1/darwin/Dockerfile +++ b/platforms/n64/ido7.1/darwin/Dockerfile @@ -7,7 +7,6 @@ RUN mkdir -p /compilers/n64/ido7.1 RUN wget -O ido-7.1-recomp-macos.tar.gz "https://github.com/decompals/ido-static-recomp/releases/download/v1.2/ido-7.1-recomp-macos.tar.gz" RUN tar xvzf ido-7.1-recomp-macos.tar.gz -C /compilers/n64/ido7.1 -COPY platforms/n64/ido7.1/cc-irix4 /compilers/n64/ido7.1/cc-irix4 RUN chown -R root:root /compilers/n64/ido7.1/ RUN chmod +x /compilers/n64/ido7.1/* diff --git a/platforms/n64/ido7.1/linux/Dockerfile b/platforms/n64/ido7.1/linux/Dockerfile index a299f8a..4bdc372 100644 --- a/platforms/n64/ido7.1/linux/Dockerfile +++ b/platforms/n64/ido7.1/linux/Dockerfile @@ -7,7 +7,6 @@ RUN mkdir -p /compilers/n64/ido7.1 RUN wget -O ido-7.1-recomp-linux.tar.gz "https://github.com/decompals/ido-static-recomp/releases/download/v1.2/ido-7.1-recomp-linux.tar.gz" RUN tar xvzf ido-7.1-recomp-linux.tar.gz -C /compilers/n64/ido7.1 -COPY platforms/n64/ido7.1/cc-irix4 /compilers/n64/ido7.1/cc-irix4 RUN chown -R root:root /compilers/n64/ido7.1/ RUN chmod +x /compilers/n64/ido7.1/* diff --git a/templates/common/default.j2 b/templates/common/default.j2 index 2c04ed7..9ad581c 100644 --- a/templates/common/default.j2 +++ b/templates/common/default.j2 @@ -24,10 +24,6 @@ RUN wget -O /compilers/{{ platform }}/{{ id }}/{{ filename }} "{{ url }}" RUN rm -rf /compilers/{{ platform }}/{{ id }}/{{ dir }} {%- endfor %} -{%- for src in copy_files | default([]) %} -COPY {{ src }} /compilers/{{ platform }}/{{ id }}/{{ src.split("/")[-1] }} -{%- endfor %} - RUN chown -R root:root /compilers/{{ platform }}/{{ id }}/ RUN chmod +x /compilers/{{ platform }}/{{ id }}/* diff --git a/values.yaml b/values.yaml index b0e6c2c..f02e58d 100644 --- a/values.yaml +++ b/values.yaml @@ -115,16 +115,14 @@ compilers: platform: n64 template: common/default arch: linux - file: https://github.com/decompals/ido-static-recomp/releases/download/v1.2/ido-7.1-recomp-linux.tar.gz - copy_files: - - platforms/n64/ido7.1/cc-irix4 + files: + - https://github.com/decompals/ido-static-recomp/releases/download/v1.2/ido-7.1-recomp-linux.tar.gz + - https://gist.githubusercontent.com/jtl3d/a3d54c4d2eadfedc7d4287e489dba902/raw/8dafb02ff809734d95c23dab00cb9fcf58c974d8/cc-irix4 - id: ido7.1 platform: n64 template: common/default arch: darwin file: https://github.com/decompals/ido-static-recomp/releases/download/v1.2/ido-7.1-recomp-macos.tar.gz - copy_files: - - platforms/n64/ido7.1/cc-irix4 - id: mips_pro_744 platform: n64 From f82088246e27f44ab9f296e1483854884e744aaf Mon Sep 17 00:00:00 2001 From: John Liljegren Date: Sun, 9 Aug 2026 12:43:30 -0400 Subject: [PATCH 3/4] actually removing the cc-irix4 file --- platforms/n64/ido7.1/cc-irix4 | 144 ---------------------------------- 1 file changed, 144 deletions(-) delete mode 100755 platforms/n64/ido7.1/cc-irix4 diff --git a/platforms/n64/ido7.1/cc-irix4 b/platforms/n64/ido7.1/cc-irix4 deleted file mode 100755 index 1b0bc82..0000000 --- a/platforms/n64/ido7.1/cc-irix4 +++ /dev/null @@ -1,144 +0,0 @@ -#!/bin/sh -# IDO 7.1 with the IRIX 4 compatibility frontend. -# -# Reproduces what the stock IDO 7.1 driver does for `cc -irix4`: preprocessing -# and the C frontend come from the IRIX 4 toolchain (acpp + accom, run under -# qemu-irix), and the backend is stock IDO 7.1 (uopt/ugen/as1). Verified to -# produce byte-identical objects to `cc -c -irix4` run against a full IRIX 4 -# subtree. -# -# It exists because the two halves live in different compiler packages: the -# frontend in ido4.1, the backend in ido7.1. Both are used unmodified, so no -# new compiler package is needed - hence this script living in the repo rather -# than being shipped inside one. -# -# usage: cc-irix4 --frontend --backend \ -# [flags] -o output.o input.c -set -e - -frontend= -backend= -opt=-O1 -debug=-g0 -mips=-mips2 -# The driver's own default is 8, but this compiler is N64-only and every other -# N64 IDO entry on the site compiles at -G 0. Defaulting to 8 would silently -# change codegen for anyone carrying flags over from ido7.1. -G8 stays -# selectable for the driver default. -gpsize=0 -ansi=-Xxansi -prototypes=-Xprototypes -sopt=0 -verbose=0 -out= -input= -cppargs="" -accomargs="" - -add_cpp() { cppargs="$cppargs $1"; } -add_accom() { accomargs="$accomargs $1"; } - -while [ $# -gt 0 ]; do - case "$1" in - --frontend) shift; frontend=$1 ;; - --backend) shift; backend=$1 ;; - -O0|-O1|-O2|-O3) opt=$1 ;; - # accom implements -Xg0/-Xg1 only, and knows mips1/mips2 only. The - # stock driver fails the same way on -g2, -g3 and -mips3 under -irix4. - -g0|-g1|-g2|-g3) debug=$1 ;; - -mips1|-mips2|-mips3) mips=$1 ;; - # -G accepted as -G0, -G 0 and -G=0; the site's flagset emits -G0. - -G) shift; gpsize=$1 ;; - -G=*) gpsize=${1#-G=} ;; - -G*) gpsize=${1#-G} ;; - -Xansi|-Xxansi) ansi=$1 ;; - -Xprototypes) prototypes=-Xprototypes ;; - -Xnoprototypes) prototypes= ;; - -sopt) sopt=1 ;; - # accom is strict C89, but acpp's -+ strips // comments before it ever - # sees them. This is what the driver's -Xcpluscomm/-Wp,-+ reach. - -Xcpluscomm) add_cpp "-+" ;; - -Wp,*) - IFS=, - for wparg in ${1#-Wp,}; do [ -n "$wparg" ] && add_cpp "$wparg"; done - unset IFS - ;; - -X*) add_accom "$1" ;; - -D*|-U*) add_cpp "$1" ;; - -I) shift; add_cpp "-I$1" ;; - -I*) add_cpp "$1" ;; - -trigraphs|-nostdinc) add_cpp "$1" ;; - -v) verbose=1 ;; - -o) shift; out=$1 ;; - # Driver-level flags with no meaning once the passes are run directly. - # -irix4 is accepted as a no-op: it is what this compiler *is*, and - # scratches carried over from a driver-based setup will still pass it. - -c|-non_shared|-KPIC|-32|-EB|-irix4) ;; - -woff) shift ;; - -woff*) ;; - -*) echo "cc-irix4: unsupported flag: $1" >&2; exit 1 ;; - *) input=$1 ;; - esac - shift -done - -[ -n "$frontend" ] || { echo "cc-irix4: --frontend not set" >&2; exit 1; } -[ -n "$backend" ] || { echo "cc-irix4: --backend not set" >&2; exit 1; } -[ -n "$input" ] || { echo "cc-irix4: no input file" >&2; exit 1; } -[ -n "$out" ] || { echo "cc-irix4: no output file (-o)" >&2; exit 1; } - -qemu="$frontend/usr/bin/qemu-irix-4.0" -for needed in "$qemu" "$frontend/usr/lib/acpp" "$frontend/usr/lib/accom" \ - "$backend/uopt" "$backend/ugen" "$backend/as1"; do - [ -x "$needed" ] || { - echo "cc-irix4: missing $needed (are the ido4.1 and ido7.1" \ - "compilers installed?)" >&2 - exit 1 - } -done - -work="$out.irix4work" -rm -rf "$work" -mkdir -p "$work" -trap 'rm -rf "$work"' EXIT - -mipsnum=${mips#-mips} - -run() { - [ "$verbose" -eq 1 ] && echo "+ $*" >&2 - "$@" -} - -# 1. IRIX 4 preprocessor. Define set matches what the 7.1 driver passes to -# acpp under -irix4, minus the /usr/irix4 system include path (the site -# compiles self-contained translation units). -run "$qemu" -silent -L "$frontend" "$frontend/usr/lib/acpp" \ - -D__EXTENSIONS__ -trigraphs -undef -p \ - -DLANGUAGE_C -D_LANGUAGE_C -D__INLINE_INTRINSICS \ - -Dsgi -DSVR3 -D__SVR3 -D__sgi -Dunix -Dmips -Dhost_mips \ - -D__unix -D__host_mips -D__DSO__ \ - -DSYSTYPE_SYSV -D_SYSTYPE_SYSV -D_LONGLONG \ - "-D__mips=$mipsnum" -D_MIPSEB -DMIPSEB \ - $cppargs "$input" > "$work/src.i" - -# 2. Optional external source optimiser. The driver runs copt between acpp and -# accom under -sopt, on the preprocessed source rather than on ucode. -source_i="$work/src.i" -if [ "$sopt" -eq 1 ]; then - run "$qemu" -silent -L "$frontend" "$frontend/usr/lib/copt" \ - "-I=$work/src.i" "-CMP=$work/src.copt.i" -cp=i - source_i="$work/src.copt.i" -fi - -# 3. IRIX 4 C frontend -> ucode (.B) + symbol table (.T). -run "$qemu" -silent -L "$frontend" "$frontend/usr/lib/accom" \ - -Xv "$mips" -EB "-X${debug#-}" "$opt" $prototypes "$ansi" $accomargs \ - -XS"$work/src.T" < "$source_i" > "$work/src.B" - -# 4. Stock IDO 7.1 backend, native. -run "$backend/uopt" -G "$gpsize" "$mips" -EB "$debug" "$opt" \ - "$work/src.B" "$work/src.O" -t "$work/src.T" "$work/uo" -run "$backend/ugen" -G "$gpsize" "$mips" -EB "$debug" "$opt" \ - "$work/src.O" -o "$work/src.G" -t "$work/src.T" -temp "$work/ug" -run "$backend/as1" -t5_ll_sc_bug -elf -G "$gpsize" -p0 "$mips" -EB "$debug" "$opt" \ - "$work/src.G" -o "$out" -t "$work/src.T" From a991a1c68a3c4abef10f3cbfcb18f6886d9dd5fb Mon Sep 17 00:00:00 2001 From: John Liljegren Date: Sun, 9 Aug 2026 13:06:02 -0400 Subject: [PATCH 4/4] add wget step to dockerfile --- platforms/n64/ido7.1/linux/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/platforms/n64/ido7.1/linux/Dockerfile b/platforms/n64/ido7.1/linux/Dockerfile index 4bdc372..cef4107 100644 --- a/platforms/n64/ido7.1/linux/Dockerfile +++ b/platforms/n64/ido7.1/linux/Dockerfile @@ -7,6 +7,7 @@ RUN mkdir -p /compilers/n64/ido7.1 RUN wget -O ido-7.1-recomp-linux.tar.gz "https://github.com/decompals/ido-static-recomp/releases/download/v1.2/ido-7.1-recomp-linux.tar.gz" RUN tar xvzf ido-7.1-recomp-linux.tar.gz -C /compilers/n64/ido7.1 +RUN wget -O /compilers/n64/ido7.1/cc-irix4 "https://gist.githubusercontent.com/jtl3d/a3d54c4d2eadfedc7d4287e489dba902/raw/8dafb02ff809734d95c23dab00cb9fcf58c974d8/cc-irix4" RUN chown -R root:root /compilers/n64/ido7.1/ RUN chmod +x /compilers/n64/ido7.1/*