authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-05-10 11:34:19+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-05-18 17:10:04+01:00
log6d7c89cb40e3a36f99c82400084aa59df27f6573
tree9674c4ab45a5c1c2e984e5528cd23e7e5dc35239
parente26c326996c315a6ed912a2d5fbe7a4f04982c69
signaturelock-open Commit is signed but in an unrecognized format.

build.zig: use correct module graph for compiler unit tests


1 files changed, 11 insertions(+), 6 deletions(-)

build.zig+11-6
......@@ -508,11 +508,9 @@ pub fn build(b: *std.Build) !void {
508508 test_step.dependOn(unit_tests_step);
509509
510510 const unit_tests = b.addTest(.{
511 .root_module = b.createModule(.{
512 .root_source_file = b.path("src/main.zig"),
511 .root_module = addCompilerMod(b, .{
513512 .optimize = optimize,
514513 .target = target,
515 .link_libc = link_libc,
516514 .single_threaded = single_threaded,
517515 }),
518516 .filters = test_filters,
......@@ -520,6 +518,9 @@ pub fn build(b: *std.Build) !void {
520518 .use_lld = use_llvm,
521519 .zig_lib_dir = b.path("lib"),
522520 });
521 if (link_libc) {
522 unit_tests.root_module.link_libc = true;
523 }
523524 unit_tests.root_module.addOptions("build_options", exe_options);
524525 unit_tests_step.dependOn(&b.addRunArtifact(unit_tests).step);
525526
......@@ -650,7 +651,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
650651 update_zig1_step.dependOn(&copy_zig_h.step);
651652}
652653
653const AddCompilerStepOptions = struct {
654const AddCompilerModOptions = struct {
654655 optimize: std.builtin.OptimizeMode,
655656 target: std.Build.ResolvedTarget,
656657 strip: ?bool = null,
......@@ -659,7 +660,7 @@ const AddCompilerStepOptions = struct {
659660 single_threaded: ?bool = null,
660661};
661662
662fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.Step.Compile {
663fn addCompilerMod(b: *std.Build, options: AddCompilerModOptions) *std.Build.Module {
663664 const compiler_mod = b.createModule(.{
664665 .root_source_file = b.path("src/main.zig"),
665666 .target = options.target,
......@@ -682,10 +683,14 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.St
682683 compiler_mod.addImport("aro", aro_mod);
683684 compiler_mod.addImport("aro_translate_c", aro_translate_c_mod);
684685
686 return compiler_mod;
687}
688
689fn addCompilerStep(b: *std.Build, options: AddCompilerModOptions) *std.Build.Step.Compile {
685690 const exe = b.addExecutable(.{
686691 .name = "zig",
687692 .max_rss = 7_800_000_000,
688 .root_module = compiler_mod,
693 .root_module = addCompilerMod(b, options),
689694 });
690695 exe.stack_size = stack_size;
691696