Working on a github action and could use some help

TL;DR: We’re trying to automate the building of Windows MSIs using cerbero in a github action while trying to leverage the standard windows-latest image rather than a self-hosted real machine. The work is over here in case anyone is interested in doing the same thing or already has. If you have interest in doing this, feel free to have a look; my efforts are on the 1.24-lldc-btg-testing branch. Our current issue is that x264 seems to generate bad files in configure and then fail at compile time, but the logs and source directory artifact are not illuminating the problem, and I could use some help if anyone has seen the issue.

We also maintain a fork on github of cerbero, and I have been adding a few small patches as I try to push this effort forward, but I’m hitting a lot of odd snags that we don’t see when trying to build in our command line environment or using a self-hosted runner. I would be happy to go into some of those details, but the current hiccup is that the x264 library fails to compile, like this:

  Running command ['C:/mingw64/bin/make.EXE', 'V=1'] in C:/a/cerbero-action/cerbero-action/cerbero/cerbero-build/sources/msvc_x86_64/x264-20191217-2245
  cat common/opencl/x264-cl.h common/opencl/bidir.cl common/opencl/downscale.cl common/opencl/weightp.cl common/opencl/intra.cl common/opencl/subpel.cl common/opencl/motionsearch.cl | ./tools/cltostr.sh common/oclobj.h
  dependency file generation...
  x86_64-w64-mingw32-gcc.exe: error: macro name missing after '-D'
  x86_64-w64-mingw32-gcc.exe: fatal error: no input files
  compilation terminated.
  make.EXE: *** [Makefile:314: .depend] Error 1

The log doesn’t give any extra information beyond that and the source directory saved off from the failure doesn’t show any -D... args that are missing names. For example, the config.mak shows all CFLAGS args are fully formed.

Out of the other forks on github, I’ve seen that AMDGlobal has a github action defined but it’s unclear if it’s working at all for them since there’s no actions history posted (I tried replicating it; it did not work for me but it had a similar initial error as my first attempt).

Much of what I’ve dealt with is msys2 configuration. The default windows-latest base image that Microsoft/GitHub puts out already contains msys2 at the usual c:\msys64 location but it’s not on the PATH. Trying to directly use it by adding a step to expose that to the GITHUB_PATH has the odd effect of seeing things like cerbero-uninstalled “succeed” without doing anything – no errors logged, etc. It just quits. My action deletes that and uses the github action for installing MSYS2. This causes it to install in a non-standard location, but it’s visible from the path, so I modified cerbero to identify the parent directory of msys2.exe when it’s trying to find the MSYS installation.

Another gotcha was that the image by default contains Python 3.9, but has readily available newer versions. Cerbero only enforces 3.7 even though it uses a glob feature introduced in 3.10, which causes it to error out. I patched that in our local branch as well, and per the actions/setup-python and windows-latest design, using that action allows one to upgrade python “in place” to >=3.10 without causing some shadow/extra installation of python to exist in the image.

Another python-related thing is that the expectation that there will be a Scripts directory doesn’t seem to get met in the windows runner, which causes the attempt to delete that directory to fail after trying to move everything into bin. Patch here. I’ve tried looking up the commits related to that and I know there’s some obscure convention for why Scripts vs. bin, but what I have not found is why cerbro is having this hard expectation that by the time it arrives at that line of code that there will in-fact be a Scripts/... directory present on the system. It leaves me wondering if some other script/code generation was supposed to happen but was skipped, leading to a lot of this other mess. I see this issue by @nirbheek; I suspect it is related, but it is also clear that investigation is still in progress by @amyspark.

Similarly, the version of Perl in windows-latest appears to cause problems that can be mitigated by amending the actions/setup-msys2 to install perl.

The cerbero-defined version of wavpack also fails to build because of some interaction between ninja, cmake, that produces a bad $-escape error message (issue here). Bumping the version of wavpack to 5.7 solves that but I don’t see why from the change lists between versions. Credit to @jawilson for this patch.

All of these changes got me to where I’m at now, where x264 fails on an apparent file generation problem likely during the configure step but with no apparent build artifact pointing directly at the issue.

Assuming we get this figured out, I do plan to upstream any necessary changes to cerbero, but I’m holding off until the dust settles enough to where pointing the action at the upstream gitlab cerbero repository works.

Thank you for taking the time to read this.

Hi! some assorted questions:

Scripts directory doesn’t seem to get met in the windows runner

Do you know the ABI of the Python version you’re using? i.e. python3 -c "import sys; print(sys.version)"

“succeed” without doing anything – no errors logged, etc

That’s an usual sign of DLL loading errors (which do not get logged anywhere). When invoking cerbero-uninstalled we rely on it being installed on C:/, D:/, or having a shortcut available in the Windows menu. (Alternatively, you may want to try including both C:/msys64/ucrt64/bin as well as the native bin folder, but YMMV)

but the current hiccup is that the x264 library fails to compile, like this:

I ported x264 to Meson some while ago, can you check with a later version of Cerbero?

Thank you @amyspark! It looks like we need to update our fork to get that x264 change; I cherry-picked it and it made a difference.

Now the build is failing while compiling libiconv, trying to expand the INSTALLDIR macro with a windows path (it’s configured as -DINSTALLDIR=C:/<github runner temp path> and it should have been wrapped in double quotes).

I do not know the ABI of the python version, but Python 3.13.2 is being installed.

The next trip-up was libiconv’s libcharset. The github action setup-msys2, windows-2022 relationship seemed to have some combination of autotools that both correctly configured libiconv and misconfigured its included libcharset library in such a way that the INSTALLDIR macro was being set to the path wrapped in quotes (correct) and stripping the quotes off the path for the internal library, causing a C compiler error. The fix in this case was to ensure a more complete/up-to-date version of autotools was installed by appending the setup-msys2:install input with mingw-w64-ucrt-x86_64-autotools.

Another gotcha along the way was the actions/upload-artifact action couldn’t retrieve the builddir for me upon failure. It would identify files to copy into the archive and then fail to copy them because each was “not found”. I suspected they were symlinks, however locally, they were real files. As it turns out that’s the default behavior, creating deep copies of files rather than symlinks. Adding a step to the cerbero-action to do this (via powershell) seems to have made the actions/upload-artifact work now:

Add-Content "C:\msys64\ucrt64.ini" "`nMSYS=winsymlinks:nativestrict"