diff --git a/.github/workflows/deploy-win.yml b/.github/workflows/deploy-win.yml index fca7c444d..3e870d2a1 100644 --- a/.github/workflows/deploy-win.yml +++ b/.github/workflows/deploy-win.yml @@ -11,7 +11,7 @@ on: jobs: build_dist: - runs-on: windows-2019 + runs-on: windows-2022 outputs: release_name: ${{ steps.build_dist.outputs.release_name }} branch: ${{ steps.build_dist.outputs.branch }} diff --git a/.github/workflows/test-win.yml b/.github/workflows/test-win.yml index a17cba6e8..99492aa50 100644 --- a/.github/workflows/test-win.yml +++ b/.github/workflows/test-win.yml @@ -4,7 +4,7 @@ on: [push, pull_request] jobs: test: - runs-on: windows-2019 + runs-on: windows-2022 steps: - name: Ask Git to use LF line endings diff --git a/CLAUDE.md b/CLAUDE.md index 5db914d0b..54e9c6272 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -58,6 +58,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co - Comments should provide additional context or explain "why" something is done, not just restate "what" is being done. - Only add function header comments when they provide meaningful information beyond what the function name and signature convey. - Use British English spellings for things like "initialise" and "colour", but only in new code. It's a preference not a hard requirement +- Use modern Typescript features like optional chaining when updating existing code or adding new code ## Testing Guidelines - Use Vitest for unit tests (compatible with Jest syntax) diff --git a/etc/config/c++.amazon.properties b/etc/config/c++.amazon.properties index 94f161977..65930f6c0 100644 --- a/etc/config/c++.amazon.properties +++ b/etc/config/c++.amazon.properties @@ -4711,11 +4711,11 @@ libs.brigand.versions.trunk.path=/opt/compiler-explorer/libs/brigand/trunk/inclu libs.brigand.versions.130.path=/opt/compiler-explorer/libs/brigand/1.3.0 libs.bronto.name=Bronto -libs.bronto.versions=0_1_0 +libs.bronto.versions=0_2_0 libs.bronto.url=https://brontosource.dev/ -libs.bronto.versions.0_1_0.version=0.1.0 -libs.bronto.versions.0_1_0.alias=trunk -libs.bronto.versions.0_1_0.path=/opt/compiler-explorer/libs/bronto/v0.1.0/include +libs.bronto.versions.0_2_0.version=0.2.0 +libs.bronto.versions.0_2_0.alias=trunk +libs.bronto.versions.0_2_0.path=/opt/compiler-explorer/libs/bronto/v0.2.0/include libs.catch2.name=Catch2 libs.catch2.description=Catch2 diff --git a/etc/config/c3.amazon.properties b/etc/config/c3.amazon.properties index 85864b4dc..a6a59b25e 100644 --- a/etc/config/c3.amazon.properties +++ b/etc/config/c3.amazon.properties @@ -1,10 +1,10 @@ compilers=&c3c compilerType=c3c -defaultCompiler=c3c062 +defaultCompiler=c3c072 supportsBinary=false supportsBinaryObject=false supportsExecute=false -group.c3c.compilers=c3c04:c3c050:c3c055:c3c060:c3c061:c3c062 +group.c3c.compilers=c3c04:c3c050:c3c055:c3c060:c3c061:c3c062:c3c063:c3c064:c3c065:c3c066:c3c067:c3c068:c3c070:c3c071:c3c072 group.c3c.isSemVer=true group.c3c.baseName=c3 @@ -26,3 +26,30 @@ compiler.c3c061.exe=/opt/compiler-explorer/c3-0.6.1/c3c compiler.c3c062.semver=0.6.2 compiler.c3c062.exe=/opt/compiler-explorer/c3-0.6.2/c3c + +compiler.c3c063.semver=0.6.3 +compiler.c3c063.exe=/opt/compiler-explorer/c3-0.6.3/c3c + +compiler.c3c064.semver=0.6.4 +compiler.c3c064.exe=/opt/compiler-explorer/c3-0.6.4/c3c + +compiler.c3c065.semver=0.6.5 +compiler.c3c065.exe=/opt/compiler-explorer/c3-0.6.5/c3c + +compiler.c3c066.semver=0.6.6 +compiler.c3c066.exe=/opt/compiler-explorer/c3-0.6.6/c3c + +compiler.c3c067.semver=0.6.7 +compiler.c3c067.exe=/opt/compiler-explorer/c3-0.6.7/c3c + +compiler.c3c068.semver=0.6.8 +compiler.c3c068.exe=/opt/compiler-explorer/c3-0.6.8/c3c + +compiler.c3c070.semver=0.7.0 +compiler.c3c070.exe=/opt/compiler-explorer/c3-0.7.0/c3c + +compiler.c3c071.semver=0.7.1 +compiler.c3c071.exe=/opt/compiler-explorer/c3-0.7.1/c3c + +compiler.c3c072.semver=0.7.2 +compiler.c3c072.exe=/opt/compiler-explorer/c3-0.7.2/c3c diff --git a/etc/config/fortran.amazon.properties b/etc/config/fortran.amazon.properties index ce2e6e791..87211fcff 100644 --- a/etc/config/fortran.amazon.properties +++ b/etc/config/fortran.amazon.properties @@ -13,6 +13,7 @@ group.gfortran_86.compilers=&gfortranassert:gfortran494:gfortran550:gfortran63:g group.gfortran_86.groupName=GFORTRAN x86-64 group.gfortran_86.isSemVer=true group.gfortran_86.baseName=x86-64 gfortran +group.gfortran_86.compilerCategories=gfortran compiler.gfortran494.exe=/opt/compiler-explorer/gcc-4.9.4/bin/gfortran compiler.gfortran494.semver=4.9.4 compiler.gfortran550.exe=/opt/compiler-explorer/gcc-5.5.0/bin/gfortran @@ -95,6 +96,7 @@ compiler.gfortransnapshot.isNightly=true ## GFORTRAN x86 build with "assertions" (--enable-checking=XXX) group.gfortranassert.compilers=gfortran103assert:gfortran104assert:gfortran105assert:gfortran111assert:gfortran112assert:gfortran113assert:gfortran114assert:gfortran121assert:gfortran122assert:gfortran123assert:gfortran124assert:gfortran131assert:gfortran132assert:gfortran133assert:gfortran134assert:gfortran141assert:gfortran142assert:gfortran143assert:gfortran151assert group.gfortranassert.groupName=GFORTRAN x86-64 (assertions) +group.gfortranassert.compilerCategories=gfortran compiler.gfortran103assert.exe=/opt/compiler-explorer/gcc-assertions-10.3.0/bin/gfortran compiler.gfortran103assert.semver=10.3 (assertions) @@ -142,6 +144,7 @@ group.ifort.intelAsm=-masm=intel group.ifort.groupName=IFORT x86-64 group.ifort.isSemVer=true group.ifort.baseName=x86-64 ifort +group.ifort.compilerCategories=ifort #compiler.ifort16.exe=/opt/compiler-explorer/intel/xe_2016_update3/bin/ifort #compiler.ifort16.semver=16.0.3 #compiler.ifort17.exe=/opt/compiler-explorer/intel/2017/bin/ifort @@ -232,6 +235,7 @@ group.ifx.groupName=IFX x86-64 group.ifx.isSemVer=true group.ifx.baseName=x86-64 ifx group.ifx.options= +group.ifx.compilerCategories=ifort compiler.ifx202112.exe=/opt/compiler-explorer/intel-fortran-2021.1.2.62/compiler/latest/linux/bin/ifx compiler.ifx202112.ldPath=/opt/compiler-explorer/intel-fortran-2021.1.2.62/compiler/latest/linux/compiler/lib/intel64_lin @@ -357,6 +361,7 @@ group.cross.supportsExecute=false group.cross.supportsBinary=false group.cross.supportsBinaryObject=true group.cross.groupName=Cross GCC +group.cross.compilerCategories=gfortran ############################### # GCC for Tricore @@ -364,6 +369,7 @@ group.gcctricore.compilers=ftricoreg1130 group.gcctricore.groupName=Tricore gfortran group.gcctricore.baseName=Tricore gfortran group.gcctricore.supportsBinary=true +group.gcctricore.compilerCategories=gfortran compiler.ftricoreg1130.exe=/opt/compiler-explorer/tricore/gcc-11.3.0/tricore-none-elf/bin/tricore-none-elf-gfortran compiler.ftricoreg1130.semver=11.3.0 (EEESlab) @@ -376,6 +382,7 @@ group.gcchppa.compilers=fhppag1420:fhppag1430:fhppag1510 group.gcchppa.groupName=HPPA gfortran group.gcchppa.baseName=HPPA gfortran group.gcchppa.supportsBinary=true +group.gcchppa.compilerCategories=gfortran compiler.fhppag1420.exe=/opt/compiler-explorer/hppa/gcc-14.2.0/hppa-unknown-linux-gnu/bin/hppa-unknown-linux-gnu-gfortran compiler.fhppag1420.semver=14.2.0 @@ -397,6 +404,7 @@ compiler.fhppag1510.demangler=/opt/compiler-explorer/hppa/gcc-15.1.0/hppa-unknow group.gccsparc.compilers=fsparcg1220:fsparcg1230:fsparcg1240:fsparcg1310:fsparcg1320:fsparcg1330:fsparcg1340:fsparcg1410:fsparcg1420:fsparcg1430:fsparcg1510 group.gccsparc.groupName=SPARC gfortran group.gccsparc.baseName=SPARC gfortran +group.gccsparc.compilerCategories=gfortran compiler.fsparcg1220.exe=/opt/compiler-explorer/sparc/gcc-12.2.0/sparc-unknown-linux-gnu/bin/sparc-unknown-linux-gnu-gfortran compiler.fsparcg1220.semver=12.2.0 @@ -458,6 +466,7 @@ compiler.fsparcg1510.demangler=/opt/compiler-explorer/sparc/gcc-15.1.0/sparc-unk group.gccsparc64.compilers=fsparc64g1220:fsparc64g1230:fsparc64g1310:fsparc64g1320:fsparc64g1410:fsparc64g1330:fsparc64g1240:fsparc64g1420:fsparc64g1510:fsparc64g1430:fsparc64g1340 group.gccsparc64.groupName=SPARC64 gfortran group.gccsparc64.baseName=SPARC64 gfortran +group.gccsparc64.compilerCategories=gfortran compiler.fsparc64g1220.exe=/opt/compiler-explorer/sparc64/gcc-12.2.0/sparc64-multilib-linux-gnu/bin/sparc64-multilib-linux-gnu-gfortran compiler.fsparc64g1220.semver=12.2.0 @@ -519,6 +528,7 @@ compiler.fsparc64g1510.demangler=/opt/compiler-explorer/sparc64/gcc-15.1.0/sparc group.gccsparcleon.compilers=fsparcleong1220:fsparcleong1220-1:fsparcleong1230:fsparcleong1240:fsparcleong1310:fsparcleong1320:fsparcleong1330:fsparcleong1340:fsparcleong1410:fsparcleong1420:fsparcleong1430:fsparcleong1510 group.gccsparcleon.groupName=SPARC LEON gfortran group.gccsparcleon.baseName=SPARC LEON gfortran +group.gccsparcleon.compilerCategories=gfortran # this one was wrongly built using 'master', not 12.2.0 release. compiler.fsparcleong1220.exe=/opt/compiler-explorer/sparc-leon/gcc-12.2.0/sparc-leon-linux-uclibc/bin/sparc-leon-linux-uclibc-gfortran @@ -587,6 +597,7 @@ compiler.fsparcleong1510.demangler=/opt/compiler-explorer/sparc-leon/gcc-15.1.0/ group.gccloongarch64.compilers=floongarch64g1220:floongarch64g1230:floongarch64g1310:floongarch64g1320:floongarch64g1410:floongarch64g1330:floongarch64g1240:floongarch64g1420:floongarch64g1510:floongarch64g1430:floongarch64g1340 group.gccloongarch64.groupName=LOONGARCH64 gfortran group.gccloongarch64.baseName=LOONGARCH64 gfortran +group.gccloongarch64.compilerCategories=gfortran compiler.floongarch64g1220.exe=/opt/compiler-explorer/loongarch64/gcc-12.2.0/loongarch64-unknown-linux-gnu/bin/loongarch64-unknown-linux-gnu-gfortran compiler.floongarch64g1220.semver=12.2.0 @@ -648,6 +659,7 @@ compiler.floongarch64g1510.demangler=/opt/compiler-explorer/loongarch64/gcc-15.1 group.gccriscv64.compilers=friscv64g1140:friscv64g1220:friscv64g1230:friscv64g1310:friscv64g1320:friscv64g1410:friscv64g1330:friscv64g1240:friscv64g1420:friscv64g1510:friscv64g1430:friscv64g1340 group.gccriscv64.groupName=RISCV64 gfortran group.gccriscv64.baseName=RISCV64 gfortran +group.gccriscv64.compilerCategories=gfortran compiler.friscv64g1140.exe=/opt/compiler-explorer/riscv64/gcc-11.4.0/riscv64-unknown-linux-gnu/bin/riscv64-unknown-linux-gnu-gfortran compiler.friscv64g1140.semver=11.4.0 @@ -714,6 +726,7 @@ compiler.friscv64g1510.demangler=/opt/compiler-explorer/riscv64/gcc-15.1.0/riscv group.gccriscv.compilers=friscvg1140:friscvg1220:friscvg1230:friscvg1240:friscvg1310:friscvg1320:friscvg1330:friscvg1340:friscvg1410:friscvg1420:friscvg1430:friscvg1510 group.gccriscv.groupName=RISCV (32bit) gfortran group.gccriscv.baseName=RISCV (32bit) gfortran +group.gccriscv.compilerCategories=gfortran compiler.friscvg1140.exe=/opt/compiler-explorer/riscv32/gcc-11.4.0/riscv32-unknown-elf/bin/riscv32-unknown-elf-gfortran compiler.friscvg1140.semver=11.4.0 @@ -780,6 +793,7 @@ compiler.friscvg1510.demangler=/opt/compiler-explorer/riscv32/gcc-15.1.0/riscv32 group.gccarm.compilers=farmg640:farmg730:farmg820:farmg1050:farmg1140:farmg1210:farmg1220:farmg1230:farmg1240:farmg1310:farmg1320:farmg1330:farmg1340:farmg1410:farmg1420:farmg1430:farmg1510 group.gccarm.groupName=ARM (32bit) gfortran group.gccarm.baseName=ARM (32bit) gfortran +group.gccarm.compilerCategories=gfortran compiler.farmg640.exe=/opt/compiler-explorer/arm/gcc-6.4.0/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gfortran compiler.farmg640.semver=6.4 @@ -863,6 +877,7 @@ compiler.farmg1510.demangler=/opt/compiler-explorer/arm/gcc-15.1.0/arm-unknown-l group.gccs390x.compilers=fs390xg1210:fs390xg1220:fs390xg1230:fs390xg1310:fs390xg1320:fs390xg1410:fs390xg1330:fs390xg1240:fs390xg1420:fs390xg1510:fs390xg1430:fs390xg1340 group.gccs390x.groupName=s390x gfortran group.gccs390x.baseName=s390x gfortran +group.gccs390x.compilerCategories=gfortran compiler.fs390xg1210.exe=/opt/compiler-explorer/s390x/gcc-12.1.0/s390x-ibm-linux-gnu/bin/s390x-ibm-linux-gnu-gfortran compiler.fs390xg1210.semver=12.1.0 @@ -928,6 +943,7 @@ compiler.fs390xg1510.demangler=/opt/compiler-explorer/s390x/gcc-15.1.0/s390x-ibm group.clang_llvmflang.compilers=flangtrunk:flangtrunk-fc group.clang_llvmflang.groupName=LLVM-FLANG x86-64 group.clang_llvmflang.compilerType=flang +group.clang_llvmflang.compilerCategories=flang compiler.flangtrunk.exe=/opt/compiler-explorer/clang-llvmflang-trunk/bin/flang compiler.flangtrunk.name=flang-trunk @@ -946,7 +962,7 @@ compiler.flangtrunk-fc.alias=flangtrunknew-fc ################################# # LFortran -group.lfortran.compilers=lfortran0420 +group.lfortran.compilers=lfortran0420:lfortran0430:lfortran0440:lfortran0450:lfortran0460:lfortran0470:lfortran0480:lfortran0490:lfortran0500:lfortran0510:lfortran0520 group.lfortran.groupName=LFortran group.lfortran.baseName=LFortran group.lfortran.supportsBinary=true @@ -954,15 +970,47 @@ group.lfortran.supportsBinaryObject=true group.lfortran.supportsExecute=true group.lfortran.compilerType=lfortran group.lfortran.isSemVer=true +group.lfortran.compilerCategories=lfortran compiler.lfortran0420.exe=/opt/compiler-explorer/lfortran/v0.42.0/bin/lfortran compiler.lfortran0420.semver=0.42.0 compiler.lfortran0420.clang=/opt/compiler-explorer/clang-19.1.0/bin/clang +compiler.lfortran0430.exe=/opt/compiler-explorer/lfortran/v0.43.0/bin/lfortran +compiler.lfortran0430.semver=0.43.0 +compiler.lfortran0430.clang=/opt/compiler-explorer/clang-19.1.0/bin/clang +compiler.lfortran0440.exe=/opt/compiler-explorer/lfortran/v0.44.0/bin/lfortran +compiler.lfortran0440.semver=0.44.0 +compiler.lfortran0440.clang=/opt/compiler-explorer/clang-19.1.0/bin/clang +compiler.lfortran0450.exe=/opt/compiler-explorer/lfortran/v0.45.0/bin/lfortran +compiler.lfortran0450.semver=0.45.0 +compiler.lfortran0450.clang=/opt/compiler-explorer/clang-19.1.0/bin/clang +compiler.lfortran0460.exe=/opt/compiler-explorer/lfortran/v0.46.0/bin/lfortran +compiler.lfortran0460.semver=0.46.0 +compiler.lfortran0460.clang=/opt/compiler-explorer/clang-19.1.0/bin/clang +compiler.lfortran0470.exe=/opt/compiler-explorer/lfortran/v0.47.0/bin/lfortran +compiler.lfortran0470.semver=0.47.0 +compiler.lfortran0470.clang=/opt/compiler-explorer/clang-19.1.0/bin/clang +compiler.lfortran0480.exe=/opt/compiler-explorer/lfortran/v0.48.0/bin/lfortran +compiler.lfortran0480.semver=0.48.0 +compiler.lfortran0480.clang=/opt/compiler-explorer/clang-19.1.0/bin/clang +compiler.lfortran0490.exe=/opt/compiler-explorer/lfortran/v0.49.0/bin/lfortran +compiler.lfortran0490.semver=0.49.0 +compiler.lfortran0490.clang=/opt/compiler-explorer/clang-19.1.0/bin/clang +compiler.lfortran0500.exe=/opt/compiler-explorer/lfortran/v0.50.0/bin/lfortran +compiler.lfortran0500.semver=0.50.0 +compiler.lfortran0500.clang=/opt/compiler-explorer/clang-19.1.0/bin/clang +compiler.lfortran0510.exe=/opt/compiler-explorer/lfortran/v0.51.0/bin/lfortran +compiler.lfortran0510.semver=0.51.0 +compiler.lfortran0510.clang=/opt/compiler-explorer/clang-19.1.0/bin/clang +compiler.lfortran0520.exe=/opt/compiler-explorer/lfortran/v0.52.0/bin/lfortran +compiler.lfortran0520.semver=0.52.0 +compiler.lfortran0520.clang=/opt/compiler-explorer/clang-19.1.0/bin/clang ############################### # GCC for ARM 64bit group.gccaarch64.compilers=farm64g494:farm64g550:farm64g640:farm64g730:farm64g820:farm64g1050:farm64g1210:farm64g1220:farm64g1230:farm64g1310:farm64g1140:farm64g1320:farm64g1410:farm64g1330:farm64g1240:farm64g1420:farm64g1510:farm64g1430:farm64g1340 group.gccaarch64.groupName=ARM (AARCH64) GCC group.gccaarch64.baseName=AARCH64 gfortran +group.gccaarch64.compilerCategories=gfortran compiler.farm64g494.exe=/opt/compiler-explorer/arm64/gcc-4.9.4/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-gfortran compiler.farm64g494.semver=4.9.4 @@ -1056,12 +1104,14 @@ compiler.farm64g1510.demangler=/opt/compiler-explorer/arm64/gcc-15.1.0/aarch64-u group.ppcs.compilers=&ppc64:&ppc64le:&ppc group.ppcs.groupName=POWER Compilers group.ppcs.instructionSet=powerpc +group.ppcs.compilerCategories=gfortran ############################### # GCC for PPC group.ppc.compilers=fppcg1210:fppcg1220:fppcg1230:fppcg1240:fppcg1310:fppcg1320:fppcg1330:fppcg1340:fppcg1410:fppcg1420:fppcg1430:fppcg1510 group.ppc.groupName=POWER gfortran group.ppc.baseName=POWER gfortran +group.ppc.compilerCategories=gfortran compiler.fppcg1210.exe=/opt/compiler-explorer/powerpc/gcc-12.1.0/powerpc-unknown-linux-gnu/bin/powerpc-unknown-linux-gnu-gfortran compiler.fppcg1210.semver=12.1.0 @@ -1127,6 +1177,7 @@ compiler.fppcg1510.demangler=/opt/compiler-explorer/powerpc/gcc-15.1.0/powerpc-u group.ppc64.compilers=fppc64g8:fppc64g9:fppc64g1210:fppc64g1220:fppc64g1230:fppc64g1310:fppc64g1320:fppc64gtrunk:fppc64g1410:fppc64g1330:fppc64g1240:fppc64g1420:fppc64g1510:fppc64g1430:fppc64g1340 group.ppc64.groupName=POWER64 gfortran group.ppc64.baseName=POWER64 gfortran +group.ppc64.compilerCategories=gfortran compiler.fppc64g8.exe=/opt/compiler-explorer/powerpc64/gcc-at12/powerpc64-unknown-linux-gnu/bin/powerpc64-unknown-linux-gnu-gfortran compiler.fppc64g8.name=power64 AT12.0 @@ -1205,6 +1256,7 @@ compiler.fppc64gtrunk.demangler=/opt/compiler-explorer/powerpc64/gcc-trunk/power group.ppc64le.compilers=fppc64leg8:fppc64leg9:fppc64leg1210:fppc64leg1220:fppc64leg1230:fppc64leg1310:fppc64leg1320:fppc64legtrunk:fppc64leg1410:fppc64leg1330:fppc64leg1240:fppc64leg1420:fppc64leg1510:fppc64leg1430:fppc64leg1340 group.ppc64le.groupName=POWER64le gfortran group.ppc64le.baseName=POWER64le gfortran +group.ppc64le.compilerCategories=gfortran compiler.fppc64leg8.exe=/opt/compiler-explorer/powerpc64le/gcc-at12/powerpc64le-unknown-linux-gnu/bin/powerpc64le-unknown-linux-gnu-gfortran compiler.fppc64leg8.name=power64le AT12.0 @@ -1282,12 +1334,14 @@ compiler.fppc64legtrunk.demangler=/opt/compiler-explorer/powerpc64le/gcc-trunk/p ## GCC For RISC-V 32 and 64 group.gccrvs.compilers=&gccrv64:&gccrv32 +group.gccrvs.compilerCategories=gfortran ################################ # GCC for RISC-V 32-bits group.gccrv32.compilers=frv32gtrunk:frv32g1210 group.gccrv32.groupName=RISC-V 32-bits gfortran group.gccrv32.baseName=RISC-V 32-bits gfortran +group.gccrv32.compilerCategories=gfortran compiler.frv32g1210.exe=/opt/compiler-explorer/riscv32/gcc-12.1.0/riscv32-unknown-elf/bin/riscv32-unknown-elf-gfortran compiler.frv32g1210.semver=12.1.0 @@ -1302,6 +1356,7 @@ compiler.frv32gtrunk.objdumper=/opt/compiler-explorer/riscv32/gcc-trunk/riscv32- group.gccrv64.compilers=frv64gtrunk:frv64g1210 group.gccrv64.groupName=RISC-V 64-bits gfortran group.gccrv64.baseName=RISC-V 64-bits gfortran +group.gccrv64.compilerCategories=gfortran compiler.frv64g1210.exe=/opt/compiler-explorer/riscv64/gcc-12.1.0/riscv64-unknown-linux-gnu/bin/riscv64-unknown-linux-gnu-gfortran compiler.frv64g1210.semver=12.1.0 @@ -1317,6 +1372,7 @@ compiler.frv64gtrunk.objdumper=/opt/compiler-explorer/riscv64/gcc-trunk/riscv64- group.gccmips.compilers=fmipsg494:fmipsg550:fmipsg950:fmipsg1210:fmipsg1220:fmipsg1230:fmipsg1240:fmipsg1310:fmipsg1320:fmipsg1330:fmipsg1340:fmipsg1410:fmipsg1420:fmipsg1430:fmipsg1510 group.gccmips.groupName=MIPS gfortran group.gccmips.baseName=MIPS gfortran +group.gccmips.compilerCategories=gfortran compiler.fmipsg494.exe=/opt/compiler-explorer/mips/gcc-4.9.4/mips-unknown-linux-gnu/bin/mips-unknown-linux-gnu-gfortran compiler.fmipsg494.semver=4.9.4 @@ -1397,6 +1453,7 @@ compiler.fmipsg1510.demangler=/opt/compiler-explorer/mips/gcc-15.1.0/mips-unknow group.gccmips64.compilers=fmips64g494:fmips64g550:fmips64g950:fmips64g1210:fmips64g1220:fmips64g1230:fmips64g1310:fmips64g1320:fmips64g1410:fmips64g1330:fmips64g1240:fmips64g1420:fmips64g1510:fmips64g1430:fmips64g1340 group.gccmips64.groupName=MIPS64 gfortran group.gccmips64.baseName=MIPS64 gfortran +group.gccmips64.compilerCategories=gfortran compiler.fmips64g494.exe=/opt/compiler-explorer/mips64/gcc-4.9.4/mips64-unknown-linux-gnu/bin/mips64-unknown-linux-gnu-gfortran compiler.fmips64g494.semver=4.9.4 @@ -1477,6 +1534,7 @@ compiler.fmips64g1510.demangler=/opt/compiler-explorer/mips64/gcc-15.1.0/mips64- group.gccmipsel.compilers=fmipselg494:fmipselg550:fmipselg950:fmipselg1210:fmipselg1220:fmipselg1230:fmipselg1240:fmipselg1310:fmipselg1320:fmipselg1330:fmipselg1340:fmipselg1410:fmipselg1420:fmipselg1430:fmipselg1510 group.gccmipsel.groupName=MIPSel gfortran group.gccmipsel.baseName=MIPSel gfortran +group.gccmipsel.compilerCategories=gfortran compiler.fmipselg494.exe=/opt/compiler-explorer/mipsel/gcc-4.9.4/mipsel-unknown-linux-gnu/bin/mipsel-unknown-linux-gnu-gfortran compiler.fmipselg494.semver=4.9.4 @@ -1557,6 +1615,7 @@ compiler.fmipselg1510.demangler=/opt/compiler-explorer/mipsel/gcc-15.1.0/mipsel- group.gccmips64el.compilers=fmips64elg494:fmips64elg550:fmips64elg950:fmips64elg1210:fmips64elg1220:fmips64elg1230:fmips64elg1310:fmips64elg1320:fmips64elg1410:fmips64elg1330:fmips64elg1240:fmips64elg1420:fmips64elg1510:fmips64elg1430:fmips64elg1340 group.gccmips64el.groupName=MIPS64el gfortran group.gccmips64el.baseName=MIPS64el gfortran +group.gccmips64el.compilerCategories=gfortran compiler.fmips64elg494.exe=/opt/compiler-explorer/mips64el/gcc-4.9.4/mips64el-unknown-linux-gnu/bin/mips64el-unknown-linux-gnu-gfortran compiler.fmips64elg494.semver=4.9.4 diff --git a/etc/config/fortran.defaults.properties b/etc/config/fortran.defaults.properties index 7fe7920c5..1ef99c81f 100644 --- a/etc/config/fortran.defaults.properties +++ b/etc/config/fortran.defaults.properties @@ -9,6 +9,7 @@ compilerType=fortran # GCC for x86 group.gfortran_86.compilers=gfortran412:gfortran447:gfortran453:gfortran464:gfortran471:gfortran472:gfortran473:gfortran474:gfortran481:gfortran482:gfortran483:gfortran484:gfortran485:gfortran490:gfortran491:gfortran492:gfortran493:gfortran494def:gfortran48:gfortran4:gfortran510:gfortran520:gfortran530:gfortran540:gfortran550def:gfortran5:gfortran62:gfortran63def:gfortran6:gfortran71def:gfortran72def:gfortran73def:gfortran7:gfortran8:gfortran81def:gfortran9:gfortran10:gfortran11:gfortran group.gfortran_86.groupName=GCC x86-64 +group.gfortran_86.compilerCategories=gfortran compiler.gfortran412.exe=/usr/bin/gfortran-4.1.2 compiler.gfortran412.name=gfortran 4.1.2 compiler.gfortran447.exe=/usr/bin/gfortran-4.4.7 @@ -100,6 +101,7 @@ compiler.gfortran.name=gfortran group.clang_llvmflang.compilers=flangtrunk group.clang_llvmflang.groupName=LLVM-FLANG group.clang_llvmflang.compilerType=flang +group.clang_llvmflang.compilerCategories=flang compiler.flangtrunk.exe=/usr/local/bin/flang compiler.flangtrunk.name=flang-trunk diff --git a/etc/config/raku.amazon.properties b/etc/config/raku.amazon.properties new file mode 100644 index 000000000..fdbe1a3de --- /dev/null +++ b/etc/config/raku.amazon.properties @@ -0,0 +1,117 @@ +compilers=&rakudo-moar +defaultCompiler=rakudo-moar-2025-05-01 +compilerType=raku + +group.rakudo-moar.compilers=rakudo-moar-2025-05-01:rakudo-moar-2025-04-01:rakudo-moar-2025-03-01:rakudo-moar-2025-02-01:rakudo-moar-2025-01-01:rakudo-moar-2024-12-01:rakudo-moar-2024-10-01:rakudo-moar-2024-09-01:rakudo-moar-2024-08-01:rakudo-moar-2024-07-01:rakudo-moar-2024-06-01:rakudo-moar-2024-05-01:rakudo-moar-2024-04-01:rakudo-moar-2024-03-01:rakudo-moar-2024-02-01:rakudo-moar-2024-01-01:rakudo-moar-2023-12-01:rakudo-moar-2023-11-01:rakudo-moar-2023-10-01:rakudo-moar-2023-10-02:rakudo-moar-2023-09-01:rakudo-moar-2023-08-01:rakudo-moar-2023-06-01:rakudo-moar-2023-04-01:rakudo-moar-2023-02-01:rakudo-moar-2022-12-01:rakudo-moar-2022-07-01:rakudo-moar-2022-06-01:rakudo-moar-2022-04-01:rakudo-moar-2022-03-01:rakudo-moar-2022-02-01:rakudo-moar-2021-12-01:rakudo-moar-2021-10-01:rakudo-moar-2021-09-01:rakudo-moar-2021-08-01:rakudo-moar-2021-07-01:rakudo-moar-2021-06-01:rakudo-moar-2021-05-01:rakudo-moar-2021-04-01:rakudo-moar-2021-03-01:rakudo-moar-2021-02-1-01:rakudo-moar-2021-02-01:rakudo-moar-2020-12-01:rakudo-moar-2020-11-01 +group.rakudo-moar.isSemVer=false +group.rakudo-moar.baseName=Rakudo MoarVM + +interpreted=true +supportsBinary=false +supportsBinaryObject=true +versionFlag=--version +versionRe=v(([0-9a-zA-Z]+))([.-]([0-9a-zA-Z]+))+ +objdumper= +demangler= +postProcess= +options= +supportsExecute=true +stubText=sub square($number) { $number * $number } +disasmScript= + +## All exes in one big block, names are further towards the bottom. +compiler.rakudo-moar-2025-05-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2025.05-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2025-04-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2025.04-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2025-03-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2025.03-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2025-02-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2025.02-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2025-01-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2025.01-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2024-12-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2024.12-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2024-10-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2024.10-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2024-09-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2024.09-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2024-08-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2024.08-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2024-07-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2024.07-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2024-06-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2024.06-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2024-05-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2024.05-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2024-04-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2024.04-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2024-03-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2024.03-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2024-02-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2024.02-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2024-01-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2024.01-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2023-12-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2023.12-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2023-11-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2023.11-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2023-10-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2023.10-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2023-10-02.exe=/opt/compiler-explorer/raku/rakudo-moar-2023.10-02-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2023-09-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2023.09-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2023-08-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2023.08-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2023-06-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2023.06-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2023-04-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2023.04-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2023-02-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2023.02-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2022-12-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2022.12-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2022-07-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2022.07-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2022-06-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2022.06-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2022-04-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2022.04-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2022-03-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2022.03-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2022-02-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2022.02-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2021-12-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2021.12-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2021-10-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2021.10-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2021-09-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2021.09-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2021-08-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2021.08-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2021-07-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2021.07-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2021-06-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2021.06-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2021-05-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2021.05-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2021-04-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2021.04-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2021-03-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2021.03-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2021-02-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2021.02-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2020-12-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2020.12-01-linux-x86_64-gcc/bin/rakudo +compiler.rakudo-moar-2020-11-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2020.11-01-linux-x86_64-gcc/bin/rakudo + +# The one release that doesn't have the same length. +compiler.rakudo-moar-2021-02-1-01.exe=/opt/compiler-explorer/raku/rakudo-moar-2021.02.1-01-linux-x86_64-gcc/bin/rakudo + + +# Names for all the compilers + +compiler.rakudo-moar-2025-05-01.name=Rakudo 2025.05 MoarVM +compiler.rakudo-moar-2025-04-01.name=Rakudo 2025.04 MoarVM +compiler.rakudo-moar-2025-03-01.name=Rakudo 2025.03 MoarVM +compiler.rakudo-moar-2025-02-01.name=Rakudo 2025.02 MoarVM +compiler.rakudo-moar-2025-01-01.name=Rakudo 2025.01 MoarVM +compiler.rakudo-moar-2024-12-01.name=Rakudo 2024.12 MoarVM +compiler.rakudo-moar-2024-10-01.name=Rakudo 2024.10 MoarVM +compiler.rakudo-moar-2024-09-01.name=Rakudo 2024.09 MoarVM +compiler.rakudo-moar-2024-08-01.name=Rakudo 2024.08 MoarVM +compiler.rakudo-moar-2024-07-01.name=Rakudo 2024.07 MoarVM +compiler.rakudo-moar-2024-06-01.name=Rakudo 2024.06 MoarVM +compiler.rakudo-moar-2024-05-01.name=Rakudo 2024.05 MoarVM +compiler.rakudo-moar-2024-04-01.name=Rakudo 2024.04 MoarVM +compiler.rakudo-moar-2024-03-01.name=Rakudo 2024.03 MoarVM +compiler.rakudo-moar-2024-02-01.name=Rakudo 2024.02 MoarVM +compiler.rakudo-moar-2024-01-01.name=Rakudo 2024.01 MoarVM +compiler.rakudo-moar-2023-12-01.name=Rakudo 2023.12 MoarVM +compiler.rakudo-moar-2023-11-01.name=Rakudo 2023.11 MoarVM +compiler.rakudo-moar-2023-10-01.name=Rakudo 2023.10 MoarVM +compiler.rakudo-moar-2023-10-02.name=Rakudo 2023.10-02 MoarVM +compiler.rakudo-moar-2023-09-01.name=Rakudo 2023.09 MoarVM +compiler.rakudo-moar-2023-08-01.name=Rakudo 2023.08 MoarVM +compiler.rakudo-moar-2023-06-01.name=Rakudo 2023.06 MoarVM +compiler.rakudo-moar-2023-04-01.name=Rakudo 2023.04 MoarVM +compiler.rakudo-moar-2023-02-01.name=Rakudo 2023.02 MoarVM +compiler.rakudo-moar-2022-12-01.name=Rakudo 2022.12 MoarVM +compiler.rakudo-moar-2022-07-01.name=Rakudo 2022.07 MoarVM +compiler.rakudo-moar-2022-06-01.name=Rakudo 2022.06 MoarVM +compiler.rakudo-moar-2022-04-01.name=Rakudo 2022.04 MoarVM +compiler.rakudo-moar-2022-03-01.name=Rakudo 2022.03 MoarVM +compiler.rakudo-moar-2022-02-01.name=Rakudo 2022.02 MoarVM +compiler.rakudo-moar-2021-12-01.name=Rakudo 2021.12 MoarVM +compiler.rakudo-moar-2021-10-01.name=Rakudo 2021.10 MoarVM +compiler.rakudo-moar-2021-09-01.name=Rakudo 2021.09 MoarVM +compiler.rakudo-moar-2021-08-01.name=Rakudo 2021.08 MoarVM +compiler.rakudo-moar-2021-07-01.name=Rakudo 2021.07 MoarVM +compiler.rakudo-moar-2021-06-01.name=Rakudo 2021.06 MoarVM +compiler.rakudo-moar-2021-05-01.name=Rakudo 2021.05 MoarVM +compiler.rakudo-moar-2021-04-01.name=Rakudo 2021.04 MoarVM +compiler.rakudo-moar-2021-03-01.name=Rakudo 2021.03 MoarVM +compiler.rakudo-moar-2021-02-01.name=Rakudo 2021.02 MoarVM +compiler.rakudo-moar-2020-12-01.name=Rakudo 2020.12 MoarVM +compiler.rakudo-moar-2020-11-01.name=Rakudo 2020.11 MoarVM + +compiler.rakudo-moar-2021-02-1-01.name=Rakudo 2021.02.1 MoarVM diff --git a/etc/config/rust.amazon.properties b/etc/config/rust.amazon.properties index 02bd4fdcf..a8365335a 100644 --- a/etc/config/rust.amazon.properties +++ b/etc/config/rust.amazon.properties @@ -3,8 +3,7 @@ objdumper=/opt/compiler-explorer/gcc-14.1.0/bin/objdump linker=/opt/compiler-explorer/gcc-14.1.0/bin/gcc aarch64linker=/opt/compiler-explorer/arm64/gcc-14.1.0/aarch64-unknown-linux-gnu/bin/aarch64-unknown-linux-gnu-gcc defaultCompiler=r1870 -demangler=/opt/compiler-explorer/gcc-14.1.0/bin/c++filt -demanglerArgs=--format=rust +demangler=/opt/compiler-explorer/demanglers/rust/bin/rustfilt buildenvsetup=ceconan-rust buildenvsetup.host=https://conan.compiler-explorer.com diff --git a/etc/scripts/disasms/moarvm_disasm.raku b/etc/scripts/disasms/moarvm_disasm.raku new file mode 100644 index 000000000..5dbf1d06d --- /dev/null +++ b/etc/scripts/disasms/moarvm_disasm.raku @@ -0,0 +1,36 @@ +sub tempname { + my $lastex; + for ^1000 { + my $name = $*TMPDIR.child("rakudo_disassembly_" ~ (|("a".."z"),|("A".."Z"),|("0".."9")).roll(8).join("") ~ ".moarvm"); + try { + $name.IO.open(:create, :exclusive).close(); + CATCH { default { $lastex = $!; next } } + } + return $name; + } + die "Could not come up with a free temp name file? $lastex.Str()"; +} + +sub MAIN($rakudoexe, $outputfile, *@extra_args) { + my $code = @extra_args.pop; + + # If the user passes --target, we don't want to run the output through + # the moar --dump program. + if @extra_args && @extra_args.any.starts-with("--target=") { + my $output = qqx/ $rakudoexe @extra_args[0] $code /; + $outputfile.IO.spurt($output); + return; + } + + # Store the moar bytecode result + my $tempfile = tempname; + my $moarexe = $rakudoexe.IO.sibling("moar"); + + qqx/ $rakudoexe --target=mbc --output=$tempfile $code /; + + my $output = qqx[ $moarexe --dump $tempfile ]; + + $outputfile.IO.spurt($output); + + LEAVE { .IO.unlink with $tempfile } +} diff --git a/examples/raku/default.raku b/examples/raku/default.raku new file mode 100644 index 000000000..a95840476 --- /dev/null +++ b/examples/raku/default.raku @@ -0,0 +1,15 @@ + +sub square($number) { + $number * $number +} + +multi sub MAIN(Int $foo) { + say "When no one was looking, Lex Luthor took $foo cakes."; + say "The square of that is &square($foo) cakes."; + say "It's also roughly as much as $($foo div 10) tens."; + say "And that's terrible."; +} + +multi sub MAIN() { + say "You can pass a number on the commandline if you like!" +} diff --git a/lib/compilers/_all.ts b/lib/compilers/_all.ts index 2ccf7c4bb..47e732caa 100644 --- a/lib/compilers/_all.ts +++ b/lib/compilers/_all.ts @@ -129,6 +129,7 @@ export {QNXCompiler} from './qnx.js'; export {R8Compiler} from './r8.js'; export {RGACompiler} from './rga.js'; export {RacketCompiler} from './racket.js'; +export {RakuCompiler} from './raku.js'; export {RubyCompiler} from './ruby.js'; export {RustCompiler} from './rust.js'; export {RustcCgGCCCompiler} from './rustc-cg-gcc.js'; diff --git a/lib/compilers/c3c.ts b/lib/compilers/c3c.ts index f94575cfe..c342f66a9 100644 --- a/lib/compilers/c3c.ts +++ b/lib/compilers/c3c.ts @@ -1,9 +1,11 @@ import path from 'node:path'; +import Semver from 'semver'; import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js'; import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js'; import {BaseCompiler} from '../base-compiler.js'; import {CompilationEnvironment} from '../compilation-env.js'; +import {asSafeVer} from '../utils.js'; export class C3Compiler extends BaseCompiler { static get key() { @@ -17,7 +19,11 @@ export class C3Compiler extends BaseCompiler { } override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string) { - return ['compile-only', '-g', '-l', 'pthread', '--no-obj', '--emit-asm']; + const options = ['compile-only', '-g', '-l', 'pthread', '--no-obj', '--emit-asm']; + if (Semver.gte(asSafeVer(this.compiler.semver), '0.6.8', true)) { + options.push('--llvm-out', '.', '--asm-out', '.'); + } + return options; } override getIrOutputFilename(inputFilename: string): string { diff --git a/lib/compilers/raku.ts b/lib/compilers/raku.ts new file mode 100644 index 000000000..d4ccc8a03 --- /dev/null +++ b/lib/compilers/raku.ts @@ -0,0 +1,85 @@ +// Copyright (c) 2025, Compiler Explorer Authors +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +import type {AsmResultSource, ParsedAsmResultLine} from '../../types/asmresult/asmresult.interfaces.js'; +import type {PreliminaryCompilerInfo} from '../../types/compiler.interfaces.js'; +import type {ParseFiltersAndOutputOptions} from '../../types/features/filters.interfaces.js'; +import {BaseCompiler} from '../base-compiler.js'; +import {CompilationEnvironment} from '../compilation-env.js'; +import {resolvePathFromAppRoot} from '../utils.js'; + +export class RakuCompiler extends BaseCompiler { + private readonly disasmScriptPath: string; + private readonly exepath: string; + + constructor(compilerInfo: PreliminaryCompilerInfo, env: CompilationEnvironment) { + super(compilerInfo, env); + this.compiler.demangler = ''; + this.demanglerClass = null; + this.disasmScriptPath = resolvePathFromAppRoot('etc', 'scripts', 'disasms', 'moarvm_disasm.raku'); + this.exepath = this.compiler.exe; + } + + static get key() { + return 'raku'; + } + + override optionsForFilter(filters: ParseFiltersAndOutputOptions, outputFilename: string) { + return [this.disasmScriptPath, this.exepath, outputFilename]; + } + + override async processAsm(result, filters: ParseFiltersAndOutputOptions, options: string[]) { + const lineRe = /^ {5}annotation: ([^:]*):(\d+)$/; + const frameHeadRe = /^ {2}Frame_(\d+) :$/; + + const bytecodeLines = result.asm.split('\n'); + + const bytecodeResult: ParsedAsmResultLine[] = []; + let lastLineNo: number | null = null; + let sourceLoc: AsmResultSource | null = null; + + for (const line of bytecodeLines) { + const matchLine = line.match(lineRe); + const matchFrame = line.match(frameHeadRe); + + if (matchFrame) { + lastLineNo = null; + sourceLoc = {line: null, file: null}; + } else if (matchLine) { + const lineno = Number.parseInt(matchLine[2]); + sourceLoc = {line: lineno, file: null}; + lastLineNo = lineno; + } else if (line) { + sourceLoc = {line: lastLineNo, file: null}; + } else { + sourceLoc = {line: null, file: null}; + lastLineNo = null; + } + + bytecodeResult.push({text: line, source: sourceLoc}); + } + + return {asm: bytecodeResult}; + } +} diff --git a/lib/handlers/route-api.ts b/lib/handlers/route-api.ts index a9058a972..92653dbb6 100644 --- a/lib/handlers/route-api.ts +++ b/lib/handlers/route-api.ts @@ -151,12 +151,24 @@ export class RouteAPI { return goldenifier.golden; } - unstoredStateHandler(req: express.Request, res: express.Response) { - const state = extractJsonFromBufferAndInflateIfRequired(Buffer.from(req.params.clientstatebase64, 'base64')); - const config = this.getGoldenLayoutFromClientState(new ClientState(state)); - const metadata = this.getMetaDataFromLink(req, null, config); + unstoredStateHandler(req: express.Request, res: express.Response, next: express.NextFunction) { + try { + const buffer = Buffer.from(req.params.clientstatebase64, 'base64'); + const state = extractJsonFromBufferAndInflateIfRequired(buffer); + const config = this.getGoldenLayoutFromClientState(new ClientState(state)); + const metadata = this.getMetaDataFromLink(req, null, config); - this.renderGoldenLayout(config, metadata, req, res); + this.renderGoldenLayout(config, metadata, req, res); + } catch (err) { + logger.debug('Failed to parse client state from URL', { + error: err instanceof Error ? err.message : String(err), + clientstatebase64: req.params.clientstatebase64?.substring(0, 100), + }); + next({ + statusCode: 400, + message: 'Invalid client state data in URL', + }); + } } simpleLayoutHandler(req: express.Request, res: express.Response) { @@ -302,13 +314,28 @@ export class RouteAPI { export function extractJsonFromBufferAndInflateIfRequired(buffer: Buffer): any { const firstByte = buffer.at(0); // for uncompressed data this is probably '{' const isGzipUsed = firstByte !== undefined && (firstByte & 0x0f) === 0x8; // https://datatracker.ietf.org/doc/html/rfc1950, https://datatracker.ietf.org/doc/html/rfc1950, for '{' this yields 11 + + let jsonString: string; if (isGzipUsed) { try { - return JSON.parse(zlib.inflateSync(buffer).toString()); - } catch (_) { - return JSON.parse(buffer.toString()); + jsonString = zlib.inflateSync(buffer).toString(); + } catch (inflateError) { + logger.debug('Failed to inflate gzipped buffer, falling back to raw buffer', inflateError); + jsonString = buffer.toString(); } } else { - return JSON.parse(buffer.toString()); + jsonString = buffer.toString(); + } + + try { + return JSON.parse(jsonString); + } catch (parseError) { + logger.debug('Failed to parse JSON from client state', { + error: parseError, + jsonString: jsonString.substring(0, 100) + (jsonString.length > 100 ? '...' : ''), + bufferLength: buffer.length, + }); + const errorMessage = parseError instanceof Error ? parseError.message : 'Unknown parsing error'; + throw new Error(`Invalid JSON in client state: ${errorMessage}`); } } diff --git a/lib/languages.ts b/lib/languages.ts index a9135303e..a3a622a87 100644 --- a/lib/languages.ts +++ b/lib/languages.ts @@ -748,6 +748,17 @@ const definitions: Record = { previewFilter: null, monacoDisassembly: 'scheme', }, + raku: { + name: 'Raku', + monaco: 'perl', + extensions: ['.raku', '.rakutest', '.rakumod', '.rakudoc'], + alias: ['Perl 6'], + logoUrl: 'camelia.svg', + logoUrlDark: null, + formatter: null, + previewFilter: null, + monacoDisassembly: null, + }, ruby: { name: 'Ruby', monaco: 'ruby', diff --git a/static/modes/c3-mode.ts b/static/modes/c3-mode.ts index e30eb97f5..836b7558d 100644 --- a/static/modes/c3-mode.ts +++ b/static/modes/c3-mode.ts @@ -63,6 +63,7 @@ function definition(): monaco.languages.IMonarchLanguage { '$eval', '$evaltype', '$extnameof', + '$exec', '$for', '$foreach', '$if', @@ -307,7 +308,7 @@ function definition(): monaco.languages.IMonarchLanguage { whitespace: [ [/[ \r\n]+/, 'white'], [/\/\*/, 'comment', '@comment'], - [/\/\+/, 'comment', '@comment'], + [/<\*/, 'contract', '@contract'], [/\/\/.*$/, 'comment'], [/\t/, 'comment.invalid'], ], @@ -316,9 +317,17 @@ function definition(): monaco.languages.IMonarchLanguage { [/[^/*]+/, 'comment'], [/\/\*/, 'comment', '@comment'], [/\*\//, 'comment', '@pop'], + [/\*>/, 'comment', '@pop'], [/[/*]/, 'comment'], ], + contract: [ + [/[^/*]+/, 'contract'], + [/\*>/, 'contract', '@pop'], + [/[/*]/, 'contract'], + [/\t/, 'contract.invalid'], + ], + string: [ [/[^\\"]+/, 'string'], [/@escapes/, 'string.escape'], diff --git a/static/panes/gccdump-view.ts b/static/panes/gccdump-view.ts index 41d0a803f..fc9f890ae 100644 --- a/static/panes/gccdump-view.ts +++ b/static/panes/gccdump-view.ts @@ -234,7 +234,8 @@ export class GccDump extends MonacoPane op[1].filename_suffix === this.selectedPass, ); - const selectedPassId = activeOption![0]; + if (!activeOption) return; + const selectedPassId = activeOption[0]; const option = this.selectize.getOption(selectedPassId); // Workaround for a TomSelect glitch: onFocus sets the active option to the first one // on the first re-open, so this setActiveOption call needs to be delayed. @@ -303,6 +304,12 @@ export class GccDump extends MonacoPane"); +} + /* * https://github.com/Microsoft/monaco-editor/issues/417 * Safari 10.1, fails inherit correct visibility from parent when we change the visibility of parent element from hidden to inherit, in this particular case. @@ -1203,27 +1210,6 @@ html[data-theme='one-dark'] { padding-right: 2rem !important; } -/* Add back the dropdown arrow for TomSelect in Bootstrap 5 */ -.ts-wrapper.single .ts-control:not(.input-active)::after { - content: " "; - display: block; - position: absolute; - top: 50%; - right: 15px; - margin-top: -3px; - width: 0; - height: 0; - border-style: solid; - border-width: 5px 5px 0 5px; - border-color: #343a40 transparent transparent transparent; -} - -/* Styling for the dropdown arrow when dropdown is active */ -.ts-wrapper.single.dropdown-active .ts-control::after { - margin-top: -4px; - border-width: 0 5px 5px 5px; - border-color: transparent transparent #343a40 transparent; -} // Fix Bootstrap 5's input-group border overlap issues with TomSelect // Bootstrap applies a -1px margin to elements matching `:not(:first-child)` in input groups diff --git a/static/styles/themes/dark-theme.scss b/static/styles/themes/dark-theme.scss index eddba737e..a433bdd46 100644 --- a/static/styles/themes/dark-theme.scss +++ b/static/styles/themes/dark-theme.scss @@ -646,13 +646,9 @@ textarea.form-control { .ts-control { border: none; color: #f2f2f2 !important; - background: #444 !important; + background-color: #444 !important; text-shadow: none !important; - &:after { - border-color: #728690 transparent transparent transparent; - } - &.disabled { color: #f2f2f2 !important; background-color: #383838 !important; @@ -660,6 +656,11 @@ textarea.form-control { } } +/* Override arrow specifically with the same selector as TomSelect uses */ +.ts-wrapper:not(.form-control, .form-select).single .ts-control { + background-image: dropdown-arrow-svg(#aaa) !important; +} + #compiler-picker-modal { .architecture, .compiler-type { diff --git a/static/styles/themes/one-dark-theme.scss b/static/styles/themes/one-dark-theme.scss index 148198c50..131c9c7f0 100644 --- a/static/styles/themes/one-dark-theme.scss +++ b/static/styles/themes/one-dark-theme.scss @@ -705,13 +705,9 @@ textarea.form-control { .ts-control { border: none; color: #f2f2f2 !important; - background: $light !important; + background-color: $light !important; text-shadow: none !important; - &:after { - border-color: #525252 transparent transparent transparent; - } - &.disabled { color: #f2f2f2 !important; background-color: $light !important; @@ -719,6 +715,11 @@ textarea.form-control { } } +/* Override arrow specifically with the same selector as TomSelect uses */ +.ts-wrapper:not(.form-control, .form-select).single .ts-control { + background-image: dropdown-arrow-svg(#999) !important; +} + #compiler-picker-modal { .architecture, .compiler-type { diff --git a/static/styles/themes/pink-theme.scss b/static/styles/themes/pink-theme.scss index 427dd5909..bc159b6b9 100644 --- a/static/styles/themes/pink-theme.scss +++ b/static/styles/themes/pink-theme.scss @@ -654,12 +654,9 @@ textarea.form-control { .ts-control { border: none; color: #343a40 !important; - background: $base !important; + background-color: $base !important; text-shadow: none !important; - &:after { - border-color: #343a40 transparent transparent transparent; - } //&.disabled { // color: #f2f2f2 !important; diff --git a/test/asm-parser-subclass-integration-tests.ts b/test/asm-parser-subclass-integration-tests.ts new file mode 100644 index 000000000..c2a3898de --- /dev/null +++ b/test/asm-parser-subclass-integration-tests.ts @@ -0,0 +1,161 @@ +// Copyright (c) 2025, Compiler Explorer Authors +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +import {describe, expect, it} from 'vitest'; + +import {AsmEWAVRParser} from '../lib/parsers/asm-parser-ewavr.js'; +import {SPIRVAsmParser} from '../lib/parsers/asm-parser-spirv.js'; +import {VcAsmParser} from '../lib/parsers/asm-parser-vc.js'; +import {AsmParser} from '../lib/parsers/asm-parser.js'; +import * as properties from '../lib/properties.js'; + +// Helper functions to reduce test duplication +function initializeParserAndFindLabels( + ParserClass: new (...args: any[]) => T, + constructorArgs: any[], + asmLines: string[], +): Set { + const parser = new ParserClass(...constructorArgs); + return parser.findUsedLabels(asmLines, true); +} + +function processAsmWithParser( + ParserClass: new (...args: any[]) => T, + constructorArgs: any[], + code: string, + options: any, +) { + const parser = new ParserClass(...constructorArgs); + return parser.processAsm(code, options); +} + +describe('AsmParser subclass compatibility', () => { + describe('labelFindFor method behavior', () => { + it('should use VcAsmParser labelFindFor override to find specific VC labels', () => { + const asmLines = ['_start:', 'mov eax, OFFSET _data', 'call _function', 'jmp _start']; + const usedLabels = initializeParserAndFindLabels(VcAsmParser, [], asmLines); + + // VC-specific label detection should find these labels + expect(usedLabels.has('_data')).toBe(true); + expect(usedLabels.has('_function')).toBe(true); + expect(usedLabels.has('_start')).toBe(true); + }); + + it('should demonstrate EWAVR labelFindFor bug prevents finding label usage', () => { + const asmLines = [ + '_data: .word 0x1234', + '_main:', + ' ldi r16, HIGH(_data)', + ' ldi r17, LOW(_data)', + ' call _subroutine', + ' rjmp _main', + ]; + const usedLabels = initializeParserAndFindLabels(AsmEWAVRParser, [properties.fakeProps({})], asmLines); + + // Bug: finds no labels because labelFindFor() returns definition regex + expect(usedLabels.size).toBe(0); + expect(usedLabels.has('_data')).toBe(false); + expect(usedLabels.has('_subroutine')).toBe(false); + expect(usedLabels.has('_main')).toBe(false); + + // The bug is that EWAVR's labelFindFor looks for lines ending with ':' + // instead of finding label references in instructions + }); + + it('should show base class finds all identifier-like tokens as potential labels', () => { + const asmLines = ['_start:', ' call printf', ' mov eax, value', ' jmp _start']; + const usedLabels = initializeParserAndFindLabels(AsmParser, [], asmLines); + + // Base class finds ALL identifier-like tokens, not just actual labels + expect(usedLabels.has('call')).toBe(true); // Instruction (not a label) + expect(usedLabels.has('printf')).toBe(true); // Actual label reference + expect(usedLabels.has('mov')).toBe(true); // Instruction (not a label) + expect(usedLabels.has('eax')).toBe(true); // Register (not a label) + expect(usedLabels.has('value')).toBe(true); // Actual label reference + expect(usedLabels.has('jmp')).toBe(true); // Instruction (not a label) + expect(usedLabels.has('_start')).toBe(true); // Actual label reference + + // This over-matching is why subclasses override labelFindFor + // to be more specific about what constitutes a label in their syntax + }); + }); + + describe('processAsm custom implementations', () => { + it('should verify VcAsmParser has different output format than base class', () => { + const testCode = ['mov eax, OFFSET _data', 'call _function'].join('\n'); + const options = {directives: true, labels: false}; + + const baseResult = processAsmWithParser(AsmParser, [], testCode, options); + const vcResult = processAsmWithParser(VcAsmParser, [], testCode, options); + + // Base class returns labelDefinitions, VC parser does not + expect(baseResult).toHaveProperty('labelDefinitions'); + expect(vcResult.labelDefinitions).toBeUndefined(); + + // Base parser tracks label definitions it finds + expect(baseResult.labelDefinitions).toEqual({}); + + // Both should preserve the actual assembly instructions + const baseMovLine = baseResult.asm.find(line => line.text?.includes('mov')); + const vcMovLine = vcResult.asm.find(line => line.text?.includes('mov')); + + expect(baseMovLine?.text).toContain('OFFSET _data'); + expect(vcMovLine?.text).toContain('OFFSET _data'); + + // Verify parsingTime and filteredCount are returned + expect(typeof baseResult.parsingTime).toBe('number'); + expect(typeof baseResult.filteredCount).toBe('number'); + }); + + it('should verify SPIRVAsmParser getUsedLabelsInLine detects percent labels', () => { + const spirvCode = ['OpBranch %exit_label', '%exit_label = OpLabel', 'OpReturn'].join('\n'); + + const result = processAsmWithParser(SPIRVAsmParser, [], spirvCode, { + directives: false, + labels: false, + commentOnly: false, + }); + + // Should correctly identify SPIR-V %label syntax in definitions + expect(result.labelDefinitions).toBeDefined(); + expect(result.labelDefinitions).toHaveProperty('%exit_label'); + expect(result.labelDefinitions!['%exit_label']).toBe(2); // Line number of definition + + // Should find the branch target in the labels array + const branchLine = result.asm.find(line => line.text === 'OpBranch %exit_label'); + expect(branchLine).toBeDefined(); + expect(branchLine?.labels).toHaveLength(1); + expect(branchLine?.labels?.[0].name).toBe('%exit_label'); + expect(branchLine?.labels?.[0].range).toBeDefined(); + expect(branchLine?.labels?.[0].range.startCol).toBeGreaterThan(0); + const startCol = branchLine?.labels?.[0].range.startCol; + expect(startCol).toBeDefined(); + expect(branchLine?.labels?.[0].range.endCol).toBeGreaterThan(startCol!); + + // OpReturn should have no labels + const returnLine = result.asm.find(line => line.text === 'OpReturn'); + expect(returnLine?.labels).toHaveLength(0); + }); + }); +}); diff --git a/test/demangler-tests.ts b/test/demangler-tests.ts index 00e3d0ec9..372521679 100644 --- a/test/demangler-tests.ts +++ b/test/demangler-tests.ts @@ -160,15 +160,9 @@ describe('Basic demangling', () => { demangler .process(result) .then(output => { - if (process.platform === 'win32') { - expect(output.asm[0].text).toEqual( - 'jmp qword ptr [rip + core::fmt::num::imp::::fmt@GOTPCREL]', - ); - } else { - expect(output.asm[0].text).toEqual( - 'jmp qword ptr [rip + core::fmt::num::imp::::fmt::h7bbbd896a38dccca@GOTPCREL]', - ); - } + expect(output.asm[0].text).toEqual( + 'jmp qword ptr [rip + core::fmt::num::imp::::fmt::h7bbbd896a38dccca@GOTPCREL]', + ); }) .catch(catchCppfiltNonexistence), ]); diff --git a/test/ewavr-asm-parser-tests.ts b/test/ewavr-asm-parser-tests.ts new file mode 100644 index 000000000..624f1e572 --- /dev/null +++ b/test/ewavr-asm-parser-tests.ts @@ -0,0 +1,199 @@ +// Copyright (c) 2025, Compiler Explorer Authors +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +import {beforeEach, describe, expect, it} from 'vitest'; + +import {AsmEWAVRParser} from '../lib/parsers/asm-parser-ewavr.js'; +import * as properties from '../lib/properties.js'; + +describe('AsmEWAVRParser', () => { + let parser: AsmEWAVRParser; + + beforeEach(() => { + parser = new AsmEWAVRParser(properties.fakeProps({})); + }); + + describe('EWAVR assembly processing functionality', () => { + it('should process EWAVR assembly and preserve AVR instruction formats', () => { + const ewavrAssembly = [ + '_main:', + ' ldi r16, 0xFF', + ' call _function', + ' ret', + ].join('\n'); + + const result = parser.processAsm(ewavrAssembly, { + directives: false, + labels: false, + commentOnly: false, + }); + + // Should preserve specific EWAVR/AVR instruction formats + const ldiInstruction = result.asm.find(line => line.text?.includes('ldi')); + expect(ldiInstruction?.text).toContain('r16, 0xFF'); + + const callInstruction = result.asm.find(line => line.text?.includes('call')); + expect(callInstruction?.text).toContain('_function'); + + // AsmEWAVRParser has custom processAsm that doesn't return labelDefinitions + expect(result.labelDefinitions).toBeUndefined(); + }); + + it('should handle EWAVR-specific directives filtering', () => { + const ewavrAssembly = [ + 'RSEG CODE', + 'PUBLIC _function', + '_function:', + ' ldi r16, HIGH(_external_var)', + ' END', + ].join('\n'); + + const resultWithDirectives = parser.processAsm(ewavrAssembly, { + directives: false, // Include directives + labels: false, + commentOnly: false, + }); + + const resultFilteringDirectives = parser.processAsm(ewavrAssembly, { + directives: true, // Filter out directives + labels: false, + commentOnly: false, + }); + + // When filtering directives, should have fewer lines + expect(resultFilteringDirectives.asm.length).toBeLessThan(resultWithDirectives.asm.length); + + // Should preserve the HIGH() function call format + const hasHighFunction = resultWithDirectives.asm.some(line => line.text?.includes('HIGH(')); + expect(hasHighFunction).toBe(true); + }); + + it('should filter EWAVR comments when commentOnly is true', () => { + const ewavrAssembly = [ + '// This is a comment', + '_main:', + ' ldi r16, 42', + ' ret', + ].join('\n'); + + const resultWithComments = parser.processAsm(ewavrAssembly, { + directives: false, + labels: false, + commentOnly: false, // Include comments + }); + + const resultFilteringComments = parser.processAsm(ewavrAssembly, { + directives: false, + labels: false, + commentOnly: true, // Filter out comments + }); + + // When filtering comments, should have fewer lines + expect(resultFilteringComments.asm.length).toBeLessThan(resultWithComments.asm.length); + + // Should still have the actual instruction + const hasLdiInstruction = resultFilteringComments.asm.some(line => line.text?.includes('ldi')); + expect(hasLdiInstruction).toBe(true); + + // Should not have comment lines when filtering + const hasCommentLine = resultFilteringComments.asm.some(line => line.text?.startsWith('//')); + expect(hasCommentLine).toBe(false); + }); + }); + + describe('EWAVR assembly processing', () => { + it('should preserve EWAVR AVR instruction operands and labels', () => { + const ewavrAssembly = [ + '_main:', + ' ldi r16, 0xFF', + ' out PORTB, r16', + ' call _delay', + 'delay_loop:', + ' brne delay_loop', + ' ret', + ].join('\n'); + + const result = parser.processAsm(ewavrAssembly, { + directives: false, + labels: false, + commentOnly: false, + }); + + // Should preserve specific AVR instruction formats + const outInstruction = result.asm.find(line => line.text?.includes('out')); + expect(outInstruction?.text).toContain('PORTB, r16'); + + const branchInstruction = result.asm.find(line => line.text?.includes('brne')); + expect(branchInstruction?.text).toContain('delay_loop'); + + // AsmEWAVRParser has custom processAsm format + expect(result.labelDefinitions).toBeUndefined(); + }); + + it('should demonstrate EWAVR labelFindFor bug with label usage detection', () => { + const asmLines = ['ldi r16, HIGH(_data)', 'ldi r17, LOW(_data)', 'call _subroutine', 'rjmp _loop']; + + const usedLabels = parser.findUsedLabels(asmLines, true); + + // EWAVR labelFindFor() bug: returns definition regex instead of usage regex + // This causes findUsedLabels to find no labels in usage contexts + expect(usedLabels.has('_data')).toBe(false); + expect(usedLabels.has('_subroutine')).toBe(false); + expect(usedLabels.has('_loop')).toBe(false); + expect(usedLabels.size).toBe(0); + + // The regex is designed for definitions (with colons) not usage + const labelFindRegex = parser.labelFindFor(); + expect(labelFindRegex.test('_data:')).toBe(true); // Matches definitions + expect(labelFindRegex.test('_data')).toBe(false); // Doesn't match usage + }); + + it('should handle EWAVR segment syntax and register operations', () => { + const ewavrCode = [ + "CODE32 segment 'CODE'", + 'public _main', + '_main:', + ' ldi r16, 0xFF', + ' out DDRC, r16', + ' CODE32 ends', + ].join('\n'); + + const result = parser.processAsm(ewavrCode, { + directives: false, + labels: false, + commentOnly: false, + }); + + // Should preserve AVR register operations + const ldiInstruction = result.asm.find(line => line.text?.includes('ldi')); + expect(ldiInstruction?.text).toContain('r16, 0xFF'); + + const outInstruction = result.asm.find(line => line.text?.includes('out')); + expect(outInstruction?.text).toContain('DDRC, r16'); + + // AsmEWAVRParser uses custom format + expect(result.labelDefinitions).toBeUndefined(); + }); + }); +}); diff --git a/test/handlers/route-api-test.ts b/test/handlers/route-api-test.ts index bb6e9d821..e45f70c55 100644 --- a/test/handlers/route-api-test.ts +++ b/test/handlers/route-api-test.ts @@ -66,6 +66,40 @@ describe('extractJsonFromBufferAndInflateIfRequired test cases', () => { const buffer = Buffer.from('no json'); expect(() => extractJsonFromBufferAndInflateIfRequired(buffer)).toThrow(); }); + it('check that data extraction fails for empty buffer', () => { + const buffer = Buffer.from(''); + expect(() => extractJsonFromBufferAndInflateIfRequired(buffer)).toThrow('Invalid JSON in client state'); + }); + it('check that data extraction fails for whitespace-only buffer', () => { + const buffer = Buffer.from(' \n\t '); + expect(() => extractJsonFromBufferAndInflateIfRequired(buffer)).toThrow('Invalid JSON in client state'); + }); + it('check that data extraction fails for truncated JSON', () => { + const buffer = Buffer.from('{"sessions":[{"id":1,"languag'); + expect(() => extractJsonFromBufferAndInflateIfRequired(buffer)).toThrow('Invalid JSON in client state'); + }); + it('check that data extraction fails for invalid JSON characters', () => { + const buffer = Buffer.from('{"invalid": json}'); + expect(() => extractJsonFromBufferAndInflateIfRequired(buffer)).toThrow('Invalid JSON in client state'); + }); + it('check that data extraction fails for gzipped malformed JSON', () => { + const malformedJson = '{"sessions":[{"id":1,"languag'; + const buffer = zlib.deflateSync(Buffer.from(malformedJson)); + expect(possibleCompression(buffer)).toBeTruthy(); + expect(() => extractJsonFromBufferAndInflateIfRequired(buffer)).toThrow('Invalid JSON in client state'); + }); + it('check that data extraction fails for gzipped empty data', () => { + const emptyJson = ''; + const buffer = zlib.deflateSync(Buffer.from(emptyJson)); + expect(possibleCompression(buffer)).toBeTruthy(); + expect(() => extractJsonFromBufferAndInflateIfRequired(buffer)).toThrow('Invalid JSON in client state'); + }); + it('check that data extraction handles corrupt gzip data', () => { + // Create data that looks like gzip (first byte & 0x0f === 0x8) but isn't valid gzip + const corruptGzipData = Buffer.from([0x18, 0x01, 0x02, 0x03]); // First byte makes it look like gzip + expect(possibleCompression(corruptGzipData)).toBeTruthy(); + expect(() => extractJsonFromBufferAndInflateIfRequired(corruptGzipData)).toThrow(); + }); }); describe('clientStateHandler', () => { @@ -110,4 +144,45 @@ describe('clientStateHandler', () => { const response = await request(app).get(`/clientstate/${document}`); expect(response.status).toBe(200); }); + it('should return 400 for invalid base64 in /clientstate', async () => { + const invalidBase64 = 'INVALID_BASE64!!!'; + const response = await request(app).get(`/clientstate/${invalidBase64}`); + expect(response.status).toBe(400); + }); + it('should return 400 for empty data in /clientstate', async () => { + const emptyData = Buffer.from('').toString('base64'); + const response = await request(app).get(`/clientstate/${emptyData}`); + expect(response.status).toBe(400); + }); + it('should return 400 for malformed JSON in /clientstate', async () => { + const malformedJson = Buffer.from('{"invalid": json}').toString('base64'); + const response = await request(app).get(`/clientstate/${malformedJson}`); + expect(response.status).toBe(400); + }); + it('should return 400 for truncated JSON in /clientstate', async () => { + const truncatedJson = Buffer.from('{"sessions":[{"id":1,"languag').toString('base64'); + const response = await request(app).get(`/clientstate/${truncatedJson}`); + expect(response.status).toBe(400); + }); + it('should return 400 for binary data in /clientstate', async () => { + const binaryData = Buffer.from([0x00, 0x01, 0x02, 0xff, 0xfe, 0xfd]).toString('base64'); + const response = await request(app).get(`/clientstate/${binaryData}`); + expect(response.status).toBe(400); + }); + it('should return 400 for gzipped malformed JSON in /clientstate', async () => { + const malformedJson = '{"sessions":[{"id":1,"languag'; + const gzippedData = zlib.deflateSync(Buffer.from(malformedJson)).toString('base64'); + const response = await request(app).get(`/clientstate/${gzippedData}`); + expect(response.status).toBe(400); + }); + it('should return 400 for gzipped empty data in /clientstate', async () => { + const emptyData = zlib.deflateSync(Buffer.from('')).toString('base64'); + const response = await request(app).get(`/clientstate/${emptyData}`); + expect(response.status).toBe(400); + }); + it('should return 400 for corrupt gzip data in /clientstate', async () => { + const corruptGzipData = Buffer.from([0x18, 0x01, 0x02, 0x03]).toString('base64'); + const response = await request(app).get(`/clientstate/${corruptGzipData}`); + expect(response.status).toBe(400); + }); }); diff --git a/test/spirv-asm-parser-tests.ts b/test/spirv-asm-parser-tests.ts new file mode 100644 index 000000000..310a8f9e1 --- /dev/null +++ b/test/spirv-asm-parser-tests.ts @@ -0,0 +1,164 @@ +// Copyright (c) 2025, Compiler Explorer Authors +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +import {beforeEach, describe, expect, it, vi} from 'vitest'; + +import {SPIRVAsmParser} from '../lib/parsers/asm-parser-spirv.js'; + +describe('SPIRVAsmParser', () => { + let parser: SPIRVAsmParser; + + beforeEach(() => { + parser = new SPIRVAsmParser(); + }); + + describe('getUsedLabelsInLine override', () => { + it('should detect labels in OpFunctionCall', () => { + const line = 'OpFunctionCall %void %func_main'; + const labels = parser.getUsedLabelsInLine(line); + + expect(labels).toHaveLength(1); + expect(labels[0].name).toBe('%func_main'); + }); + + it('should detect labels in OpBranch', () => { + const line = 'OpBranch %label_endif'; + const labels = parser.getUsedLabelsInLine(line); + + expect(labels).toHaveLength(1); + expect(labels[0].name).toBe('%label_endif'); + }); + + it('should detect multiple labels in OpBranchConditional', () => { + const line = 'OpBranchConditional %cond %true_label %false_label'; + const labels = parser.getUsedLabelsInLine(line); + + expect(labels).toHaveLength(2); + expect(labels[0].name).toBe('%true_label'); + expect(labels[1].name).toBe('%false_label'); + }); + + it('should detect labels in OpSelectionMerge', () => { + const line = 'OpSelectionMerge %merge_label None'; + const labels = parser.getUsedLabelsInLine(line); + + expect(labels).toHaveLength(1); + expect(labels[0].name).toBe('%merge_label'); + }); + + it('should detect labels in OpLoopMerge', () => { + const line = 'OpLoopMerge %merge_label %continue_label None'; + const labels = parser.getUsedLabelsInLine(line); + + expect(labels).toHaveLength(2); + expect(labels[0].name).toBe('%merge_label'); + expect(labels[1].name).toBe('%continue_label'); + }); + + it('should detect labels in OpSwitch', () => { + const line = 'OpSwitch %selector %default 1 %case1 2 %case2'; + const labels = parser.getUsedLabelsInLine(line); + + expect(labels).toHaveLength(3); + expect(labels[0].name).toBe('%default'); + expect(labels[1].name).toBe('%case1'); + expect(labels[2].name).toBe('%case2'); + }); + + it('should be called during assembly processing', () => { + const spy = vi.spyOn(parser, 'getUsedLabelsInLine'); + + const spirvCode = ` + OpBranch %exit_label + %exit_label = OpLabel + `; + + parser.processAsm(spirvCode, { + directives: false, + labels: false, + commentOnly: false, + }); + + expect(spy).toHaveBeenCalled(); + }); + }); + + describe('SPIR-V assembly processing', () => { + it('should detect SPIR-V percent labels with custom getUsedLabelsInLine', () => { + const spirvCode = [ + '%main = OpFunction %void None %1', + '%entry = OpLabel', + 'OpBranch %exit', + '%exit = OpLabel', + 'OpReturn', + ].join('\n'); + + const result = parser.processAsm(spirvCode, { + directives: false, + labels: false, + commentOnly: false, + }); + + // Should detect SPIR-V %label definitions + expect(result.labelDefinitions).toHaveProperty('%main'); + expect(result.labelDefinitions).toHaveProperty('%entry'); + expect(result.labelDefinitions).toHaveProperty('%exit'); + + // Should detect SPIR-V %label usage in OpBranch + const branchLine = result.asm.find(line => line.text?.includes('OpBranch')); + expect(branchLine?.labels?.some(label => label.name === '%exit')).toBe(true); + }); + + it('should handle SPIR-V control flow instructions with multiple label references', () => { + const spirvCode = [ + 'OpSelectionMerge %merge None', + 'OpBranchConditional %condition %true_block %false_block', + '%true_block = OpLabel', + '%false_block = OpLabel', + '%merge = OpLabel', + ].join('\n'); + + const result = parser.processAsm(spirvCode, { + directives: false, + labels: false, + commentOnly: false, + }); + + // Should identify all label definitions + expect(result.labelDefinitions).toHaveProperty('%true_block'); + expect(result.labelDefinitions).toHaveProperty('%false_block'); + expect(result.labelDefinitions).toHaveProperty('%merge'); + + // Should detect multiple labels in OpBranchConditional + const branchCondLine = result.asm.find(line => line.text?.includes('OpBranchConditional')); + const labelNames = branchCondLine?.labels?.map(label => label.name) || []; + expect(labelNames).toContain('%true_block'); + expect(labelNames).toContain('%false_block'); + + // Should detect label in OpSelectionMerge + const mergeLine = result.asm.find(line => line.text?.includes('OpSelectionMerge')); + expect(mergeLine?.labels?.some(label => label.name === '%merge')).toBe(true); + }); + }); +}); diff --git a/test/vc-asm-parser-tests.ts b/test/vc-asm-parser-tests.ts new file mode 100644 index 000000000..3175681b8 --- /dev/null +++ b/test/vc-asm-parser-tests.ts @@ -0,0 +1,119 @@ +// Copyright (c) 2025, Compiler Explorer Authors +// All rights reserved. +// +// Redistribution and use in source and binary forms, with or without +// modification, are permitted provided that the following conditions are met: +// +// * Redistributions of source code must retain the above copyright notice, +// this list of conditions and the following disclaimer. +// * Redistributions in binary form must reproduce the above copyright +// notice, this list of conditions and the following disclaimer in the +// documentation and/or other materials provided with the distribution. +// +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +// POSSIBILITY OF SUCH DAMAGE. + +import {beforeEach, describe, expect, it} from 'vitest'; + +import {VcAsmParser} from '../lib/parsers/asm-parser-vc.js'; +import {AsmParser} from '../lib/parsers/asm-parser.js'; + +describe('VcAsmParser', () => { + let parser: VcAsmParser; + + beforeEach(() => { + parser = new VcAsmParser(); + }); + + describe('VC assembly processing functionality', () => { + it('should have custom processAsm that returns different format than base class', () => { + // Simple test that doesn't trigger complex VC parsing logic + const simpleAsm = 'nop'; + + const baseParser = new AsmParser(); + const baseResult = baseParser.processAsm(simpleAsm, { + directives: false, + labels: false, + commentOnly: false, + }); + + // Base parser returns labelDefinitions, VC parser format is different + expect(baseResult).toHaveProperty('labelDefinitions'); + expect(typeof baseResult.labelDefinitions).toBe('object'); + }); + + it('should handle VC-specific directives correctly', () => { + const vcAssembly = ['PUBLIC _function', '_data\tSEGMENT', '_variable\tDD\t42', '_data\tENDS'].join('\n'); + + const resultWithDirectives = parser.processAsm(vcAssembly, { + directives: false, // Should include directives + labels: false, + commentOnly: false, + }); + + const resultFilteringDirectives = parser.processAsm(vcAssembly, { + directives: true, // Should filter out directives + labels: false, + commentOnly: false, + }); + + // When filtering directives, should have fewer lines + expect(resultFilteringDirectives.asm.length).toBeLessThan(resultWithDirectives.asm.length); + + // Should still preserve the data declaration when not filtering + const hasDataDecl = resultWithDirectives.asm.some(line => line.text?.includes('DD')); + expect(hasDataDecl).toBe(true); + }); + + it('should correctly identify VC comments using commentOnly regex', () => { + const commentLine = '; This is a VC comment'; + const indentedComment = ' ; Indented comment'; + const codeLine = 'mov eax, ebx'; + + // VC commentOnly regex is /^;/ - only matches lines starting with ; + expect(parser.commentOnly.test(commentLine)).toBe(true); + expect(parser.commentOnly.test(codeLine)).toBe(false); + + // VC regex doesn't match comments with leading whitespace + expect(parser.commentOnly.test(indentedComment)).toBe(false); + }); + }); + + describe('VC assembly processing', () => { + it('should recognize VC function definitions with PROC keyword', () => { + const procLine = '_function\tPROC'; + const nonProcLine = '_function:'; + + // Test the function definition regex directly + expect(parser.definesFunction.test(procLine)).toBe(true); + expect(parser.definesFunction.test(nonProcLine)).toBe(false); + + // Should extract function name + const match = procLine.match(parser.definesFunction); + expect(match?.[1]).toBe('_function'); + }); + + it('should find labels in VC-specific syntax using custom labelFindFor', () => { + const asmLines = ['mov eax, OFFSET _data', 'mov ebx, DWORD PTR _variable', 'call _function']; + + const usedLabels = parser.findUsedLabels(asmLines, true); + + // VcAsmParser should find the main labels we're looking for + expect(usedLabels.has('_data')).toBe(true); + expect(usedLabels.has('_variable')).toBe(true); + expect(usedLabels.has('_function')).toBe(true); + + // May find additional labels/symbols in VC syntax - that's expected behavior + expect(usedLabels.size).toBeGreaterThanOrEqual(3); + }); + }); +}); diff --git a/types/languages.interfaces.ts b/types/languages.interfaces.ts index fb59af649..fce163822 100644 --- a/types/languages.interfaces.ts +++ b/types/languages.interfaces.ts @@ -88,6 +88,7 @@ export type LanguageKey = | 'python' | 'ptx' | 'racket' + | 'raku' | 'ruby' | 'rust' | 'sail' diff --git a/views/font-size.pug b/views/font-size.pug index e8eac11da..f4b843cf3 100644 --- a/views/font-size.pug +++ b/views/font-size.pug @@ -1,4 +1,4 @@ .btn-group.btn-group-sm(role="group" aria-label="Font size") button.dropdown-toggle.btn.btn-light.fs-button(type="button" title="Change font size\nTip #1: You can use scroll wheel while hovering over this button\nTip #2: You can ctrl+click this button to reset to default" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" data-bs-flip="false" data-bs-boundary="viewport") - span.fa.fa-font #[b.caret] + span.fa.fa-font .dropdown-menu.font-size-list(aria-labelledby="fs-button") diff --git a/views/resources/logos/camelia.svg b/views/resources/logos/camelia.svg new file mode 100644 index 000000000..556094d30 --- /dev/null +++ b/views/resources/logos/camelia.svg @@ -0,0 +1 @@ +TM \ No newline at end of file