Why is incremental compilation taking so long in the install step?

I noticed that unlike what gets shown in the terminal (around 33 ms), the actual time feels more like half a second, and indeed when looking at it with --time-report I can see
Screenshot at 2026-10-05 20-40-32

What’s the install step even doing, apart from copying the output binary to the install location? How can that be so slow?

In my build.zig it also only depends on the exe installArtifact:

const installExe = b.addInstallArtifact(exe, exeInstallOptions);
b.getInstallStep().dependOn(&installExe.step);

What is the size of that binary?

I had a similar issue at some point on master. It was a bug in the linker that produced huge binary (since fixed, but maybe you have a similar issue?).
The install step of linux uses install command line utility (-D flag maybe) that does a checksum before copying (in the spirit I’d avoiding said copy if the file is unchanged.

Irony is on a few hundreds megabytes and (at least my) ssd drive, raw cp was extremely faster than computing both target and destination hashes.

Maybe use zig build --verbose to check the actual command used and reproduce it manually to confirm if it’s the same symptoms.

Yeah, looks like it’s just copying that one file:

... (zig build-exe)
info(verbose): install -C .zig-cache/o/db1a2d060fb3f1ad82e73c3b48d91097/Cubyz zig-out/bin/Cubyz
(end of stream)

Weirdly though copy-pasting this command only yields ~120 ms, even when removing the output file to force a re-copy (actually when I remove the file, then rebuild in Zig it also only shows 160 ms, so I guess it depends on the context).
Raw cp takes around 200 ms for me.

282 MB
Just wanted to compare it without incremental, and somehow it’s even bigger with 500 MB???
But with llvm it’s only 55 MB (which is more reasonably, given that Cubyz links about 51 MB of static C libraries).

So I guess congrats, copying the binary is your compile bottleneck as well now :sweat_smile:.

Honestly it’s a tribute to incremental wild efficiency.

I noticed as well incremental output being smaller than “normal” link. I don’t know if it’s just better organised binary of maybe some debug info not being present in the incremental version.

One option can be to declare a run step directly depending in the compile step instead of the install one, so you can launch the app without paying the copy cost. Really wild to me to have this kind of concerns. Exciting times!