Commit ed04acf90d
lib/std/Target/Query.zig
@@ -193,6 +193,9 @@ pub const ParseOptions = struct {
/// If error.UnknownCpuFeature is returned, this will be populated.
unknown_feature_name: ?[]const u8 = null,
+
+ /// If error.UnknownArchitecture is returned, this will be populated.
+ unknown_architecture_name: ?[]const u8 = null,
};
};
@@ -208,8 +211,10 @@ pub fn parse(args: ParseOptions) !Query {
const arch_name = it.first();
const arch_is_native = mem.eql(u8, arch_name, "native");
if (!arch_is_native) {
- result.cpu_arch = std.meta.stringToEnum(Target.Cpu.Arch, arch_name) orelse
+ result.cpu_arch = std.meta.stringToEnum(Target.Cpu.Arch, arch_name) orelse {
+ diags.unknown_architecture_name = arch_name;
return error.UnknownArchitecture;
+ };
}
const arch = result.cpu_arch orelse builtin.cpu.arch;
diags.arch = arch;
lib/std/zig.zig
@@ -660,6 +660,17 @@ pub fn parseTargetQueryOrReportFatalError(
}
fatal("unknown object format: '{s}'", .{opts.object_format.?});
},
+ error.UnknownArchitecture => {
+ help: {
+ var help_text = std.ArrayList(u8).init(allocator);
+ defer help_text.deinit();
+ inline for (@typeInfo(std.Target.Cpu.Arch).@"enum".fields) |field| {
+ help_text.writer().print(" {s}\n", .{field.name}) catch break :help;
+ }
+ std.log.info("available architectures:\n{s} native\n", .{help_text.items});
+ }
+ fatal("unknown architecture: '{s}'", .{diags.unknown_architecture_name.?});
+ },
else => |e| fatal("unable to parse target query '{s}': {s}", .{
opts.arch_os_abi, @errorName(e),
}),