Skip to content

Update TIC-80#28

Open
RobLoach wants to merge 30 commits intomasterfrom
revert-27-revert-26-update-tic80
Open

Update TIC-80#28
RobLoach wants to merge 30 commits intomasterfrom
revert-27-revert-26-update-tic80

Conversation

@RobLoach
Copy link
Member

@RobLoach RobLoach commented May 13, 2024

@RobLoach RobLoach added the Hold label May 13, 2024
@imsys
Copy link

imsys commented Aug 24, 2025

I don't know gitlab that well, but I could not find the mentioned targets. I hope we could get some update on this.

@imsys
Copy link

imsys commented Aug 26, 2025

I was able to build it for my Linux x86_64 and Android using your the configs you created in the gitlab yml.

It does fix nesbox#2504 (sprites) and nesbox#2319 (javascript games).

I made a small Makefile (with the help of ChatGPT) to build it. It can be found with instructions at: https://gist.github.com/imsys/2981c9de54a07abf7a24df139b3237a2

In case anyone wants to just use my binaries, I will host it at my Gdrive until we have an official build.
https://drive.google.com/drive/folders/14MkvLGF7qxGFfVlTElmYyMd-NQE_RrOF

I also tried compiling to Linux aarch64, so I could run it on my TRIMUI handheld. It would just build fine, but the core would just fail to load over there. I will probably check in their community what I may be missing to get it working correctly there.

@RobLoach
Copy link
Member Author

Thanks for testing. I think what was remaining here was making sure that all build targets passed in libretro buildbot. While most passed, not all did. I'm unclear on the status of that today.

Either way, this attempt could do with another update to the latest TIC80 😉

@imsys
Copy link

imsys commented Aug 27, 2025

I was able to compile for the TrimUI, notes are at: https://gist.github.com/imsys/0c67f1b27ff386abb075b67c6fa1766a

@imsys
Copy link

imsys commented Sep 5, 2025

Edge case: Bokdown https://tic80.com/play?cart=1411
In my Android and Trimu build, the game freezes in the first level. I first suspected it was due to using static link instead of dynamic, but I'm unsure,.. I can't get a dynamic build to work.
I will see if I can do more tests later.

@imsys
Copy link

imsys commented Sep 5, 2025

Sorry, my bad. The problem is in the TIC-80 main (latest 4c1b009).
The version proposed here (v1.1.2837) works fine.

Disable BUILD_WITH_ALL and enable multiple language options in CI configuration.
@imsys
Copy link

imsys commented Mar 9, 2026

$ curl -L https://github.com/Kitware/CMake/releases/download/v3.31.11/cmake-3.31.11-linux-x86_64.sh -o cmake-install.sh # collapsed multi-line command
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0
100 52.4M  100 52.4M    0     0  35.6M      0  0:00:01  0:00:01 --:--:-- 37.3M
CMake Installer Version: 3.31.11, Copyright (c) Kitware
This is a self-extracting archive.
The archive will be extracted to: /builds/libretro/tic80/cmake
Using target directory: /builds/libretro/tic80/cmake
Extracting, please wait...
./cmake-install.sh: 278: cd: can't cd to /builds/libretro/tic80/cmake

add this line somewhere before the cmake install:
mkdir -p "$CI_PROJECT_DIR/cmake"

so:

.upgrade-cmake:
  before_script:
    - |
      mkdir -p "$CI_PROJECT_DIR/cmake"
      curl -L https://github.com/Kitware/CMake/releases/download/v3.31.11/cmake-3.31.11-linux-x86_64.sh -o cmake-install.sh
      chmod +x cmake-install.sh
      ./cmake-install.sh --skip-license --prefix=$CI_PROJECT_DIR/cmake
      export PATH="$CI_PROJECT_DIR/cmake/bin:$PATH"
      cmake --version

@imsys
Copy link

imsys commented Mar 9, 2026

For the Switch, while we don't get nesbox#2891, we can use this:

libretro-build-libnx-aarch64:
  extends:
    - .libretro-libnx-static-cmake-retroarch-master
    - .core-defs
  before_script:
    - export NUMPROC=$(($(nproc)/5))
    - sed -i '13,31 s/^/#/' "$CI_PROJECT_DIR/$CMAKE_SOURCE_ROOT/cmake/nswitch.cmake"

