With build.zig, you can use -Dtarget=aarch64-linux and such for easy cross compilation to a single target. Is there some idiom to compile to many targets at the same time?
I can run zig build several times, for each target I need, but that’s not parallel.
I can for(targets)insidebuild.zig to create a step per target and tie them all into build install command, but that requires somewhat non-trivial refactor of build.zig.
Is there some way to take a trivial build.zig generated by zig init-exe, and somehow make that compile to a bunch of targets simultaneosly in a single command in parallel?
I don’t know if there’s a command like that. So, this doesn’t answer your question, but here’s how I’d make a trivial cross-compiling build.zig example:
Hm, I think this needs something else to avoid name clash in the install dir? As written, I think linux and mac binaries would both race to overwirte zig-out/bin/exe?
We could update the build_runner to accept multiple targets and then invoke the build fn for each one. This could also be generalized to any set of build options, i.e.
This would be equivalent to invoking zig build twice we each set of corresponding options. The advantage of this over executing zig build each time is you can take full advantage of zig build’s parallelism. Seems like a feature worth considering.