| ... | @@ -13,6 +13,7 @@ const Target = std.Target; | ... | @@ -13,6 +13,7 @@ const Target = std.Target; |
| 13 | const self_hosted_main = @import("main.zig"); | 13 | const self_hosted_main = @import("main.zig"); |
| 14 | const errmsg = @import("errmsg.zig"); | 14 | const errmsg = @import("errmsg.zig"); |
| 15 | const DepTokenizer = @import("dep_tokenizer.zig").Tokenizer; | 15 | const DepTokenizer = @import("dep_tokenizer.zig").Tokenizer; |
| | 16 | const assert = std.debug.assert; |
| 16 | | 17 | |
| 17 | var stderr_file: fs.File = undefined; | 18 | var stderr_file: fs.File = undefined; |
| 18 | var stderr: *io.OutStream(fs.File.WriteError) = undefined; | 19 | var stderr: *io.OutStream(fs.File.WriteError) = undefined; |
| ... | @@ -675,7 +676,7 @@ const Stage2CpuFeatures = struct { | ... | @@ -675,7 +676,7 @@ const Stage2CpuFeatures = struct { |
| 675 | }); | 676 | }); |
| 676 | errdefer allocator.free(builtin_str); | 677 | errdefer allocator.free(builtin_str); |
| 677 | | 678 | |
| 678 | const cache_hash = try std.fmt.allocPrint0(allocator, "{}\n{x}", .{ cpu.name, cpu.features }); | 679 | const cache_hash = try std.fmt.allocPrint0(allocator, "{}\n{x}", .{ cpu.name, cpu.features.bytes }); |
| 679 | errdefer allocator.free(cache_hash); | 680 | errdefer allocator.free(cache_hash); |
| 680 | | 681 | |
| 681 | self.* = Self{ | 682 | self.* = Self{ |
| ... | @@ -696,29 +697,19 @@ const Stage2CpuFeatures = struct { | ... | @@ -696,29 +697,19 @@ const Stage2CpuFeatures = struct { |
| 696 | ) ![*:0]const u8 { | 697 | ) ![*:0]const u8 { |
| 697 | var llvm_features_buffer = try std.Buffer.initSize(allocator, 0); | 698 | var llvm_features_buffer = try std.Buffer.initSize(allocator, 0); |
| 698 | defer llvm_features_buffer.deinit(); | 699 | defer llvm_features_buffer.deinit(); |
| 699 | // First, disable all features. | 700 | |
| 700 | // This way, we only get the ones the user requests. | | |
| 701 | const all_features = arch.allFeaturesList(); | 701 | const all_features = arch.allFeaturesList(); |
| 702 | for (all_features) |feature| { | | |
| 703 | if (feature.llvm_name) |llvm_name| { | | |
| 704 | try llvm_features_buffer.append("-"); | | |
| 705 | try llvm_features_buffer.append(llvm_name); | | |
| 706 | try llvm_features_buffer.append(","); | | |
| 707 | } | | |
| 708 | } | | |
| 709 | for (all_features) |feature, index| { | 702 | for (all_features) |feature, index| { |
| 710 | if (!feature_set.isEnabled(@intCast(u8, index))) continue; | 703 | const llvm_name = feature.llvm_name orelse continue; |
| 711 | | 704 | |
| 712 | if (feature.llvm_name) |llvm_name| { | 705 | const plus_or_minus = "-+"[@boolToInt(feature_set.isEnabled(@intCast(u8, index)))]; |
| 713 | try llvm_features_buffer.append("+"); | 706 | try llvm_features_buffer.appendByte(plus_or_minus); |
| 714 | try llvm_features_buffer.append(llvm_name); | 707 | try llvm_features_buffer.append(llvm_name); |
| 715 | try llvm_features_buffer.append(","); | 708 | try llvm_features_buffer.append(","); |
| 716 | } | | |
| 717 | } | 709 | } |
| | 710 | assert(mem.endsWith(u8, llvm_features_buffer.toSliceConst(), ",")); |
| | 711 | llvm_features_buffer.shrink(llvm_features_buffer.len() - 1); |
| 718 | | 712 | |
| 719 | if (mem.endsWith(u8, llvm_features_buffer.toSliceConst(), ",")) { | | |
| 720 | llvm_features_buffer.shrink(llvm_features_buffer.len() - 1); | | |
| 721 | } | | |
| 722 | return llvm_features_buffer.toOwnedSlice().ptr; | 713 | return llvm_features_buffer.toOwnedSlice().ptr; |
| 723 | } | 714 | } |
| 724 | | 715 | |
| ... | @@ -730,7 +721,7 @@ const Stage2CpuFeatures = struct { | ... | @@ -730,7 +721,7 @@ const Stage2CpuFeatures = struct { |
| 730 | const self = try allocator.create(Self); | 721 | const self = try allocator.create(Self); |
| 731 | errdefer allocator.destroy(self); | 722 | errdefer allocator.destroy(self); |
| 732 | | 723 | |
| 733 | const cache_hash = try std.fmt.allocPrint0(allocator, "\n{x}", .{feature_set}); | 724 | const cache_hash = try std.fmt.allocPrint0(allocator, "\n{}", .{feature_set.bytes}); |
| 734 | errdefer allocator.free(cache_hash); | 725 | errdefer allocator.free(cache_hash); |
| 735 | | 726 | |
| 736 | const generic_arch_name = arch.genericName(); | 727 | const generic_arch_name = arch.genericName(); |