How to compile custom version of Godot with mono in CI/CD?

Viewed 39

How do you compile Godot with mono in a CI/CD? I can't find many examples -- the modules I could find (godex, sg_physics), omit compiling mono altogether.

Is Godot's own CI/CD for making releases available somewhere?

(EDIT: It looks like Godot users their build-containers repo to build their release builds. Unfortunately it can't be run on github actions because building the dockerfiles takes too long.)

Using Godot's documentation I'm hitting a problem compiling Godot windows, ios, and web builds. For all my compilations I'm using precompiled versions of mono made by the godot-mono-builds repo to compile for every platform. I'm also using Github Actions as my CI/CD.

Here's my repository for reference (I'm attempting to build mono versions of Godot containing snopek games' SGPhysics module): https://github.com/Fractural/SGPhysics2D

For the windows build, I'm running on a windows runner. But when I build, it can't seem to find the mono library -- even though I verified that it was downloaded successfully. I get the following error:

Found Mono root directory: %ProgramFiles%\Mono\desktop-windows-x86_64-release
RuntimeError: Could not find mono library in: %ProgramFiles%\Mono\desktop-windows-x86_64-release\lib:
  File "D:\a\SGPhysics2D\SGPhysics2D\SConstruct", line 716:
    SConscript("modules/SCsub")

EDIT: The prebuilt mono releases from the godot-mono-builds repo is for linux systems only. After cross compiling windows on ubuntu, I'm getting a new error:

/usr/bin/x86_64-w64-mingw32-ld: /home/runner/mono-installs/desktop-windows-x86_64-release/lib/libmonosgen-2.0.a(libmini_la-mini-windows.o):(.text+0x2dc): undefined reference to `__imp_timeGetDevCaps'
/usr/bin/x86_64-w64-mingw32-ld: /home/runner/mono-installs/desktop-windows-x86_64-release/lib/libmonosgen-2.0.a(libmini_la-mini-windows.o):(.text+0x334): undefined reference to `__imp_timeSetEvent'

For the iOS build, I'm getting missing files when I bundle them together using lipo.

fatal error: /Applications/Xcode_13.2.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/lipo: can't open input file: bin/libmonosgen-2.0.iphone.arm64.a (No such file or directory)

EDIT: I ran echo $(basename bin/*) during the bundling step and found out I was building arm instead of arm64, which caused the output to be bin/lipmonosgen-2.0.iphone.arm.a. Right now I'm not sure what the difference is between arm64 and arm, as if I attempt to lipo into one fat.a file, it throws an error saying both have the same architecture of arm64.

For the web build, I'm running on an ubuntu 20.04 runner. But when I build, it get duplicate symbols, which throws this error:

wasm-ld: error: duplicate symbol: getpwnam_r
>>> defined in /home/runner/mono-installs/wasm-runtime-release/lib/libmonosgen-2.0.a(libmini_la-mini-wasm.o)
>>> defined in /home/runner/work/SGPhysics2D/SGPhysics2D/emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libstubs.a(emscripten_libc_stubs.o)

wasm-ld: error: duplicate symbol: getpwuid_r
>>> defined in /home/runner/mono-installs/wasm-runtime-release/lib/libmonosgen-2.0.a(libmini_la-mini-wasm.o)
>>> defined in /home/runner/work/SGPhysics2D/SGPhysics2D/emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libstubs.a(emscripten_libc_stubs.o)

wasm-ld: error: duplicate symbol: getgrnam
>>> defined in /home/runner/mono-installs/wasm-runtime-release/lib/libmonosgen-2.0.a(libmini_la-mini-wasm.o)
>>> defined in /home/runner/work/SGPhysics2D/SGPhysics2D/emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libstubs.a(emscripten_libc_stubs.o)

wasm-ld: error: duplicate symbol: getgrgid
>>> defined in /home/runner/mono-installs/wasm-runtime-release/lib/libmonosgen-2.0.a(libmini_la-mini-wasm.o)
>>> defined in /home/runner/work/SGPhysics2D/SGPhysics2D/emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libstubs.a(emscripten_libc_stubs.o)

wasm-ld: error: duplicate symbol: pthread_sigmask
>>> defined in /home/runner/mono-installs/wasm-runtime-release/lib/libmonosgen-2.0.a(libmini_la-mini-wasm.o)
>>> defined in /home/runner/work/SGPhysics2D/SGPhysics2D/emsdk-cache/emsdk-main/upstream/emscripten/cache/sysroot/lib/wasm32-emscripten/libc.a(pthread_sigmask.o)

EDIT: This was fixed by using EXACTLY Emscripten 1.39.9. I'm building for Godot 3.x for reference, so this may be different for 4.x.

1 Answers

Windows

Windows builds must enable posix threading for BOTH 64 and 32 bit versions of MinGW. Here's the bash commands that do that:

          sudo apt-get install mingw-w64
          echo "1" | sudo update-alternatives --config x86_64-w64-mingw32-gcc
          echo "1" | sudo update-alternatives --config x86_64-w64-mingw32-g++
          echo "1" | sudo update-alternatives --config i686-w64-mingw32-gcc
          echo "1" | sudo update-alternatives --config i686-w64-mingw32-g++

IOS

I made a typo and accidentally built godot using sconsflags arch=arm instead of arch=arm64. This was why lipo couldn't find the arm64 files. On another note, lipo seems to interpret both arm and arm64 builds as arm64, which prevented me from bundling their files together using lipo. I ended up dropping the arm builds -- I'm still not sure if it's significant or not.

Web

Web builds with mono must use exactly Emiscripten 1.39.9. Non mono builds, however, can use the latest version.

Related