Add PSY-Q 3.5 and PSY-Q 3.6 compilers for PlayStation 1 (#651)

* Download PSY-Q 3.x compilers

* Add PSY-Q 3.3 and PSY-Q 3.6 PlayStation 1 compilers

* Remove gcc2.6.3-mipsel for good

* Actually install compilers

* Clean-up psyq-msdos folder after downloading it

* Map /proc to allow dosemu2 to run

* Allow to compile with PSY-Q 3.6

* Remove debugging stuff

* Add PSY-Q 3.5 and remove 3.3

* Let ASPSX to be quiet

* Completely replace PSY-Q 3.3 with 3.5

* Modify Castlevania preset

* Add migration from gcc2.6.3-mipsel to psyq3.6

* clean-up

* Typo

* Install DOSEMU in the CI

* Group ENABLE_PS1_SUPPORT set-up

* fix migration script

* Unset the HOME directory globally

* New line

* undo more auto-formatting

* Remove unnecessary comment

* fix

* More autoformatting shenanigans

* Try to fix CI pipeline

* Fix download script

* lint

* lint

* Fix dosemu setup

* Speed-up PSYQ MSDOS compiler

* debugging stuff for the tests

this commit will be reverted

* testing sandbox thingie

* Revert "debugging stuff for the tests"

This reverts commit 6d026b9214.

* Trimming down what Sandbox mounts

* Mount all /dev but read only
This commit is contained in:
Luciano Ciccariello
2023-02-24 12:40:31 +00:00
committed by GitHub
parent e03b357405
commit 8a5de1d2f0
7 changed files with 89 additions and 21 deletions

View File

@@ -54,8 +54,13 @@ jobs:
- name: Install apt dependencies (cached)
uses: awalsh128/cache-apt-pkgs-action@v1
with:
packages: docker-ce docker-ce-cli containerd.io docker-compose-plugin binutils-aarch64-linux-gnu binutils-mips-linux-gnu binutils-powerpc-linux-gnu dos2unix libprotobuf-dev libnl-route-3-dev libncurses5 protobuf-compiler wine
packages: docker-ce docker-ce-cli containerd.io docker-compose-plugin binutils-aarch64-linux-gnu binutils-mips-linux-gnu binutils-powerpc-linux-gnu dos2unix libprotobuf-dev libnl-route-3-dev libncurses5 protobuf-compiler wine software-properties-common
version: 1.0
- name: Install DOSEMU
run: |-
sudo add-apt-repository -y ppa:dosemu2/ppa
sudo apt-get update
sudo apt-get install -y dosemu2
- name: Install nsjail
run: |-
git clone --recursive --branch=3.1 https://github.com/google/nsjail

View File

@@ -70,7 +70,12 @@ RUN if [ "${ENABLE_NDS_SUPPORT}" = "YES" ] || \
# ps1 specifics
RUN if [ "${ENABLE_PS1_SUPPORT}" = "YES" ] ; then \
apt-get install -y dos2unix; \
apt-get update && \
apt-get install -y -o APT::Immediate-Configure=false \
dos2unix software-properties-common && \
add-apt-repository -y ppa:dosemu2/ppa && \
apt-get update && \
apt-get install -y dosemu2; \
fi
# gc/wii specifics

27
backend/compilers/download.py Executable file → Normal file
View File

@@ -469,16 +469,10 @@ def download_ps1():
compilers_path = COMPILERS_DIR / "psyq-compilers"
download_zip(
url="https://github.com/decompals/old-gcc/releases/download/release/gcc-2.6.3.zip",
dl_name="gcc2.6.3-mipsel.zip",
dest_name="gcc2.6.3-mipsel",
create_subdir=True,
download_tar(
url="https://github.com/Xeeynamo/wine-psyq/releases/download/psyq-binaries/psyq-msdos.tar.gz",
dest_name="psyq-msdos-compilers",
)
set_x(COMPILERS_DIR / "gcc2.6.3-mipsel" / "cc1")
set_x(COMPILERS_DIR / "gcc2.6.3-mipsel" / "cpp")
set_x(COMPILERS_DIR / "gcc2.6.3-mipsel" / "gcc")
set_x(COMPILERS_DIR / "gcc2.6.3-mipsel" / "g++")
download_tar(
url="https://github.com/mkst/esa/releases/download/psyq-binaries/psyq-compilers.tar.gz",
@@ -492,7 +486,22 @@ def download_ps1():
dest_path=compilers_path / "psyq",
)
# transfer MS-DOS compilers into the same directory of their Win32 counterpart
shutil.move(
COMPILERS_DIR / "psyq-msdos-compilers/psyq3.3", COMPILERS_DIR / "psyq-compilers"
)
shutil.move(
COMPILERS_DIR / "psyq-msdos-compilers/psyq3.5", COMPILERS_DIR / "psyq-compilers"
)
shutil.move(
COMPILERS_DIR / "psyq-msdos-compilers/psyq3.6", COMPILERS_DIR / "psyq-compilers"
)
shutil.rmtree(COMPILERS_DIR / "psyq-msdos-compilers/")
psyq_to_gcc = {
"3.3": "2.6.0",
"3.5": "2.6.0",
"3.6": "2.6.3",
"4.0": "2.7.2",
"4.1": "2.7.2",
"4.3": "2.8.1",

View File

@@ -276,13 +276,25 @@ CLANG_401 = ClangCompiler(
)
# PS1
GCC263_MIPSEL = GCCPS1Compiler(
id="gcc2.6.3-mipsel",
PSYQ_MSDOS_CC = (
'cpp -P "$INPUT" | unix2dos > object.oc && cp ${COMPILER_DIR}/* . && '
+ '(HOME="." dosemu -quiet -dumb -f ${COMPILER_DIR}/dosemurc -K . -E "CC1PSX.EXE -quiet ${COMPILER_FLAGS} -o object.os object.oc") &&'
+ '(HOME="." dosemu -quiet -dumb -f ${COMPILER_DIR}/dosemurc -K . -E "ASPSX.EXE -quiet object.os -o object.oo") && '
+ '${COMPILER_DIR}/psyq-obj-parser object.oo -o "$OUTPUT"'
)
PSYQ_CC = 'cpp -P "$INPUT" | unix2dos | ${WINE} ${COMPILER_DIR}/CC1PSX.EXE -quiet ${COMPILER_FLAGS} -o "$OUTPUT".s && ${WINE} ${COMPILER_DIR}/ASPSX.EXE -quiet "$OUTPUT".s -o "$OUTPUT".obj && ${COMPILER_DIR}/psyq-obj-parser "$OUTPUT".obj -o "$OUTPUT"'
PSYQ35 = GCCPS1Compiler(
id="psyq3.5",
platform=PS1,
cc='cpp -Wall -lang-c -gstabs "$INPUT" | "${COMPILER_DIR}"/cc1 -mips1 -mcpu=3000 $COMPILER_FLAGS | mips-linux-gnu-as -march=r3000 -mtune=r3000 -no-pad-sections -O1 -o "$OUTPUT"',
cc=PSYQ_MSDOS_CC,
)
PSYQ_CC = 'cpp -P "$INPUT" | unix2dos | ${WINE} ${COMPILER_DIR}/CC1PSX.EXE -quiet ${COMPILER_FLAGS} -o "$OUTPUT".s && ${WINE} ${COMPILER_DIR}/ASPSX.EXE -quiet "$OUTPUT".s -o "$OUTPUT".obj && ${COMPILER_DIR}/psyq-obj-parser "$OUTPUT".obj -o "$OUTPUT"'
PSYQ36 = GCCPS1Compiler(
id="psyq3.6",
platform=PS1,
cc=PSYQ_MSDOS_CC,
)
PSYQ40 = GCCPS1Compiler(
id="psyq4.0",
@@ -744,7 +756,8 @@ _all_compilers: List[Compiler] = [
CLANG_391,
CLANG_401,
# PS1
GCC263_MIPSEL,
PSYQ35,
PSYQ36,
PSYQ40,
PSYQ41,
PSYQ43,
@@ -888,8 +901,8 @@ _all_presets = [
# PS1
Preset(
"Castlevania: Symphony of the Night",
GCC263_MIPSEL,
"-O2 -G0 -funsigned-char",
PSYQ35,
"-O2 -G0 -fsigned-char",
),
Preset(
"Evo's Space Adventures",

View File

@@ -0,0 +1,35 @@
import django.db.migrations.operations.special
from django.apps.registry import Apps
from django.db import migrations
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
def rename_compilers(apps: Apps, schema_editor: BaseDatabaseSchemaEditor) -> None:
"""
Migrate the compiler ID 'gcc-263-mipsel' into 'psyq3.6'
"""
compiler_map = {
"gcc2.6.3-mipsel": "psyq3.6",
}
Scratch = apps.get_model("coreapp", "Scratch")
for row in Scratch.objects.only("compiler").filter(
compiler__endswith="gcc2.6.3-mipsel"
):
if row.compiler in compiler_map:
row.compiler = compiler_map[row.compiler]
row.save(update_fields=["compiler"])
class Migration(migrations.Migration):
dependencies = [
("coreapp", "0029_courses"),
]
operations = [
migrations.RunPython(
code=rename_compilers,
reverse_code=django.db.migrations.operations.special.RunPython.noop,
)
]

View File

@@ -57,7 +57,7 @@ class Sandbox(contextlib.AbstractContextManager["Sandbox"]):
"--chroot", str(settings.SANDBOX_CHROOT_PATH),
"--bindmount", f"{self.path}:/tmp",
"--bindmount", f"{self.path}:/run/user/{os.getuid()}",
"--bindmount", "/dev/null",
"--bindmount_ro", "/dev",
"--bindmount_ro", "/bin",
"--bindmount_ro", "/etc/alternatives",
"--bindmount_ro", "/etc/fonts",
@@ -65,6 +65,7 @@ class Sandbox(contextlib.AbstractContextManager["Sandbox"]):
"--bindmount_ro", "/lib",
"--bindmount_ro", "/lib64",
"--bindmount_ro", "/usr",
"--bindmount_ro", "/proc",
"--bindmount_ro", str(settings.COMPILER_BASE_PATH),
"--env", "PATH=/usr/bin:/bin",
"--cwd", "/tmp",

View File

@@ -18,7 +18,6 @@
"ee-gcc2.96": "EE GCC 2.96 build 001003-1",
"ee-gcc3.2-040921": "EE GCC 3.2 build 040921",
"egcs_1.1.2-4": "EGCS 1.1.2-4 (gcc egcs-2.91.66)",
"gcc2.6.3-mipsel": "GCC 2.6.3 (mipsel)",
"gcc2.7.2kmc": "GCC 2.7.2 (KMC)",
"gcc2.7.2sn": "GCC 2.7.2 (SN)",
"gcc2.7.2snew": "GCC 2.7.2 (SN, experimental)",
@@ -79,6 +78,8 @@
"gcc-5026": "GCC 4.0.0 (Xcode 2.1) (C)",
"gcc-5026-cpp": "GCC 4.0.0 (Xcode 2.1) (C++)",
"gcc3-1041": "GCC 3.1 (Mac OS 10.1.4) (C)",
"psyq3.5": "PSYQ3.5 (gcc 2.6.0 + aspsx 2.34)",
"psyq3.6": "PSYQ3.6 (gcc 2.6.3 + aspsx 2.34)",
"psyq4.0": "PSYQ4.0 (gcc 2.7.2)",
"psyq4.1": "PSYQ4.1 (gcc 2.7.2)",
"psyq4.3": "PSYQ4.3 (gcc 2.8.1)",
@@ -173,7 +174,6 @@
"mwcc_opt_level.-O4": "Extreme optimization",
"mwcc_opt_level.-O4,p": "Extreme optimization + speed",
"mwcc_opt_level.-O4,s": "Extreme optimization + space",
"mwcc_floating_point": "Floating point",
"mwcc_floating_point.-fp soft": "Software emulation; default",
"mwcc_floating_point.-fp off": "No floating point",