Skip to content

Commit af1f10a

Browse files
committed
document incremental compilation in build-on-save guide
1 parent 05f2afe commit af1f10a

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

content/zls/guides/build-on-save.smd

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Once you're done with this, restart your editor (or at least ZLS), **save your f
6767

6868
### Customize build arguments
6969

70-
By default, ZLS will run the equivalent of the following command:
70+
By default, ZLS will try to run the equivalent of the following command:
7171

7272
```
7373
zig build check --watch
@@ -83,6 +83,23 @@ To further customize the build arguments, the `build_on_save_args` config option
8383

8484
Run `zig build --help` to find out what build steps and build options are available in your project.
8585

86+
### Incremental Compilation (experimental)
87+
88+
As of [Zig 0.15.x](https://ziglang.org/download/0.15.1/release-notes.html#toc-Incremental-Compilation), incremental compilation is still under active development:
89+
90+
> Zig 0.15.x makes further progress on the work-in-progress Incremental Compilation functionality, which allows the compiler to perform very fast rebuilds by only re-compiling code which has changed. Various bugs have been fixed, particularly relating to changing file imports.
91+
>
92+
> This feature is still experimental—it has known bugs and can lead to miscompilations or incorrect compile errors. However, it is now stable enough to be used reliably in combination with `-fno-emit-bin`.
93+
94+
Because the previously mentioned "check" step only reports compile errors without emitting code, it integrates well with incremental compilation:
95+
96+
To try it out:
97+
- Ensure that your project defines a "check" step
98+
- Do **not** enable the `enable_build_on_save` config option
99+
- Set `"build_on_save_args": ["-fincremental"]`
100+
101+
Restart ZLS and review the [log output](/zls/guides/view-logs) to ensure there are no errors and that the config options were applied correctly. At this point, compile errors should appear *almost* instantly as you make changes.
102+
86103
## Special Thanks
87104

88105
This Guide is based on the ["Improving Your Zig Language Server Experience"](https://kristoff.it/blog/improving-your-zls-experience/) Blog Post by Loris Cro.

0 commit comments

Comments
 (0)