Build the mips toolchain from source in the build image.

Ubuntu 26.04 has no mips cross compiler to install, so a first stage builds
binutils and gcc with spawn-compiler.sh and the final image copies the result
out of it. Scratch branch: this exists only so the image can be built from the
SDL3 recipe before the migration lands, and it is not meant to be merged.
This commit is contained in:
Nicolas 'Pixel' Noble
2026-08-27 14:21:45 -07:00
parent e1b865f73d
commit 68b34dfeb2
3 changed files with 51 additions and 16 deletions
+8
View File
@@ -0,0 +1,8 @@
# The build image only needs a couple of scripts out of the tree, so keep the
# build context from dragging in a full local build.
.git
objs/
bins/
/pcsx-redux
/pcsx-redux-tests
*.AppImage
+32 -6
View File
@@ -1,6 +1,27 @@
# Dockerfile for ghcr.io/grumpycoders/pcsx-redux-build
#
# This one needs the repository root as its build context, as the first stage
# builds the mips toolchain using tools/linux-mips/spawn-compiler.sh:
#
# docker build -f tools/build/Dockerfile -t ghcr.io/grumpycoders/pcsx-redux-build .
FROM ubuntu:24.04
FROM ubuntu:26.04 AS toolchain
ENV DEBIAN_FRONTEND noninteractive
ENV TZ Etc/GMT
RUN apt update
RUN apt dist-upgrade -y
RUN apt install -y make g++ wget bzip2 xz-utils bison flex texinfo
RUN apt install -y libgmp-dev libmpfr-dev libmpc-dev
ARG JOBS=
WORKDIR /tmp/toolchain
COPY tools/linux-mips/spawn-compiler.sh .
RUN JOBS=$JOBS sh spawn-compiler.sh
FROM ubuntu:26.04
# The tzdata package isn't docker-friendly, and something pulls it.
ENV DEBIAN_FRONTEND noninteractive
@@ -16,7 +37,6 @@ RUN apt install -y pkg-config
# Compilers & base libraries
RUN apt install -y g++
RUN apt install -y g++-mipsel-linux-gnu
# Development packages
RUN apt install -y libavcodec-dev
@@ -25,7 +45,7 @@ RUN apt install -y libavutil-dev
RUN apt install -y libcapstone-dev
RUN apt install -y libcurl4-openssl-dev
RUN apt install -y libfreetype-dev
RUN apt install -y libglfw3-dev
RUN apt install -y libsdl3-dev
RUN apt install -y libswresample-dev
RUN apt install -y libuv1-dev
RUN apt install -y zlib1g-dev
@@ -33,7 +53,7 @@ RUN apt install -y zlib1g-dev
# CI utilities
RUN apt install -y curl wget
RUN apt install -y xvfb
RUN apt install -y python3-pip python3-setuptools patchelf desktop-file-utils libgdk-pixbuf2.0-dev fakeroot strace
RUN apt install -y python3-pip python3-setuptools patchelf desktop-file-utils libgdk-pixbuf-2.0-dev fakeroot strace
RUN apt install -y glibc-tools lcov
RUN apt install -y file
@@ -42,11 +62,16 @@ RUN apt install -y libfuse2t64
RUN apt install -y fuse
# AppImage tools
RUN apt install -y imagemagick-6.q16 gtk-update-icon-cache appstream
RUN apt install -y imagemagick-7.q16 gtk-update-icon-cache appstream
RUN apt install -y squashfs-tools zip zsync
# The mips toolchain, built from source in the first stage. Ubuntu dropped the
# mipsel cross compilers, so there's no distribution package to install here.
COPY --from=toolchain /usr/local /usr/local
# Both projects name their releases after uname's spelling of the architecture,
# which is also the one the AppImage ends up carrying.
WORKDIR /tmp
# Both projects name their releases after uname's spelling of the architecture.
RUN wget https://github.com/AppImage/appimagetool/releases/download/continuous/appimagetool-`uname -m`.AppImage && \
chmod +x appimagetool-`uname -m`.AppImage && \
mv appimagetool-`uname -m`.AppImage /usr/bin/appimagetool
@@ -59,6 +84,7 @@ RUN wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous
LABEL org.opencontainers.image.source=https://github.com/grumpycoders/pcsx-redux
RUN mkdir /project
ENV HOME=/home/coder
RUN mkdir -p /home/coder/dconf
RUN chmod a+rwx /home/coder/dconf
+11 -10
View File
@@ -1,17 +1,18 @@
#!/bin/sh
#
# Building gcc from source isn't necessarily an easy task, and it requires
# a lot of various dependency packages to work properly. The easiest way
# to use a mips compiler for Linux is still to use a package from your
# distribution. Nevertheless, here's how to build a working mips compiler
# that can produce code for the R3000A CPU, granted you have the necessary
# dependencies to do so. The script can be run as root, or as a regular user
# when the PREFIX environment variable is provided.
# a lot of various dependency packages to work properly. Here's how to build
# a working mips compiler that can produce code for the R3000A CPU, granted
# you have the necessary dependencies to do so. The script can be run as
# root, or as a regular user when the PREFIX environment variable is
# provided. Set JOBS to override the parallelism, which defaults to the
# number of available cores.
#
set -ex
PREFIX=${PREFIX:-"/usr/local"}
JOBS=${JOBS:-$(nproc 2> /dev/null || echo 1)}
for url in https://ftpmirror.gnu.org/gnu/binutils/binutils-2.47.tar.gz https://mirrors.kernel.org/gnu/binutils/binutils-2.47.tar.gz ; do
wget --max-redirect=2 --timeout=60 --continue --trust-server-names $url && break
@@ -19,7 +20,7 @@ done
tar xvfz binutils-2.47.tar.gz
cd binutils-2.47
./configure --target=mipsel-none-elf --disable-multilib --disable-nls --disable-werror --prefix=$PREFIX
make
make -j$JOBS
make install-strip
cd ..
@@ -32,9 +33,9 @@ cd gcc-16.2.0
mkdir build
cd build
../configure --target=mipsel-none-elf --without-isl --disable-nls --disable-threads --disable-shared --disable-libssp --disable-libstdcxx-pch --disable-libgomp --disable-werror --without-headers --disable-hosted-libstdcxx --with-as=$PREFIX/bin/mipsel-none-elf-as --with-ld=$PREFIX/bin/mipsel-none-elf-ld --enable-languages=c,c++ --prefix=$PREFIX
make all-gcc
make -j$JOBS all-gcc
make install-strip-gcc
make all-target-libgcc
make -j$JOBS all-target-libgcc
make install-strip-target-libgcc
make all-target-libstdc++-v3
make -j$JOBS all-target-libstdc++-v3
make install-strip-target-libstdc++-v3