authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-21 12:14:43-05:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-01-21 12:14:43-05:00
log91ecce3bc05abb6677b389cbc7af403584d9cc7d
tree08cd205a53b75bdf7f8f8b3ff13175be539e9590
parent6793af8d8b370cefc0a1fccbcf1c9fd1a24c7378
signaturelock-open Commit is signed but in an unrecognized format.

fix cache of cpu features


1 files changed, 11 insertions(+), 20 deletions(-)

src-self-hosted/stage1.zig+11-20
......@@ -13,6 +13,7 @@ const Target = std.Target;
1313const self_hosted_main = @import("main.zig");
1414const errmsg = @import("errmsg.zig");
1515const DepTokenizer = @import("dep_tokenizer.zig").Tokenizer;
16const assert = std.debug.assert;
1617
1718var stderr_file: fs.File = undefined;
1819var stderr: *io.OutStream(fs.File.WriteError) = undefined;
......@@ -675,7 +676,7 @@ const Stage2CpuFeatures = struct {
675676 });
676677 errdefer allocator.free(builtin_str);
677678
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 });
679680 errdefer allocator.free(cache_hash);
680681
681682 self.* = Self{
......@@ -696,29 +697,19 @@ const Stage2CpuFeatures = struct {
696697 ) ![*:0]const u8 {
697698 var llvm_features_buffer = try std.Buffer.initSize(allocator, 0);
698699 defer llvm_features_buffer.deinit();
699 // First, disable all features.
700 // This way, we only get the ones the user requests.
700
701701 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 }
709702 for (all_features) |feature, index| {
710 if (!feature_set.isEnabled(@intCast(u8, index))) continue;
703 const llvm_name = feature.llvm_name orelse continue;
711704
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(",");
717709 }
710 assert(mem.endsWith(u8, llvm_features_buffer.toSliceConst(), ","));
711 llvm_features_buffer.shrink(llvm_features_buffer.len() - 1);
718712
719 if (mem.endsWith(u8, llvm_features_buffer.toSliceConst(), ",")) {
720 llvm_features_buffer.shrink(llvm_features_buffer.len() - 1);
721 }
722713 return llvm_features_buffer.toOwnedSlice().ptr;
723714 }
724715
......@@ -730,7 +721,7 @@ const Stage2CpuFeatures = struct {
730721 const self = try allocator.create(Self);
731722 errdefer allocator.destroy(self);
732723
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});
734725 errdefer allocator.free(cache_hash);
735726
736727 const generic_arch_name = arch.genericName();