Hardening consulting

Release of Accendino 0.6.4

A new version of accendino is out, 0.6.4, available on GitHub and on pypi. As a reminder, accendino is a project that lets you specify how to build a piece of software and its dependencies in a multi-platform way (at least Windows, Linux, partially Mac, a bit of FreeBSD), building it while making the best use of the bricks already installable on the system (if a package is available, we use it, otherwise we build it). It also tries as much as possible to support MinGW, to allow cross-building for Windows from Linux. On the menu: a GitHub action and the associated accendino improvements to easily use accendino in your CI, an emscripten target to compile to WebAssembly, improved cross compilation (tools built for the build machine, macOS for the other architecture), Qt and rust coming in, and as usual a good batch of fixes, especially on Windows.


Accendino in the CI

A GitHub action

This is probably the most handy addition of this release: the accendino repo now ships a GitHub action (the action.yml file) that installs accendino and builds the targets of an accendino file. In a workflow it's simply:

- uses: actions/checkout@v7
- uses: forgiare/accendino@v0.6.4
  with:
    file: freerdp.accendino
    targets: freerdp3
    extra-args: --targetDistrib=mingw64

The big benefit of the action is that it handles caches between runs:

  • the tools directory (emsdk, Qt, meson, ...): it's only saved when its content changed;
  • the ccache cache, which is saved even when the build fails, what was compiled is still useful for the next run;
  • the platform packages installed by accendino (only on Linux with dpkg for now), which avoids spending ages doing apt install on each run.

By default the cache keys are a hash of the file, the targets and the arguments, so each job of a matrix gets its own caches without any configuration. And the prefix output gives where the targets were installed, handy for the next step (tests, packaging, ...).

All these caching features can also be used without the action, through new command line options:

  • --ccache: compiles through ccache (ignored on Windows). For cmake it goes through CMAKE_C_COMPILER_LAUNCHER, for meson and autotools by prefixing CC and CXX, and even with emscripten through EM_COMPILER_WRAPPER;
  • --cachePackage=<dir>: keeps the installed packages in <dir> and installs them from there on the next runs;
  • --pruneTools: removes the tools that aren't used anymore from the tools directory, so that the cache doesn't grow forever.

Easy to build with accendino

An example I like is the CI of qfreerdp_platform. This project needs FreeRDP 3 (and so all its dependencies) and Qt 5 or 6. The ci/qfreerdp_platform.accendino file used to test that is only a few lines long:

include('freerdp')

for version in (5, 6,):
    qfreerdp_tests = []
    if version == 5:
        debQtDeps = ['qtbase5-private-dev', 'qttools5-dev-tools']
        qfreerdp_tests.append('-Dtests=disabled')
    elif version == 6:
        debQtDeps = ['qt6-base-private-dev', 'qt6-tools-dev-tools']

    qfreerdpPkgs = {
        UBUNTU_LIKE: ['libxkbcommon-dev', 'libglib2.0-dev', 'libxrender-dev', 'libudev-dev', 'libfontconfig1-dev', 'libxcursor-dev'] + debQtDeps,
    }

    ARTIFACTS.append(
        MesonBuildArtifact(f'qfreerdp_platform-qt{version}', ['freerdp3'],
            LocalSource('.', do_symlink=True),
            pkgs=qfreerdpPkgs,
            mesonOpts=[f'-Dqt_version=qt{version}', '-Dglobal_install=false'] + qfreerdp_tests,
            provides=['qfreerdp_platform'],
            toolchainArtifacts='c++'
        )
    )

The include('freerdp') pulls the FreeRDP recipe shipped in accendino's pockets, the LocalSource('.') says the project sources are the ones of the CI checkout, and we declare a dependency on freerdp3. That's all: accendino takes care of installing the packages, fetching FreeRDP, building it with its dependencies, and then building the Qt plugin with meson. On the workflow side, a single line per variant is enough:

- name: Test build with Qt5
  run: accendino --prefix=/tmp/qfreerdp_platform --targets=qfreerdp_platform-qt5 --debug ci/qfreerdp_platform.accendino

- name: Test build with Qt6
  run: accendino --prefix=/tmp/qfreerdp_platform --targets=qfreerdp_platform-qt6 --debug ci/qfreerdp_platform.accendino

And with the action, it can become a matrix taking advantage of the caches:

strategy:
  matrix:
    qt: [5, 6]
steps:
  - uses: actions/checkout@v7
  - uses: forgiare/accendino@v0.6.4
    with:
      file: ci/qfreerdp_platform.accendino
      targets: qfreerdp_platform-qt${{ matrix.qt }}

The other example is the CI of accendino itself, which serves as a test bench. The same freerdp.accendino file is built in a matrix where only the arguments change:

- descr: FreeRDP clang build on Ubuntu-24.04
  file: freerdp.accendino
  targets: freerdp3
  extraArgs: --toolchain=clang --options=ci/build-options-ci.ini
- descr: Mingw64 cross build of FreeRDP
  file: freerdp.accendino
  targets: freerdp3
  extraArgs: --targetDistrib=mingw64 --options=ci/build-options-ci.ini
- descr: Emscripten build of FreeRDP's SDL3 client
  file: freerdp.accendino
  targets: freerdp3
  extraArgs: --targetDistrib=emscripten

