| ... | @@ -508,11 +508,9 @@ pub fn build(b: *std.Build) !void { | ... | @@ -508,11 +508,9 @@ pub fn build(b: *std.Build) !void { |
| 508 | test_step.dependOn(unit_tests_step); | 508 | test_step.dependOn(unit_tests_step); |
| 509 | | 509 | |
| 510 | const unit_tests = b.addTest(.{ | 510 | const unit_tests = b.addTest(.{ |
| 511 | .root_module = b.createModule(.{ | 511 | .root_module = addCompilerMod(b, .{ |
| 512 | .root_source_file = b.path("src/main.zig"), | | |
| 513 | .optimize = optimize, | 512 | .optimize = optimize, |
| 514 | .target = target, | 513 | .target = target, |
| 515 | .link_libc = link_libc, | | |
| 516 | .single_threaded = single_threaded, | 514 | .single_threaded = single_threaded, |
| 517 | }), | 515 | }), |
| 518 | .filters = test_filters, | 516 | .filters = test_filters, |
| ... | @@ -520,6 +518,9 @@ pub fn build(b: *std.Build) !void { | ... | @@ -520,6 +518,9 @@ pub fn build(b: *std.Build) !void { |
| 520 | .use_lld = use_llvm, | 518 | .use_lld = use_llvm, |
| 521 | .zig_lib_dir = b.path("lib"), | 519 | .zig_lib_dir = b.path("lib"), |
| 522 | }); | 520 | }); |
| | 521 | if (link_libc) { |
| | 522 | unit_tests.root_module.link_libc = true; |
| | 523 | } |
| 523 | unit_tests.root_module.addOptions("build_options", exe_options); | 524 | unit_tests.root_module.addOptions("build_options", exe_options); |
| 524 | unit_tests_step.dependOn(&b.addRunArtifact(unit_tests).step); | 525 | unit_tests_step.dependOn(&b.addRunArtifact(unit_tests).step); |
| 525 | | 526 | |
| ... | @@ -650,7 +651,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void { | ... | @@ -650,7 +651,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void { |
| 650 | update_zig1_step.dependOn(&copy_zig_h.step); | 651 | update_zig1_step.dependOn(&copy_zig_h.step); |
| 651 | } | 652 | } |
| 652 | | 653 | |
| 653 | const AddCompilerStepOptions = struct { | 654 | const AddCompilerModOptions = struct { |
| 654 | optimize: std.builtin.OptimizeMode, | 655 | optimize: std.builtin.OptimizeMode, |
| 655 | target: std.Build.ResolvedTarget, | 656 | target: std.Build.ResolvedTarget, |
| 656 | strip: ?bool = null, | 657 | strip: ?bool = null, |
| ... | @@ -659,7 +660,7 @@ const AddCompilerStepOptions = struct { | ... | @@ -659,7 +660,7 @@ const AddCompilerStepOptions = struct { |
| 659 | single_threaded: ?bool = null, | 660 | single_threaded: ?bool = null, |
| 660 | }; | 661 | }; |
| 661 | | 662 | |
| 662 | fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.Step.Compile { | 663 | fn addCompilerMod(b: *std.Build, options: AddCompilerModOptions) *std.Build.Module { |
| 663 | const compiler_mod = b.createModule(.{ | 664 | const compiler_mod = b.createModule(.{ |
| 664 | .root_source_file = b.path("src/main.zig"), | 665 | .root_source_file = b.path("src/main.zig"), |
| 665 | .target = options.target, | 666 | .target = options.target, |
| ... | @@ -682,10 +683,14 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.St | ... | @@ -682,10 +683,14 @@ fn addCompilerStep(b: *std.Build, options: AddCompilerStepOptions) *std.Build.St |
| 682 | compiler_mod.addImport("aro", aro_mod); | 683 | compiler_mod.addImport("aro", aro_mod); |
| 683 | compiler_mod.addImport("aro_translate_c", aro_translate_c_mod); | 684 | compiler_mod.addImport("aro_translate_c", aro_translate_c_mod); |
| 684 | | 685 | |
| | 686 | return compiler_mod; |
| | 687 | } |
| | 688 | |
| | 689 | fn addCompilerStep(b: *std.Build, options: AddCompilerModOptions) *std.Build.Step.Compile { |
| 685 | const exe = b.addExecutable(.{ | 690 | const exe = b.addExecutable(.{ |
| 686 | .name = "zig", | 691 | .name = "zig", |
| 687 | .max_rss = 7_800_000_000, | 692 | .max_rss = 7_800_000_000, |
| 688 | .root_module = compiler_mod, | 693 | .root_module = addCompilerMod(b, options), |
| 689 | }); | 694 | }); |
| 690 | exe.stack_size = stack_size; | 695 | exe.stack_size = stack_size; |
| 691 | | 696 | |