Skip to content

build: use zig in every module and run prek in CI - #4

Merged
michaelboulton merged 3 commits into
mainfrom
build/zig-toolchains-and-prek
Oct 25, 2026
Merged

michaelboulton merged 3 commits into
mainfrom
build/zig-toolchains-and-prek

Conversation

@michaelboulton

Copy link
Copy Markdown
Owner

Builds every module with the zig C toolchain and host make, and adds a GitHub Actions workflow that runs the pre-commit hooks with prek.

Click for implementation details
  • Register hermetic_cc_toolchain in luaunit and busted as a dev dependency. Register the glibc 2.28 zig toolchains ahead of the glibc 2.17 default in the root, examples and luaunit. The host toolchain on new distros fails to build BCR C deps: GNU ld 2.47 segfaults on --start-lib, and glibc 2.44 headers break old gnulib.
  • Use the host make (tools.make(mode = "system")) in luaunit and busted, as building make from source runs hundreds of slow autoconf actions.
  • Patch the Lua 5.4.6 makefile to build without readline. BCR readline pulls in ncurses, sed and rules_cc_autoconf, whose configure checks run as hundreds of Bazel actions per configuration.
  • Fix the existing buildifier, buildifier-lint and prettier findings so the workflow passes on all files, and regenerate docs.
  • Disable the name-conventions and bzl-visibility lint checks: LuaLibrary and FennelLibrary are public API, and luaunit and fennel load //lua/private on purpose.
  • The luaunit and busted lockfile updates from the first commit landed in the second one.

Tested on Bazel 9.3.1: root bazel test //... (9 tests), examples (3), luaunit//tests:all (2), busted//tests:all (1), and prek run --all-files. Not tested on Bazel 8.

Register hermetic_cc_toolchain in luaunit and busted as a dev dependency, and register the glibc 2.28 zig toolchains ahead of the glibc 2.17 default in the root, examples and luaunit. The host toolchain on new distros fails to build BCR C deps: GNU ld 2.47 segfaults on --start-lib, and glibc 2.44 headers break old gnulib.

Use the host make in luaunit and busted, as building make from source runs hundreds of slow autoconf actions.

Patch the Lua 5.4.6 makefile to build without readline, so the toolchain needs no host readline headers.
Add a GitHub Actions workflow that runs prek on all files.

Fix the existing buildifier and prettier findings: sort loads, add module and function docstrings, remove an unused helper and variable, trim trailing whitespace, and regenerate docs.

Disable the name-conventions and bzl-visibility lint checks, as LuaLibrary and FennelLibrary are public API, and luaunit and fennel load //lua/private on purpose.
Comment on lines +11 to +15
-MYCFLAGS= $(LOCAL) -std=c99 -DLUA_USE_LINUX -DLUA_USE_READLINE
+MYCFLAGS= $(LOCAL) -std=c99 -DLUA_USE_LINUX
MYLDFLAGS= $(LOCAL) -Wl,-E
-MYLIBS= -ldl -lreadline
+MYLIBS= -ldl

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

Might cause some problems but this speeds up the build a loooot

Set require_serial on the buildifier hooks, as parallel batches race to download the buildifier binary on a cold cache and fail with "mv: cannot create regular file ... File exists".
@michaelboulton
michaelboulton merged commit aa1bebb into main Oct 25, 2026
1 check passed
@michaelboulton
michaelboulton deleted the build/zig-toolchains-and-prek branch October 25, 2026 16:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant