| ... | @@ -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 | } |
| 668 | | 677 | |
| 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; |
| 744 | | 753 | |
| 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 | } |
| 749 | | 760 | |
| 750 | try builtin_str_buffer.append( | 761 | try builtin_str_buffer.append( |