Skip to content

搞英语 → 看世界

翻译英文优质信息和名人推特

Menu
  • 首页
  • 作者列表
  • 独立博客
  • 专业媒体
  • 名人推特
  • 邮件列表
  • 关于本站
Menu

新的 Zig 0.14 编译器功能 -fincremental –watch

Posted on 2025-03-20

介绍

新Zig 0.14中发布的两大功能是增量编译和 x86 后端(无 LLVM)。

增量编译+文件系统观察

阅读此处了解增量编译
阅读此处有关文件系统观察的内容
(抱歉,我懒得重复其他资源涵盖的内容)

x86 后端

在这里阅读
(再次抱歉……哈哈)

构建.zig

这是我的 build.zig:构建-zig-01

注意:注意紫色箭头和矩形。

完整代码:

 const std = @import("std"); const ctPrint = std.fmt.comptimePrint; pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); // List of Zig files in the programs/ directory const programs = [_][]const u8{ "main_add", "test_zigMaster_014", }; // Loop through each program and create exec inline for (programs) |program| { // Comptime program path const program_path = comptime ctPrint("programs/{s}.zig", .{program}); const exe = b.addExecutable(.{ .name = program, .root_source_file = b.path(program_path), .target = target, .optimize = optimize, .use_llvm = false, }); b.installArtifact(exe); const run_cmd = b.addRunArtifact(exe); run_cmd.step.dependOn(b.getInstallStep()); if (b.args) |args| { run_cmd.addArgs(args); } // Comptime step name and description const run_step_name = comptime ctPrint("run-{s}", .{program}); const run_step_desc = comptime ctPrint("Run the {s} program", .{program}); const run_step = b.step(run_step_name, run_step_desc); run_step.dependOn(&run_cmd.step); } const test_step = b.step("test", "Run tests for all programs"); inline for (programs) |program| { // Comptime program path const program_path = comptime ctPrint("programs/{s}.zig", .{program}); const test_exe = b.addTest(.{ .root_source_file = b.path(program_path), .target = target, .optimize = optimize, .use_llvm = false, }); const run_test_cmd = b.addRunArtifact(test_exe); test_step.dependOn(&run_test_cmd.step); } }

观看-fincremental –观看实际操作

Zig-build-watch-01

主要亮点:

  1. 紫色箭头:运行命令zig build -fincremental --watch
  2. 黄色矩形:初始构建 ~ 请注意我的两个 Zig 文件各花费约 700 毫秒的时间。
  3. 绿色矩形:增量构建,每当您进行更改并保存文件时都会自动完成。 -> 请注意,只花了大约 50 毫秒 –> 令人惊叹的 fwast!

增量编译加速的更多证据

  • 来自 0.14 发行说明:Zig-build-watch-02 ==从 14 秒到 63 毫秒==

  • 来自 Jetzig 文档:jetzig 增量加速 ==从 16 秒到 139 毫秒==
    如果您想阅读来源: Jetzig 博客

结论

就这样,这真是太神奇了不是吗?更重要的是,这些功能还没有完全成熟,所以下一个 Zig 版本 0.15 / 0.16 将会有更多的性能改进。这些功能的组合对于那些从事需要快速迭代的工作的人(尤其是游戏开发人员)来说至关重要。

我 10 岁的女儿正在使用 Godot 开发一款游戏,目前每次调试编译需要 20 秒。这 20 秒的延迟很烦人,而且确实破坏了动力。我想知道Mach(Zig游戏引擎)是否可以通过这种增量编译在亚秒内完成编译,我们不妨迁移到Mach?我们会看到…

原文: https://hwisnu.bearblog.dev/new-zig-014-compiler-features-fincremental-watch/

本站文章系自动翻译,站长会周期检查,如果有不当内容,请点此留言,非常感谢。
  • Abhinav
  • Abigail Pain
  • Adam Fortuna
  • Alberto Gallego
  • Alex Wlchan
  • Answer.AI
  • Arne Bahlo
  • Ben Carlson
  • Ben Kuhn
  • Bert Hubert
  • Bits about Money
  • Brian Krebs
  • ByteByteGo
  • Chip Huyen
  • Chips and Cheese
  • Christopher Butler
  • Colin Percival
  • Cool Infographics
  • Dan Sinker
  • David Walsh
  • Dmitry Dolzhenko
  • Dustin Curtis
  • eighty twenty
  • Elad Gil
  • Ellie Huxtable
  • Ethan Dalool
  • Ethan Marcotte
  • Exponential View
  • FAIL Blog
  • Founder Weekly
  • Geoffrey Huntley
  • Geoffrey Litt
  • Greg Mankiw
  • Henrique Dias
  • Hypercritical
  • IEEE Spectrum
  • Investment Talk
  • Jaz
  • Jeff Geerling
  • Jonas Hietala
  • Josh Comeau
  • Lenny Rachitsky
  • Liz Danzico
  • Lou Plummer
  • Luke Wroblewski
  • Matt Baer
  • Matt Stoller
  • Matthias Endler
  • Mert Bulan
  • Mostly metrics
  • News Letter
  • NextDraft
  • Non_Interactive
  • Not Boring
  • One Useful Thing
  • Phil Eaton
  • Product Market Fit
  • Readwise
  • ReedyBear
  • Robert Heaton
  • Rohit Patel
  • Ruben Schade
  • Sage Economics
  • Sam Altman
  • Sam Rose
  • selfh.st
  • Shtetl-Optimized
  • Simon schreibt
  • Slashdot
  • Small Good Things
  • Steve Blank
  • Taylor Troesh
  • Telegram Blog
  • The Macro Compass
  • The Pomp Letter
  • thesephist
  • Thinking Deep & Wide
  • Tim Kellogg
  • Understanding AI
  • Wes Kao
  • 英文媒体
  • 英文推特
  • 英文独立博客
©2025 搞英语 → 看世界 | Design: Newspaperly WordPress Theme