master
1pub fn build(b: *std.Build) !void {
2 const mod = b.createModule(.{
3 // Setting the entry point doesn't work properly on all targets right now. Since we're
4 // really just trying to make sure that the compiler *frontend* respects `-fentry` and
5 // includes it in the cache manifest, just test for a target where it works.
6 .target = b.resolveTargetQuery(try .parse(.{
7 .arch_os_abi = "x86_64-linux",
8 })),
9 .optimize = .ReleaseFast, // non-Debug build for reproducible output
10 .root_source_file = b.path("main.zig"),
11 });
12
13 const exe_foo = b.addExecutable(.{
14 .name = "the_exe", // same name for reproducible output
15 .root_module = mod,
16 });
17 exe_foo.entry = .{ .symbol_name = "foo" };
18 const exe_bar = b.addExecutable(.{
19 .name = "the_exe", // same name for reproducible output
20 .root_module = mod,
21 });
22 exe_bar.entry = .{ .symbol_name = "bar" };
23
24 // Despite the output binary being reproducible, the `entry` differed, so the emitted binaries
25 // should be different. But the two compilations are otherwise identical, so if `entry` isn't
26 // being respected properly, we will see identical binaries.
27
28 const check_differ_exe = b.addExecutable(.{
29 .name = "check_differ",
30 .root_module = b.createModule(.{
31 .target = b.graph.host,
32 .optimize = .Debug,
33 .root_source_file = b.path("check_differ.zig"),
34 }),
35 });
36
37 const diff_cmd = b.addRunArtifact(check_differ_exe);
38 diff_cmd.addFileArg(exe_foo.getEmittedBin());
39 diff_cmd.addFileArg(exe_bar.getEmittedBin());
40 diff_cmd.expectExitCode(0);
41
42 const test_step = b.step("test", "Test it");
43 b.default_step = test_step;
44 test_step.dependOn(&diff_cmd.step);
45}
46const std = @import("std");