Commit 9ad24a4aee
Changed files (4)
lib
std
build
lib/std/build/CheckObjectStep.zig
@@ -571,6 +571,12 @@ const MachODumper = struct {
});
},
+ .UUID => {
+ const uuid = lc.cast(macho.uuid_command).?;
+ try writer.writeByte('\n');
+ try writer.print("uuid {x}", .{std.fmt.fmtSliceHexLower(&uuid.uuid)});
+ },
+
else => {},
}
}
test/link/macho/uuid/build.zig
@@ -0,0 +1,52 @@
+const std = @import("std");
+const builtin = @import("builtin");
+const Builder = std.build.Builder;
+const LibExeObjectStep = std.build.LibExeObjStep;
+
+pub fn build(b: *Builder) void {
+ const test_step = b.step("test", "Test");
+ test_step.dependOn(b.getInstallStep());
+
+ switch (builtin.cpu.arch) {
+ .aarch64 => {
+ testUuid(b, test_step, .ReleaseSafe, "eb1203019e453d808d4f1e71053af9af");
+ testUuid(b, test_step, .ReleaseFast, "eb1203019e453d808d4f1e71053af9af");
+ testUuid(b, test_step, .ReleaseSmall, "eb1203019e453d808d4f1e71053af9af");
+ },
+ .x86_64 => {
+ testUuid(b, test_step, .ReleaseSafe, "b3598e7c42dc38b0bd2975ead6e4ae85");
+ testUuid(b, test_step, .ReleaseFast, "b3598e7c42dc38b0bd2975ead6e4ae85");
+ testUuid(b, test_step, .ReleaseSmall, "1064b25eef4e3e6391866188b3dd7156");
+ },
+ else => unreachable,
+ }
+}
+
+fn testUuid(b: *Builder, test_step: *std.build.Step, mode: std.builtin.Mode, comptime exp: []const u8) void {
+ // The calculated UUID value is independent of debug info and so it should
+ // stay the same across builds.
+ {
+ const dylib = simpleDylib(b, mode);
+ const check_dylib = dylib.checkObject(.macho);
+ check_dylib.checkStart("cmd UUID");
+ check_dylib.checkNext("uuid " ++ exp);
+ test_step.dependOn(&check_dylib.step);
+ }
+ {
+ const dylib = simpleDylib(b, mode);
+ dylib.strip = true;
+ const check_dylib = dylib.checkObject(.macho);
+ check_dylib.checkStart("cmd UUID");
+ check_dylib.checkNext("uuid " ++ exp);
+ test_step.dependOn(&check_dylib.step);
+ }
+}
+
+fn simpleDylib(b: *Builder, mode: std.builtin.Mode) *LibExeObjectStep {
+ const dylib = b.addSharedLibrary("test", null, b.version(1, 0, 0));
+ dylib.setBuildMode(mode);
+ dylib.setTarget(.{ .os_tag = .macos });
+ dylib.addCSourceFile("test.c", &.{});
+ dylib.linkLibC();
+ return dylib;
+}
test/link/macho/uuid/test.c
@@ -0,0 +1,2 @@
+void test() {}
+
test/link.zig
@@ -170,6 +170,11 @@ fn addMachOCases(cases: *tests.StandaloneContext) void {
.requires_symlinks = true,
});
+ cases.addBuildFile("test/link/macho/uuid/build.zig", .{
+ .build_modes = false,
+ .requires_symlinks = true,
+ });
+
cases.addBuildFile("test/link/macho/weak_library/build.zig", .{
.build_modes = true,
.requires_symlinks = true,