I think the EXTRA_PATH has to be changed to bin in the current version of tic80, thats where cmakes output the .so file. So I think it should be removed, as it is set EXTRA_PATH=bin at the beginning of the yml.

ChatGPT also says the before_script overwrites the before_script in the template files, and says that we should add export NUMPROC=$(($(nproc)/5)) in this new overwrite.

@imsys
Copy link

imsys commented Mar 9, 2026

I'm expecting the variables to be:
CI_PROJECT_DIR = /builds/libretro/tic80/
CMAKE_SOURCE_ROOT = core

So the full path to the file that I target the sed command is this:
/builds/libretro/tic80/core/cmake/nswitch.cmake

by the way, the command is basically to comment lines from 13 to 31.

@imsys
Copy link

imsys commented Mar 9, 2026

$ cmake $CORE_ARGS "$CMAKE_SOURCE_ROOT" -B$BUILD_DIR -DCMAKE_BUILD_TYPE=Release -DLIBRETRO_STATIC=ON -DLIBRETRO_SUFFIX=_ctr -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE_DIR}/ctr.cmake
CMake Warning:
  Ignoring extra path from command line:
   "/builds/libretro/tic80/${CORE_ARGS}"
CMake Error: Parse error in command line argument: TIC80_FFT_UNSUPPORTED
 Should be: VAR:type=value
CMake Error: Run 'cmake --help' for all supported options.

Gemini explains this error at: https://gemini.google.com/share/65d2736e50b0

So, basically applying all the previous fixes:
https://gist.github.com/imsys/f9a4b31a368ff89764c8e636ccf2201b

@imsys
Copy link

imsys commented Mar 9, 2026

So, I was debugging the Vita compilation, you can see my discussion with Gemini: https://gemini.google.com/share/0913b6014411

But to make a summary, Gitlab CI/CD doesn't accept:
CORE_ARGS: "${CORE_ARGS} ..... "

So i had to set it as a before_script + export var. But as it doesn't accept multiples before_script, it would overwrite the upgrade_cmake,.. so I had to combine the upgrade_cmake + the core vars, like:

.core-some-32bits-system:
  before_script:
    - export NUMPROC=$(($(nproc)/5))
    - export CORE_ARGS="${CORE_ARGS} ${CORE_32BITS_ARGS}"
    - |
      curl -L https://github.com/Kitware/CMake/releases/download/v3.31.11/cmake-3.31.11-linux-x86_64.sh -o cmake-install.sh
      chmod +x cmake-install.sh
      mkdir -p "$CI_PROJECT_DIR/cmake"
      ./cmake-install.sh --skip-license --prefix="$CI_PROJECT_DIR/cmake"
      export PATH="$CI_PROJECT_DIR/cmake/bin:$PATH"
      cmake --version

I just did not know what to label it all, as some 32bits system works with this, and others doesnt need this,.. so that how I labeled it, haha.

I updated the gist to reflect those changes.

https://gist.github.com/imsys/f9a4b31a368ff89764c8e636ccf2201b

So, the only system left that I need to look into is the emscripten.

Added support for building with JS and Janet in the CI configuration. Updated various build configurations to include 32-bit system arguments.
@RobLoach
Copy link
Member Author

RobLoach commented Mar 9, 2026

Like the idea of pushing some of the cmake stuff upstream. Good call 👍

@imsys
Copy link

imsys commented Mar 9, 2026

$ cmake $CORE_ARGS "$CMAKE_SOURCE_ROOT" -B$BUILD_DIR -DCMAKE_BUILD_TYPE=Release -DLIBRETRO_STATIC=ON -DLIBRETRO_SUFFIX=_ctr -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE_DIR}/ctr.cmake
CMake Error: Parse error in command line argument: TIC80_FFT_UNSUPPORTED\
 Should be: VAR:type=value
CMake Error: Run 'cmake --help' for all supported options.

This is really quite tricky, maybe this could work?

.core-some-32bits-system:
  variables:
    CORE_32BITS_ARGS: >
      -DCMAKE_C_FLAGS_RELEASE="-DLUA_32BITS -DTIC80_FFT_UNSUPPORTED -DPOOR_CLIB"
      -DCMAKE_CXX_FLAGS_RELEASE="-DLUA_32BITS"

RobLoach added 2 commits March 9, 2026 13:37
Disable JANET build option in CI configuration.
@imsys
Copy link

