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 {
659659 const target = try Target.parse(mem.toSliceConst(u8, zig_triple));
660660 const arch = target.Cross.arch;
661661 const cpu_features = try cpuFeaturesFromLLVM(arch, llvm_cpu_name_z, llvm_cpu_features);
662 switch (cpu_features) {
663 .baseline => return createBaseline(allocator, arch),
664 .cpu => |cpu| return createFromCpu(allocator, arch, cpu),
665 .features => |features| return createFromCpuFeatures(allocator, arch, features),
662 const result = switch (cpu_features) {
663 .baseline => try createBaseline(allocator, arch),
664 .cpu => |cpu| try createFromCpu(allocator, arch, cpu),
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 = "";
666674 }
675 return result;
667676 }
668677
669678 fn createFromCpu(allocator: *mem.Allocator, arch: Target.Arch, cpu: *const Target.Cpu) !*Self {
......@@ -742,9 +751,11 @@ const Stage2CpuFeatures = struct {
742751 for (arch.allFeaturesList()) |feature, index| {
743752 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(" .@\"");
746757 try builtin_str_buffer.append(feature.name);
747 try builtin_str_buffer.append(",\n");
758 try builtin_str_buffer.append("\",\n");
748759 }
749760
750761 try builtin_str_buffer.append(
src/codegen.cpp+3-3
......@@ -8785,15 +8785,15 @@ static void init(CodeGen *g) {
87858785 const char *target_specific_features = "";
87868786
87878787 if (g->zig_target->is_native) {
8788 target_specific_cpu_args = ZigLLVMGetHostCPUName();
8789 target_specific_features = ZigLLVMGetNativeFeatures();
87888790 // LLVM creates invalid binaries on Windows sometimes.
87898791 // See https://github.com/ziglang/zig/issues/508
87908792 // As a workaround we do not use target native features on Windows.
8793 // This logic is repeated in stage1.zig
87918794 if (g->zig_target->os == OsWindows || g->zig_target->os == OsUefi) {
87928795 target_specific_cpu_args = "";
87938796 target_specific_features = "";
8794 } else {
8795 target_specific_cpu_args = ZigLLVMGetHostCPUName();
8796 target_specific_features = ZigLLVMGetNativeFeatures();
87978797 }
87988798 }
87998799