I am using zigs build system as the second compilation step in a programming language called Acton. The actonc compiler generates C code which is then compiled by zig (cc). All Acton projects have the same structure so we can use the same build.zig. zig build actually takes some time to build build.zig into build, often several seconds. When actonc is compiling a single .act file, there is no persistent zig-cache, so taking a 5 second hit isn't acceptable. I put together a solution now where I prebuild build.zig by just building it once, grabbing the output build file in zig-cache. I then directly invoke this program the same way zig build does, providing build dir, caches etc from actonc.
My issue is that zig build builds build.zig with optimizations for the native CPU features and that means it's not very portable. The way I prebuild it, and place it in the Acton distribution which can be installed on other computers, it will SIGILL when run on a computer with older CPU than it was built on.
I skimmed cpuBuild in main.zig and noticed I can't modify the cpu stuff. I wonder if I can manually invoke zig build-exe perhaps with some magic arguments or so to build build.zig? That way I could specify -Dcpu=x86_64 for example to use base feature set, right.