authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2023-08-16 21:28:50+01:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-08-16 18:05:18-07:00
log000aa30086eb4b470d2b567ce377f0e4a9d9a516
tree19c17d4177f36f460a661f96efa0d04ea629b117
parent01836c7bbe90cfb7847ab9803cb976515160c533

std.Build: check for native CPU when serializing CrossTarget

When using `std.Build.dependency` with target options, dependencies would sometimes get targets which are equivalent but have distinct names, e.g. `native` vs `native-native`. This is a somewhat broad issue, and it's unclear how to fix it more generally - perhaps we should special-case CrossTarget in options passing, or maybe targets should have a canonical name which we guarantee to use everywhere aside from raw user input. However, this commit fixes the most egregious issue, which was an active blocker to using the package manager for some users. This was caused by the CPU changing from `native` to a specific descriptor (e.g. `skylake+sgx`), which then changed the behavior of `zigTriple`. Resolves: #16856

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

lib/std/Build.zig+6-1
......@@ -414,7 +414,12 @@ fn userInputOptionsFromArgs(allocator: Allocator, args: anytype) UserInputOption
414414 }) catch @panic("OOM");
415415 user_input_options.put("cpu", .{
416416 .name = "cpu",
417 .value = .{ .scalar = serializeCpu(allocator, v.getCpu()) catch unreachable },
417 .value = .{
418 .scalar = if (v.isNativeCpu())
419 "native"
420 else
421 serializeCpu(allocator, v.getCpu()) catch unreachable,
422 },
418423 .used = false,
419424 }) catch @panic("OOM");
420425 },