aboutsummaryrefslogtreecommitdiff
path: root/lib/std/Target/Query.zig
diff options
context:
space:
mode:
authorDaniel Hooper <danielchasehooper@gmail.com>2024-11-05 19:38:01 -0800
committerGitHub <noreply@github.com>2024-11-06 03:38:01 +0000
commited04acf90dad41b24d7e11168a0fdd3316fc6f82 (patch)
treec62f9980b9aa9c230fae017ab4d9a7ec1a15ecde /lib/std/Target/Query.zig
parent7ebfc72186bbb70064d08192620bd7cccd965b2e (diff)
downloadzig-ed04acf90dad41b24d7e11168a0fdd3316fc6f82.tar.gz
zig-ed04acf90dad41b24d7e11168a0fdd3316fc6f82.zip
Provide a detailed message for invalid arch in target triple (#21921)
Diffstat (limited to 'lib/std/Target/Query.zig')
-rw-r--r--lib/std/Target/Query.zig7
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/std/Target/Query.zig b/lib/std/Target/Query.zig
index e50759a347..f3e280ee32 100644
--- a/lib/std/Target/Query.zig
+++ b/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;