← 返回 Siami 首頁

Zig 建構系統大幅重構 將 maker 程序與 configurer 程序分離

▲ 130 💬 32
Zig 建構系統大幅重構 將 maker 程序與 configurer 程序分離

Zig 語言創辦人 Andrew Kelley 宣布重大重構:將建構系統的「配置器」與「執行器」分離。過去,build.zig 檔案與整個建構系統實作都被編譯成一個龐大的程序,浪費資源。現在 build.zig 會先被編譯成一個小巧的「配置器」,其產生的建構圖序列化為二進位設定檔快取;同時,系統會非同步地以發行模式編譯「執行器」程序。這樣執行器每個 Zig 版本只需編譯一次,大幅節省時間。此次重構帶來三層加速:修改 build.zig 時只需重新編譯使用者代碼,而非整個建構系統;系統可跳過未變動的建構邏輯,直接使用快取的設定檔;執行器以優化模式編譯,速度更快。實測顯示 zig build —help 從平均 150ms 降至 14.3ms,提速約 90%。主要破壞性變更是 b.args 被移除,改為 addPassthruArgs(),未來建構腳本將無法直接觀測命令列參數。Zig 0.17.0 預計於數週內發布。

網友熱門留言 (5)

#1 brabel ▲ 1
I just upgraded some code to Zig 0.16.0 and I am actually really happy with the results. It impacted A LOT of things, but the changes were actually very good and seems to have set the language for a bright future, especially with the new IO mechanism which allows supper efficient code that looks good whether it's implemented single-threaded, multi-threaded or just via an event loop! If you haven't tried Zig since 0.16.0 was released, I highly recommend having a look. The release notes for this release were huge!!
#2 ulbu ▲ 1
the '(super) efficient' is not there yet. Io is still dynamic dispatch with multiple layers of indirection. afaik it's slower than before. the upcoming releases are expected to provide a solution to this 'dispatch is comptime-known, but still dynamic' problem, and drop the loses in efficiency.
#3 bbkane ▲ 1
Hmm in the 2025 talk, Andrew emphasizes that this approach is more efficient than before- even showing compiled assembly iirc. I guess that was a one-off?
#4 chaz72 ▲ 1
My guess is that one of these (Andrew) is measuring syscalls and the other is measuring vtable indirections.
#5 veglen ▲ 1
This is why I love Zig - they continue to make significant improvements to the build system while many languages stagnate. The performance improvements here are impressive and the approach of separating configurer from maker is elegant.