imsys commented Mar 10, 2026

The Switch version is basically fixed, we just need to set EXTRA_PATH: lib for it.

Actually, we have to add EXTRA_PATH: lib to everything that compiles with -DLIBRETRO_STATIC=ON, and that seems to be:

libretro-build-ctr
libretro-build-emscripten
libretro-build-libnx-aarch64
libretro-build-ngc
libretro-build-vita
libretro-build-wii
libretro-build-wiiu 

Speaking of which, they all compile fine, but the lib will be incomplete if we don't do the changes at nesbox#2905

So I thought that for now we could just do:

  before_script:
    - curl -L https://raw.githubusercontent.com/imsys/TIC-80/1a27f7a0dcfaf6149cd2c56e9d173c538526648a/cmake/libretro.cmake -o "$CI_PROJECT_DIR/$CMAKE_SOURCE_ROOT/cmake/libretro.cmake"

At least just to check if it works. Or you could add the file to this project and do a cp or mv.

Now the biggest problem is still the C/CXX_FLAGS. The next suggestion Gemini gave is to we try this:

    - |
      echo 'set(CMAKE_C_FLAGS_RELEASE "-DLUA_32BITS -DTIC80_FFT_UNSUPPORTED -DPOOR_CLIB" CACHE STRING "" FORCE)' > build_flags.cmake
      echo 'set(CMAKE_CXX_FLAGS_RELEASE "-DLUA_32BITS" CACHE STRING "" FORCE)' >> build_flags.cmake
    - export CORE_ARGS="${CORE_ARGS} -C ${CI_PROJECT_DIR}/build_flags.cmake"

If this doesn't work, probably some variation of it will. So I updated my gist with all those changes.

@imsys
Copy link

imsys commented Mar 10, 2026

I thought it would take only a few iterations, but it's taking way more..

libretro-build-ctr (3DS) ✅ fixed
libretro-build-emscripten ✅ fixed

Switch build got an error that I was able to reproduce, and I fixed by more updates to libretro.cmake.

https://raw.githubusercontent.com/imsys/TIC-80/1fff1af2e33d71a586abdcac82cf3c3dbf881c49/cmake/libretro.cmake

It needs to be updated in the 3 occurrences in the before_script.

The WiiU and Vita seems to be missing some os-time related lib, and I'm looking into it.

@imsys
Copy link

imsys commented Mar 10, 2026

NGC and Wii are failing because they require devkit to be added to path, so I added:
- [ -n "${DEVKITPPC:-}" ] && export PATH="$PATH:$DEVKITPPC/bin"
it checks if the var exists, if so, it adds to the path.

WiiU is failing because of some python issue with UTC_TIME,.. so I just set python off only for it.
Vita is failing because of Javascript time issues, so I have set JS off only for that system.

I have also set JS of for dingux.

All updated in the gist.

Updated the URL for fetching libretro.cmake to a newer commit.
@imsys
Copy link

imsys commented Mar 11, 2026

`.gitlab-ci.yml`: (): did not find expected ',' or ']' while parsing a flow sequence at line 115 column 7

oh,.. that line required to be between quotes:

  before_script:
    - export NUMPROC=$(($(nproc)/5))
    - '[ -n "${DEVKITPPC:-}" ] && export PATH="$PATH:$DEVKITPPC/bin"'

@imsys
Copy link

imsys commented Mar 13, 2026

Updated gist

Drumrolls 😄

@@ -107,6 +107,13 @@
   - build-shared
   - build-static
 
+.js-patch:
+  before_script:
+    - export NUMPROC=$(($(nproc)/5))
+    - echo 'set(CMAKE_C_FLAGS_RELEASE "-DPOOR_CLIB" CACHE STRING "" FORCE)' > build_flags.cmake
+    - export CORE_ARGS="${CORE_ARGS} -C ${CI_PROJECT_DIR}/build_flags.cmake"
+    - sed -i 's|#include <fenv.h>|#if __has_include(<fenv.h>)\n#include <fenv.h>\n#endif|' "$CI_PROJECT_DIR/$CMAKE_SOURCE_ROOT/vendor/quickjs/quickjs.c"
+
 .core-some-32bits-system:
   variables:
     EXTRA_PATH: lib