The ci/build-options-ci.ini options file just forces building FreeRDP from sources:

[freerdp]
fromSources=yes

So with a single recipe, we get a native clang build, a Windows cross-build with mingw and a WebAssembly build, and there's also a native Windows job with MSVC running the same --targets=freerdp3 freerdp.accendino.

What's new in 0.6.4

An emscripten target

With --targetDistrib=emscripten, accendino cross compiles to WebAssembly with emscripten. The initial use case is FreeRDP's SDL3 client running in a browser:

$ accendino --targetDistrib=emscripten --targets=freerdp3 freerdp.accendino

The toolchain uses the emsdk pointed by the EMSDK variable when it's set (like in the emscripten/emsdk docker image), otherwise it installs emsdk in the tools/emsdk directory of the project (you only need git, python3, xz and tar on the machine). The emscripten section of the options file lets you pick the emsdk version, and turn pthreads on or off.

Cross compilation moves forward

When cross compiling, some artifacts need to run programs during their build: protoc for protobuf, wayland-scanner for everything wayland related, ... These programs obviously have to be built for the build machine and not for the target. Artifacts can now declare toolDeps, which are then built for the build machine as native:<name> artifacts, installed in --buildToolsPrefix with the --buildToolchain toolchain. For instance in wlroots.accendino:

MesonBuildArtifact('wlroots', ['wayland-artifact', 'libdrm-artifact', 'xkbcommon-artifact', 'pixman-artifact', 'wayland-protocols-artifact'],
    stdGitSourceFromOptions('wlroots', 'https://gitlab.freedesktop.org/wlroots/wlroots.git', 'master'),
    mesonOpts=['-Dexamples=false', '-Dtests=false'],
    pkgs=wlroots_pkgDeps,
    provides=['wlroots-artifact'],
    # protocol code is generated with wayland-scanner
    toolDeps=['wayland-artifact'],
),

To represent all this cleanly, there's now a Machine object holding the settings of a build target (distribution, architecture, toolchain, prefix, libdir, cross file).

On Mac, you can now also compile for the other architecture: --targetArch=x86_64 on Apple Silicon or --targetArch=arm64 on Intel, arm64 now being a supported architecture.

A goal for a future release is to fully support cross compilation to a completely different architecture than the build host.

Qt and rust

QtInstaller() provides Qt 5 or 6 to the artifacts depending on it, either from the platform packages, or by installing it with aqtinstall in the tools directory when that's not possible (on Windows for instance):

QtInstaller('qt6', flavor=6, version='latest', modules=['qtwebsockets', 'qtmultimedia'])

For the dependent artifacts to find this Qt, an artifact needed to be able to export environment variables to the ones depending on it: that's the exportedEnv() method that can be overridden.

On the rust side, CargoBuildArtifact builds crates, either binaries with cargo install, or libraries with a C API through cargo-c (capi=True), which then installs the libraries, headers and .pc files. Rust can come from the platform packages, or from a rustup toolchain installed in the tools directory (rustVersion='stable' or a specific version). And when cross compiling, the crate is built for the matching rust target (x86_64-pc-windows-gnu, wasm32-unknown-emscripten, ...).

Always more pockets

New accendino files shipped: cef, crashpad (from Sentry's fork), curl, psl, cwalk, dav1d, iconv, libjuice, libwebrtc, libwebrtc-c, libxml2, xerces, msix-packaging, msix-packaging-c, protobuf and protobuf-c. And FreeRDP can now be built with cwalk and dav1d.

Other small options

  • --build-as-debug=<artifacts>: builds the given artifacts in debug mode whatever the build type, quite handy when you want to debug a specific library without rebuilding everything in debug;
  • with --no-packages, the default toolchain is picked from the compilers found in the PATH.

Robustness and fixes

Many fixes are about Windows, the Windows CI helping to find them:

  • fixed pkg-config for native Windows builds: PKG_CONFIG_LIBDIR/PKG_CONFIG_PATH are ; separated, and meson artifacts use pkgconfiglite (meson refuses Strawberry Perl's pkg-config);
  • ACCENDINO_PATH is split with the platform separator, it was always split on :, which broke Windows paths;
  • fixed LocalSource symlinks on Windows, they are also re-linked (and the artifact rebuilt) when the source directory changes;
  • environment variables that change between sessions (<id>_POSIX_FD_STATE of Win32-OpenSSH, PSExecutionPolicyPreference of PowerShell, ...) don't trigger rebuilds anymore;
  • fixed the protobuf-c, libusb, openssl and libwebrtc files for MSVC, and fido2 and FFmpeg linking on Windows;

And elsewhere:

  • meson builds restart from a clean build directory when their settings changed, as meson --reconfigure keeps the programs it found the first time;
  • an artifact whose build failed is prepared again when one of its dependencies was rebuilt since;
  • build logs that aren't UTF-8, or that the console can't print, are shown instead of raising an exception;
  • detection of RHEL clones like Rocky Linux from /etc/os-release;
  • fixed an empty checkout directory after a failed git clone.

Apart from that accendino has been used to build big real projects that explains why it is now more robust and more mature.

Conclusion

With the GitHub action and the caches, accendino becomes really simple to integrate in a CI: a recipe of a few lines and you test your project against FreeRDP master on Linux, Windows, as a mingw cross-build, and now even in WebAssembly. Try it!