File reproducible.patch of Package zig

Date: 2025-01-31
Based on https://github.com/ziglang/zig/pull/22673
to fix variations of binaries from CPU-model https://github.com/ziglang/zig/issues/22663


diff --git a/lib/compiler/build_runner.zig b/lib/compiler/build_runner.zig
index 80b0c2ea..2c6e1e7e 100644
--- a/lib/compiler/build_runner.zig
+++ b/lib/compiler/build_runner.zig
@@ -61,6 +61,12 @@ pub fn main() !void {
         .handle = try std.fs.cwd().makeOpenPath(global_cache_root, .{}),
     };
 
+    // Avoid using native binaries during build to not influence zig-cache hashes
+    const host_query: std.Target.Query = .{
+        .cpu_model = .baseline,
+        .os_tag = builtin.target.os.tag,
+    };
+
     var graph: std.Build.Graph = .{
         .arena = arena,
         .cache = .{
@@ -71,8 +77,8 @@ pub fn main() !void {
         .env_map = try process.getEnvMap(arena),
         .global_cache_root = global_cache_directory,
         .host = .{
-            .query = .{},
-            .result = try std.zig.system.resolveTargetQuery(.{}),
+            .query = host_query,
+            .result = try std.zig.system.resolveTargetQuery(host_query),
         },
     };
 
openSUSE Build Service is sponsored by