From 80ff549e2602ecfc4eaf9ade0108e1779dff1874 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 6 Mar 2020 21:03:23 -0500 Subject: fix detectNativeCpuAndFeatures including foreign asm --- lib/std/zig/system.zig | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig index cfc43b7281..a4e065e184 100644 --- a/lib/std/zig/system.zig +++ b/lib/std/zig/system.zig @@ -863,7 +863,10 @@ pub const NativeTargetInfo = struct { } fn detectNativeCpuAndFeatures(cpu_arch: Target.Cpu.Arch, os: Target.Os, cross_target: CrossTarget) ?Target.Cpu { - switch (cpu_arch) { + // Here we switch on a comptime value rather than `cpu_arch`. This is valid because `cpu_arch`, + // although it is a runtime value, is guaranteed to be one of the architectures in the set + // of the respective switch prong. + switch (std.Target.current.cpu.arch) { .x86_64, .i386 => { return @import("system/x86.zig").detectNativeCpuAndFeatures(cpu_arch, os, cross_target); }, -- cgit v1.2.3