Apr 06,
2022

Wasting someone else's CPU time

Greetings Interweb neighbors,

Emacs 28 dropped, but I'm not building it. I'm building tomorrow's Emacs on someone else's power bill.

Native compilation via libgccjit made the stable cut, what was left out is pure GTK support for Wayland. Since I'm on Wayland, I'm tracking the dev branch where it lives, which means frequent rebuilds of bleeding-edge snapshots. PGTK gives native Wayland support without the XWayland compatibility layer overhead.

GitHub offers 2000 minutes monthly of free CI/CD compute. Time to automate Debian package builds for Bullseye.

The beauty of delegation

My desktop is faster to build it, but where's the satisfaction in that? Instead, GitHub Actions spins up a fresh container, installs dependencies, compiles libgccjit support, builds native .eln files, packages to .deb, uploads artifacts.

Build takes 45 minutes on their infrastructure, zero noise from my machine. Ephemeral compute: servers spin up, do work, vanish.

The setup

Dockerfile does the usual: builds on Bullseye, installs a mountain of dev dependencies (libgccjit-10-dev, libgtk-3-dev, libwebkit2gtk-4.0-dev, etc.), copies in the Emacs source tree, then:

RUN cd emacs && ./configure \
    --prefix "/usr" \
    --with-native-compilation \
    --with-pgtk \
    --with-xwidgets \
    --with-json \
    --with-modules \
    CFLAGS="-O2 -pipe -fomit-frame-pointer" && \
    make NATIVE_FULL_AOT=1 -j $(nproc)

GitHub Actions workflow:

name: Build package

on:
  workflow_dispatch:
  push:
    branches:
      - main

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
    - name: Checkout repository
      uses: actions/checkout@v3

    - name: Build package
      run: ./build.sh

    - name: Store package
      uses: actions/upload-artifact@v3
      with:
        name: emacs-pgtk
        path: ./packages/emacs-pgtk_*.deb

For the curious reader, all the gory details at github.com/ndrvtl/emacs-pgtk.

After build, manually construct .deb package structure: create DEBIAN/control, strip binaries, pack with dpkg-deb. More control, more tedium.

Smoketest runs apt-get install on built package, verifies emacs --version works. If it fails, workflow goes red. GitHub's problem to tell me.

The real win

Automated builds mean latest dev snapshots always packaged, ready to install. Push to branch, wait 45 minutes, download .deb. No local toolchain noise. No fan spin. No interrupted workflow.

Native compilation is sensibly fast. Pure GTK support works well. But the satisfaction isn't the software — it's having someone else's infrastructure do the work while I drink tea.

Long live free compute, never mind the warming planet. They get metrics, I get watts. Everyone loses.