@@ -117,6 +124,7 @@
       echo 'set(CMAKE_C_FLAGS_RELEASE "-DLUA_32BITS -DTIC80_FFT_UNSUPPORTED -DPOOR_CLIB" CACHE STRING "" FORCE)' > build_flags.cmake
       echo 'set(CMAKE_CXX_FLAGS_RELEASE "-DLUA_32BITS" CACHE STRING "" FORCE)' >> build_flags.cmake
     - export CORE_ARGS="${CORE_ARGS} -C ${CI_PROJECT_DIR}/build_flags.cmake"
+    - sed -i 's|#include <fenv.h>|#if __has_include(<fenv.h>)\n#include <fenv.h>\n#endif|' "$CI_PROJECT_DIR/$CMAKE_SOURCE_ROOT/vendor/quickjs/quickjs.c"
     - curl -L https://raw.githubusercontent.com/imsys/TIC-80/1fff1af2e33d71a586abdcac82cf3c3dbf881c49/cmake/libretro.cmake -o "$CI_PROJECT_DIR/$CMAKE_SOURCE_ROOT/cmake/libretro.cmake"
     - |
       curl -L https://github.com/Kitware/CMake/releases/download/v3.31.11/cmake-3.31.11-linux-x86_64.sh -o cmake-install.sh
@@ Dingux @@
 libretro-build-dingux-odbeta-mips32:
   extends:
     - .libretro-dingux-odbeta-cmake-mips32
     - .core-defs
+    - .js-patch
   variables:
     DINGUX_CFLAGS:   -DDINGUX -fomit-frame-pointer -march=mips32 -mtune=mips32r2 -mhard-float
     DINGUX_CXXFLAGS: -DDINGUX -fomit-frame-pointer -march=mips32 -mtune=mips32r2 -mhard-float
-    CORE_ARGS_EXTRA: >
-      -DBUILD_WITH_JS=OFF
 
 # RetroFW
 libretro-build-retrofw-mips32:
   extends:
     - .libretro-retrofw-odbeta-cmake-mips32
     - .core-defs
+    - .js-patch
   variables:
     DINGUX_CFLAGS:   -DDINGUX -fomit-frame-pointer -march=mips32 -mtune=mips32r2 -mhard-float
     DINGUX_CXXFLAGS: -DDINGUX -fomit-frame-pointer -march=mips32 -mtune=mips32r2 -mhard-float
-    CORE_ARGS_EXTRA: >
-      -DBUILD_WITH_JS=OFF
 
 # MIYOO
 libretro-build-miyoo-arm32:
   extends:
     - .libretro-miyoo-cmake-arm32
     - .core-defs
+    - .js-patch
   variables:
     DINGUX_CFLAGS:   -DDINGUX -fomit-frame-pointer -fno-fast-math -march=armv5te -mtune=arm926ej-s -ftree-vectorize -funswitch-loops
     DINGUX_CXXFLAGS: -DDINGUX -fomit-frame-pointer -fno-fast-math -march=armv5te -mtune=arm926ej-s -ftree-vectorize -funswitch-loops
-    CORE_ARGS_EXTRA: >
-      -DBUILD_WITH_JS=OFF
 
 # VITA
 libretro-build-vita:
@@ -262,11 +267,11 @@
     - .core-defs
   variables:
     EXTRA_PATH: lib
-    CORE_ARGS_EXTRA: >
-      -DBUILD_WITH_JS=OFF
   before_script:
     - export NUMPROC=$(($(nproc)/5))
-    - export CORE_ARGS="${CORE_ARGS} -DCMAKE_POSITION_INDEPENDENT_CODE=OFF"
+    - echo 'set(CMAKE_C_FLAGS_RELEASE "-DPOOR_CLIB" CACHE STRING "" FORCE)' > build_flags.cmake
+    - curl -L https://raw.githubusercontent.com/imsys/TIC-80/1fff1af2e33d71a586abdcac82cf3c3dbf881c49/cmake/libretro.cmake -o "$CI_PROJECT_DIR/$CMAKE_SOURCE_ROOT/cmake/libretro.cmake"
+    - export CORE_ARGS="${CORE_ARGS} -DCMAKE_POSITION_INDEPENDENT_CODE=OFF -C ${CI_PROJECT_DIR}/build_flags.cmake"
 
 # Libnx
 libretro-build-libnx-aarch64:
