| author | |
| committer | |
| log | ed04acf90dad41b24d7e11168a0fdd3316fc6f82 |
| tree | c62f9980b9aa9c230fae017ab4d9a7ec1a15ecde |
| parent | 7ebfc72186bbb70064d08192620bd7cccd965b2e |
| signature |
2 files changed, 17 insertions(+), 1 deletions(-)
lib/std/Target/Query.zig+6-1| ... | @@ -193,6 +193,9 @@ pub const ParseOptions = struct { | ... | @@ -193,6 +193,9 @@ pub const ParseOptions = struct { |
| 193 | 193 | ||
| 194 | /// If error.UnknownCpuFeature is returned, this will be populated. | 194 | /// If error.UnknownCpuFeature is returned, this will be populated. |
| 195 | unknown_feature_name: ?[]const u8 = null, | 195 | unknown_feature_name: ?[]const u8 = null, |
| 196 | |||
| 197 | /// If error.UnknownArchitecture is returned, this will be populated. | ||
| 198 | unknown_architecture_name: ?[]const u8 = null, | ||
| 196 | }; | 199 | }; |
| 197 | }; | 200 | }; |
| 198 | 201 | ||
| ... | @@ -208,8 +211,10 @@ pub fn parse(args: ParseOptions) !Query { | ... | @@ -208,8 +211,10 @@ pub fn parse(args: ParseOptions) !Query { |
| 208 | const arch_name = it.first(); | 211 | const arch_name = it.first(); |
| 209 | const arch_is_native = mem.eql(u8, arch_name, "native"); | 212 | const arch_is_native = mem.eql(u8, arch_name, "native"); |
| 210 | if (!arch_is_native) { | 213 | if (!arch_is_native) { |
| 211 | result.cpu_arch = std.meta.stringToEnum(Target.Cpu.Arch, arch_name) orelse | 214 | result.cpu_arch = std.meta.stringToEnum(Target.Cpu.Arch, arch_name) orelse { |
| 215 | diags.unknown_architecture_name = arch_name; | ||
| 212 | return error.UnknownArchitecture; | 216 | return error.UnknownArchitecture; |
| 217 | }; | ||
| 213 | } | 218 | } |
| 214 | const arch = result.cpu_arch orelse builtin.cpu.arch; | 219 | const arch = result.cpu_arch orelse builtin.cpu.arch; |
| 215 | diags.arch = arch; | 220 | diags.arch = arch; |
lib/std/zig.zig+11| ... | @@ -660,6 +660,17 @@ pub fn parseTargetQueryOrReportFatalError( | ... | @@ -660,6 +660,17 @@ pub fn parseTargetQueryOrReportFatalError( |
| 660 | } | 660 | } |
| 661 | fatal("unknown object format: '{s}'", .{opts.object_format.?}); | 661 | fatal("unknown object format: '{s}'", .{opts.object_format.?}); |
| 662 | }, | 662 | }, |
| 663 | error.UnknownArchitecture => { | ||
| 664 | help: { | ||
| 665 | var help_text = std.ArrayList(u8).init(allocator); | ||
| 666 | defer help_text.deinit(); | ||
| 667 | inline for (@typeInfo(std.Target.Cpu.Arch).@"enum".fields) |field| { | ||
| 668 | help_text.writer().print(" {s}\n", .{field.name}) catch break :help; | ||
| 669 | } | ||
| 670 | std.log.info("available architectures:\n{s} native\n", .{help_text.items}); | ||
| 671 | } | ||
| 672 | fatal("unknown architecture: '{s}'", .{diags.unknown_architecture_name.?}); | ||
| 673 | }, | ||
| 663 | else => |e| fatal("unable to parse target query '{s}': {s}", .{ | 674 | else => |e| fatal("unable to parse target query '{s}': {s}", .{ |
| 664 | opts.arch_os_abi, @errorName(e), | 675 | opts.arch_os_abi, @errorName(e), |
| 665 | }), | 676 | }), |