mirror of
https://github.com/ziglang/zig.git
synced 2025-12-24 07:03:11 +00:00
Provide a detailed message for invalid arch in target triple (#21921)
This commit is contained in:
parent
7ebfc72186
commit
ed04acf90d
@ -193,6 +193,9 @@ pub const ParseOptions = struct {
|
|||||||
|
|
||||||
/// If error.UnknownCpuFeature is returned, this will be populated.
|
/// If error.UnknownCpuFeature is returned, this will be populated.
|
||||||
unknown_feature_name: ?[]const u8 = null,
|
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_name = it.first();
|
||||||
const arch_is_native = mem.eql(u8, arch_name, "native");
|
const arch_is_native = mem.eql(u8, arch_name, "native");
|
||||||
if (!arch_is_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;
|
return error.UnknownArchitecture;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
const arch = result.cpu_arch orelse builtin.cpu.arch;
|
const arch = result.cpu_arch orelse builtin.cpu.arch;
|
||||||
diags.arch = arch;
|
diags.arch = arch;
|
||||||
|
|||||||
@ -660,6 +660,17 @@ pub fn parseTargetQueryOrReportFatalError(
|
|||||||
}
|
}
|
||||||
fatal("unknown object format: '{s}'", .{opts.object_format.?});
|
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}", .{
|
else => |e| fatal("unable to parse target query '{s}': {s}", .{
|
||||||
opts.arch_os_abi, @errorName(e),
|
opts.arch_os_abi, @errorName(e),
|
||||||
}),
|
}),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user