authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-21 21:01:36-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-21 21:01:36-05:00
log6e6ec3d71d1b5ecff8ad6bff5e159417abfa5382
tree97b2cf1c4153121c9d501ddc69bc7b07ea345964
parent68b6867e7689617b3dcef72a88414deaf3ede43b

put hack back in to disable windows native cpu features

See #508. This can be removed when we upgrade to LLVM 10.

2 files changed, 20 insertions(+), 9 deletions(-)

src-self-hosted/stage1.zig+17-6
...@@ -659,11 +659,20 @@ const Stage2CpuFeatures = struct {...@@ -659,11 +659,20 @@ const Stage2CpuFeatures = struct {
659 const target = try Target.parse(mem.toSliceConst(u8, zig_triple));659 const target = try Target.parse(mem.toSliceConst(u8, zig_triple));
660 const arch = target.Cross.arch;660 const arch = target.Cross.arch;
661 const cpu_features = try cpuFeaturesFromLLVM(arch, llvm_cpu_name_z, llvm_cpu_features);661 const cpu_features = try cpuFeaturesFromLLVM(arch, llvm_cpu_name_z, llvm_cpu_features);
662 switch (cpu_features) {662 const result = switch (cpu_features) {
663 .baseline => return createBaseline(allocator, arch),663 .baseline => try createBaseline(allocator, arch),
664 .cpu => |cpu| return createFromCpu(allocator, arch, cpu),664 .cpu => |cpu| try createFromCpu(allocator, arch, cpu),
665 .features => |features| return createFromCpuFeatures(allocator, arch, features),665 .features => |features| try createFromCpuFeatures(allocator, arch, features),
666 };
667 // LLVM creates invalid binaries on Windows sometimes.
668 // See https://github.com/ziglang/zig/issues/508
669 // As a workaround we do not use target native features on Windows.
670 // This logic is repeated in codegen.cpp
671 if (target.isWindows() or target.isUefi()) {
672 result.llvm_cpu_name = "";
673 result.llvm_features_str = "";
666 }674 }
675 return result;
667 }676 }
668677
669 fn createFromCpu(allocator: *mem.Allocator, arch: Target.Arch, cpu: *const Target.Cpu) !*Self {678 fn createFromCpu(allocator: *mem.Allocator, arch: Target.Arch, cpu: *const Target.Cpu) !*Self {
...@@ -742,9 +751,11 @@ const Stage2CpuFeatures = struct {...@@ -742,9 +751,11 @@ const Stage2CpuFeatures = struct {
742 for (arch.allFeaturesList()) |feature, index| {751 for (arch.allFeaturesList()) |feature, index| {
743 if (!feature_set.isEnabled(@intCast(u8, index))) continue;752 if (!feature_set.isEnabled(@intCast(u8, index))) continue;
744753
745 try builtin_str_buffer.append(" .");754 // TODO some kind of "zig identifier escape" function rather than
755 // unconditionally using @"" syntax
756 try builtin_str_buffer.append(" .@\"");
746 try builtin_str_buffer.append(feature.name);757 try builtin_str_buffer.append(feature.name);
747 try builtin_str_buffer.append(",\n");758 try builtin_str_buffer.append("\",\n");
748 }759 }
749760
750 try builtin_str_buffer.append(761 try builtin_str_buffer.append(
src/codegen.cpp+3-3
...@@ -8785,15 +8785,15 @@ static void init(CodeGen *g) {...@@ -8785,15 +8785,15 @@ static void init(CodeGen *g) {
8785 const char *target_specific_features = "";8785 const char *target_specific_features = "";
87868786
8787 if (g->zig_target->is_native) {8787 if (g->zig_target->is_native) {
8788 target_specific_cpu_args = ZigLLVMGetHostCPUName();
8789 target_specific_features = ZigLLVMGetNativeFeatures();
8788 // LLVM creates invalid binaries on Windows sometimes.8790 // LLVM creates invalid binaries on Windows sometimes.
8789 // See https://github.com/ziglang/zig/issues/5088791 // See https://github.com/ziglang/zig/issues/508
8790 // As a workaround we do not use target native features on Windows.8792 // As a workaround we do not use target native features on Windows.
8793 // This logic is repeated in stage1.zig
8791 if (g->zig_target->os == OsWindows || g->zig_target->os == OsUefi) {8794 if (g->zig_target->os == OsWindows || g->zig_target->os == OsUefi) {
8792 target_specific_cpu_args = "";8795 target_specific_cpu_args = "";
8793 target_specific_features = "";8796 target_specific_features = "";
8794 } else {
8795 target_specific_cpu_args = ZigLLVMGetHostCPUName();
8796 target_specific_features = ZigLLVMGetNativeFeatures();
8797 }8797 }
8798 }8798 }
87998799