@@ -279,6 +284,7 @@
     - export NUMPROC=$(($(nproc)/5))
     - curl -L https://raw.githubusercontent.com/imsys/TIC-80/1fff1af2e33d71a586abdcac82cf3c3dbf881c49/cmake/libretro.cmake -o "$CI_PROJECT_DIR/$CMAKE_SOURCE_ROOT/cmake/libretro.cmake"
     - sed -i '13,31 s/^/#/' "$CI_PROJECT_DIR/$CMAKE_SOURCE_ROOT/cmake/nswitch.cmake"
+    - sed -i 's/set(PREFER_SYSTEM_LIBRARIES ON)/set(PREFER_SYSTEM_LIBRARIES OFF)/' "$CI_PROJECT_DIR/$CMAKE_SOURCE_ROOT/CMakeLists.txt"

Added .js-patch to various build configurations and adjusted CORE_ARGS.
Comment on lines +13 to +16
- Squirrel
- WASM
- Fennel
- JavaScript
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- Squirrel
- WASM
- Fennel
- JavaScript

@imsys
Copy link

imsys commented Mar 16, 2026

Yay! It worked! :)

It builds fine, I just do not know if it actually runs. I do not have any of the Nintendo devices to test on them.

By the way, I think we could also add -DBUILD_WITH_JANET=ON that I think it would build just fine on most systems, and then just add -DBUILD_WITH_JANET=OFF using CORE_ARGS_EXTRA: just on the systems that fails. There is just 9 games using it, so it's not a priority, but there are some good ones, like Astro's Ladder. I actually would prefer if you just merge and then we try in a second PR, and maybe for that I could be the one starting the PR, and you would just assign the gitlab to mirror my PR, so we don't have to go back and forth exchanging patches.

Another note on the -DBUILD_WITH_RUBY=, it's quite easy to fix on debian/ubuntu based containers, we just have to add an apt-get install -y ruby rake, but as it uses a devkitpro container, it seems to use pacman for package manager, but from my initial tests, it seemed that the source repo was not set up. The challenge would be just installing those two packages. But there is only 5 games, and 4 out of them are from Itch. So it is also very low priority.

echo 'set(CMAKE_CXX_FLAGS_RELEASE "-DLUA_32BITS" CACHE STRING "" FORCE)' >> build_flags.cmake
- export CORE_ARGS="${CORE_ARGS} -C ${CI_PROJECT_DIR}/build_flags.cmake"
- sed -i 's|#include <fenv.h>|#if __has_include(<fenv.h>)\n#include <fenv.h>\n#endif|' "$CI_PROJECT_DIR/$CMAKE_SOURCE_ROOT/vendor/quickjs/quickjs.c"
- curl -L https://raw.githubusercontent.com/imsys/TIC-80/1fff1af2e33d71a586abdcac82cf3c3dbf881c49/cmake/libretro.cmake -o "$CI_PROJECT_DIR/$CMAKE_SOURCE_ROOT/cmake/libretro.cmake"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Before this gets in, I'd prefer if the upstream PR gets in first: nesbox#2905

Selectively building off of forks can become a mess in some cases 😅

before_script:
- export NUMPROC=$(($(nproc)/5))
- echo 'set(CMAKE_C_FLAGS_RELEASE "-DPOOR_CLIB" CACHE STRING "" FORCE)' > build_flags.cmake
- curl -L https://raw.githubusercontent.com/imsys/TIC-80/1fff1af2e33d71a586abdcac82cf3c3dbf881c49/cmake/libretro.cmake -o "$CI_PROJECT_DIR/$CMAKE_SOURCE_ROOT/cmake/libretro.cmake"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EXTRA_PATH: lib
before_script:
- export NUMPROC=$(($(nproc)/5))
- curl -L https://raw.githubusercontent.com/imsys/TIC-80/1fff1af2e33d71a586abdcac82cf3c3dbf881c49/cmake/libretro.cmake -o "$CI_PROJECT_DIR/$CMAKE_SOURCE_ROOT/cmake/libretro.cmake"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

variables:
EXTRA_PATH: lib
before_script:
- curl -L https://raw.githubusercontent.com/imsys/TIC-80/1fff1af2e33d71a586abdcac82cf3c3dbf881c49/cmake/libretro.cmake -o "$CI_PROJECT_DIR/$CMAKE_SOURCE_ROOT/cmake/libretro.cmake"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants