Are C libraries recompiled during every zig build?

After seeing videos about the speed of -fincremental, i decided to give it a try but I could not manage any improvement on my side. Could it be because my project contains C libraries?

Just to be sure, I cloned the zig-webui repo to build its examples using -fincremental:

> zig build examples -fincremental --summary all                                                                                   
Build Summary: 24/24 steps succeeded
examples cached
├─ install call_js_from_zig cached
│  └─ zig build-exe call_js_from_zig Debug native success 32s MaxRSS:172M
│     ├─ WriteFile webui.h cached
│     ├─ zig build-lib webui Debug native success 441ms MaxRSS:24M
│     ├─ zig build-lib webui Debug native (reused)
│     ├─ WriteFile webui.h (reused)
│     ├─ zig build-lib webui Debug native (reused)
│     ├─ zig build-lib webui Debug native (reused)
│     └─ options cached
├─ install call_zig_from_js cached
│  └─ zig build-exe call_zig_from_js Debug native success 32s MaxRSS:176M
│     ├─ WriteFile webui.h (reused)
...

Running the cmd zig build examples -fincremental a few times (without modifying any of the .zig files) did not improve the compilation time, which stays around 30 sec.

I was thinking that I would see a lot more cached instead of success, and I wondered if this is due to the step:

...
│     ├─ zig build-lib webui Debug native success 441ms MaxRSS:24M
...

which is, I believe, about the webui C library.

Am I missing something about the use of -fincremental? I am testing on a Windows OS btw.

2 Likes

Incremental compilation is only supported with the native (non-llvm) backend.
You can disable llvm by passing .use_llvm = false to your addExecutable options in your build.exe.

However so far it seems that not everything is supported in the x86 backend yet, in particular vectors are the big problem for my project. So you can probably expect some errors.

6 Likes

Thanks for the explanation. I must have missed that info.
The compilation fails at the moment when using .use_llvm=false, but no worries, I’ll wait for the x86 backend :+1: