| ... | ... | @@ -13,6 +13,7 @@ const Target = std.Target; |
| 13 | 13 | const self_hosted_main = @import("main.zig"); |
| 14 | 14 | const errmsg = @import("errmsg.zig"); |
| 15 | 15 | const DepTokenizer = @import("dep_tokenizer.zig").Tokenizer; |
| 16 | const assert = std.debug.assert; |
| 16 | 17 | |
| 17 | 18 | var stderr_file: fs.File = undefined; |
| 18 | 19 | var stderr: *io.OutStream(fs.File.WriteError) = undefined; |
| ... | ... | @@ -675,7 +676,7 @@ const Stage2CpuFeatures = struct { |
| 675 | 676 | }); |
| 676 | 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 | 680 | errdefer allocator.free(cache_hash); |
| 680 | 681 | |
| 681 | 682 | self.* = Self{ |
| ... | ... | @@ -696,29 +697,19 @@ const Stage2CpuFeatures = struct { |
| 696 | 697 | ) ![*:0]const u8 { |
| 697 | 698 | var llvm_features_buffer = try std.Buffer.initSize(allocator, 0); |
| 698 | 699 | defer llvm_features_buffer.deinit(); |
| 699 | | // First, disable all features. |
| 700 | | // This way, we only get the ones the user requests. |
| 700 | |
| 701 | 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 | 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| { |
| 713 | | try llvm_features_buffer.append("+"); |
| 714 | | try llvm_features_buffer.append(llvm_name); |
| 715 | | try llvm_features_buffer.append(","); |
| 716 | | } |
| 705 | const plus_or_minus = "-+"[@boolToInt(feature_set.isEnabled(@intCast(u8, index)))]; |
| 706 | try llvm_features_buffer.appendByte(plus_or_minus); |
| 707 | try llvm_features_buffer.append(llvm_name); |
| 708 | try llvm_features_buffer.append(","); |
| 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 | 713 | return llvm_features_buffer.toOwnedSlice().ptr; |
| 723 | 714 | } |
| 724 | 715 | |
| ... | ... | @@ -730,7 +721,7 @@ const Stage2CpuFeatures = struct { |
| 730 | 721 | const self = try allocator.create(Self); |
| 731 | 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 | 725 | errdefer allocator.free(cache_hash); |
| 735 | 726 | |
| 736 | 727 | const generic_arch_name = arch.genericName(); |