diff options
Diffstat (limited to 'build.zig')
| -rw-r--r-- | build.zig | 62 |
1 files changed, 39 insertions, 23 deletions
@@ -70,30 +70,32 @@ pub fn build(b: *std.Build) void { .cpu_model = .{ .explicit = &std.Target.riscv.cpu.generic_rv32 }, .cpu_features_add = riscvFeatures(&.{ .m, .a, .f, .c, .zicsr, .zifencei }), }; - const requested_target = b.standardTargetOptions(.{ .default_target = switch (platform) { - .macos => if (builtin.os.tag.isDarwin()) .{ - .cpu_arch = builtin.target.cpu.arch, - .os_tag = .macos, - .os_version_min = .{ .semver = macos_min_version }, - } else .{}, - // The P4 firmware target, spelled out here so `-Dplatform=p4` alone is a - // working command line. The CPU FEATURES are part of that spelling and - // are not optional: the object this build emits is linked into an image - // whose other halves are compiled `generic_rv32+m+a+f+c+zicsr+zifencei`, - // and `f` decides the float ABI. Leaving the model implicit produced a - // soft-float object and `ld.lld: cannot link object files with different - // floating-point ABI` — at LINK time in the other repo, far from here. - // Espressif's GCC adds the vendor extensions xesploop/xespv2p1 on top; - // upstream LLVM has neither and ordinary code never emits them, so this - // matches the base ISA the firmware uses exactly. - .p4 => p4_target, - .tty, .gui, .web => .{ - .cpu_arch = .x86_64, - .os_tag = .linux, - .abi = .gnu, - .glibc_version = .{ .major = 2, .minor = 38, .patch = 0 }, + const requested_target = b.standardTargetOptions(.{ + .default_target = switch (platform) { + .macos => if (builtin.os.tag.isDarwin()) .{ + .cpu_arch = builtin.target.cpu.arch, + .os_tag = .macos, + .os_version_min = .{ .semver = macos_min_version }, + } else .{}, + // The P4 firmware target, spelled out here so `-Dplatform=p4` alone is a + // working command line. The CPU FEATURES are part of that spelling and + // are not optional: the object this build emits is linked into an image + // whose other halves are compiled `generic_rv32+m+a+f+c+zicsr+zifencei`, + // and `f` decides the float ABI. Leaving the model implicit produced a + // soft-float object and `ld.lld: cannot link object files with different + // floating-point ABI` — at LINK time in the other repo, far from here. + // Espressif's GCC adds the vendor extensions xesploop/xespv2p1 on top; + // upstream LLVM has neither and ordinary code never emits them, so this + // matches the base ISA the firmware uses exactly. + .p4 => p4_target, + .tty, .gui, .web => .{ + .cpu_arch = .x86_64, + .os_tag = .linux, + .abi = .gnu, + .glibc_version = .{ .major = 2, .minor = 38, .patch = 0 }, + }, }, - } }); + }); // `standardTargetOptions` honours `default_target` ONLY when `-Dtarget` is absent, so the // documented `-Dplatform=p4 -Dtarget=riscv32-freestanding` discarded the CPU features above and // silently produced a soft-float object. The features are not a preference here - `f` decides @@ -346,6 +348,20 @@ pub fn build(b: *std.Build) void { opts.addOption(bool, "enable_tracy", tracy != null); opts.addOption(bool, "zls_backend", zls_backend); opts.addOption(bool, "mupdf", enable_mupdf); + // THE BOARD'S GRID, a build option because the right size is a measurement rather than a + // constant, and because two independent things limit it. + // + // LATENCY binds first, and linearly: every frame walks the whole grid, at 0.87 us per cell + // measured on the die. 56x14 is 784 cells and a 3,930 us round trip - 63% more area and 40% more + // width than the 40x12 it replaces, and still inside the 4 ms this port was built to hold. 56x16 + // was tried first and measured 4,029, which is over; 80x24 works and costs 4,809. The full curve + // is in `05-zig-p4/experiments/report.typ`. + // + // MEMORY binds much later, and only since vaxis's two unused grids stopped being allocated: + // 140x42 runs, 160x48 links and then traps, and 200x60 does not link at all - `.bss will not fit + // in region l2mem, overflowed by 76036 bytes`, that being the shell's shadow copy of the grid. + opts.addOption(u16, "p4_cols", b.option(u16, "p4-cols", "board grid width in cells (p4 only)") orelse 56); + opts.addOption(u16, "p4_rows", b.option(u16, "p4-rows", "board grid height in cells (p4 only)") orelse 14); // Meaningful only for the SDL shell. Keeping the platform condition here // prevents Config/EffectCode from describing tty/macOS/web as "prebuilt". opts.addOption(bool, "gui_shader_sources_prebuilt", gui_shader_sources_prebuilt); |
