mirror of
https://github.com/ziglang/zig.git
synced 2026-01-03 03:53:20 +00:00
x86_64: fix errors compiling the compiler
This fixes issues targetting both `x86_64-linux` and `x86_64-macos` with the self-hosted backend.
This commit is contained in:
parent
f5dbcd1cb4
commit
eaa6218f09
@ -21,7 +21,7 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void {
|
||||
const reader = stream.reader();
|
||||
|
||||
const db_header = try reader.readStructEndian(ApplDbHeader, .big);
|
||||
assert(mem.eql(u8, "kych", &@as([4]u8, @bitCast(db_header.signature))));
|
||||
assert(mem.eql(u8, &db_header.signature, "kych"));
|
||||
|
||||
try stream.seekTo(db_header.schema_offset);
|
||||
|
||||
@ -73,7 +73,7 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void {
|
||||
}
|
||||
|
||||
const ApplDbHeader = extern struct {
|
||||
signature: @Vector(4, u8),
|
||||
signature: [4]u8,
|
||||
version: u32,
|
||||
header_size: u32,
|
||||
schema_offset: u32,
|
||||
|
||||
@ -452,11 +452,20 @@ pub fn init(stream: anytype, ca_bundle: Certificate.Bundle, host: []const u8) In
|
||||
if (ciphertext.len > cleartext_buf.len) return error.TlsRecordOverflow;
|
||||
const cleartext = cleartext_buf[0..ciphertext.len];
|
||||
const auth_tag = record_decoder.array(P.AEAD.tag_length).*;
|
||||
const V = @Vector(P.AEAD.nonce_length, u8);
|
||||
const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8);
|
||||
const operand: V = pad ++ @as([8]u8, @bitCast(big(read_seq)));
|
||||
const nonce = if (builtin.zig_backend == .stage2_x86_64 and
|
||||
P.AEAD.nonce_length > comptime std.simd.suggestVectorLength(u8) orelse 1)
|
||||
nonce: {
|
||||
var nonce = p.server_handshake_iv;
|
||||
const operand = std.mem.readInt(u64, nonce[nonce.len - 8 ..], .big);
|
||||
std.mem.writeInt(u64, nonce[nonce.len - 8 ..], operand ^ read_seq, .big);
|
||||
break :nonce nonce;
|
||||
} else nonce: {
|
||||
const V = @Vector(P.AEAD.nonce_length, u8);
|
||||
const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8);
|
||||
const operand: V = pad ++ @as([8]u8, @bitCast(big(read_seq)));
|
||||
break :nonce @as(V, p.server_handshake_iv) ^ operand;
|
||||
};
|
||||
read_seq += 1;
|
||||
const nonce = @as(V, p.server_handshake_iv) ^ operand;
|
||||
P.AEAD.decrypt(cleartext, ciphertext, auth_tag, record_header, nonce, p.server_handshake_key) catch
|
||||
return error.TlsBadRecordMac;
|
||||
break :c cleartext;
|
||||
@ -806,7 +815,6 @@ fn prepareCiphertextRecord(
|
||||
switch (c.application_cipher) {
|
||||
inline else => |*p| {
|
||||
const P = @TypeOf(p.*);
|
||||
const V = @Vector(P.AEAD.nonce_length, u8);
|
||||
const overhead_len = tls.record_header_len + P.AEAD.tag_length + 1;
|
||||
const close_notify_alert_reserved = tls.close_notify_alert.len + overhead_len;
|
||||
while (true) {
|
||||
@ -838,10 +846,20 @@ fn prepareCiphertextRecord(
|
||||
ciphertext_end += ciphertext_len;
|
||||
const auth_tag = ciphertext_buf[ciphertext_end..][0..P.AEAD.tag_length];
|
||||
ciphertext_end += auth_tag.len;
|
||||
const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8);
|
||||
const operand: V = pad ++ @as([8]u8, @bitCast(big(c.write_seq)));
|
||||
const nonce = if (builtin.zig_backend == .stage2_x86_64 and
|
||||
P.AEAD.nonce_length > comptime std.simd.suggestVectorLength(u8) orelse 1)
|
||||
nonce: {
|
||||
var nonce = p.client_iv;
|
||||
const operand = std.mem.readInt(u64, nonce[nonce.len - 8 ..], .big);
|
||||
std.mem.writeInt(u64, nonce[nonce.len - 8 ..], operand ^ c.write_seq, .big);
|
||||
break :nonce nonce;
|
||||
} else nonce: {
|
||||
const V = @Vector(P.AEAD.nonce_length, u8);
|
||||
const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8);
|
||||
const operand: V = pad ++ @as([8]u8, @bitCast(big(c.write_seq)));
|
||||
break :nonce @as(V, p.client_iv) ^ operand;
|
||||
};
|
||||
c.write_seq += 1; // TODO send key_update on overflow
|
||||
const nonce = @as(V, p.client_iv) ^ operand;
|
||||
P.AEAD.encrypt(ciphertext, auth_tag, cleartext, ad, nonce, p.client_key);
|
||||
|
||||
const record = ciphertext_buf[record_start..ciphertext_end];
|
||||
@ -1102,15 +1120,24 @@ pub fn readvAdvanced(c: *Client, stream: anytype, iovecs: []const std.os.iovec)
|
||||
const cleartext = switch (c.application_cipher) {
|
||||
inline else => |*p| c: {
|
||||
const P = @TypeOf(p.*);
|
||||
const V = @Vector(P.AEAD.nonce_length, u8);
|
||||
const ad = frag[in - 5 ..][0..5];
|
||||
const ciphertext_len = record_len - P.AEAD.tag_length;
|
||||
const ciphertext = frag[in..][0..ciphertext_len];
|
||||
in += ciphertext_len;
|
||||
const auth_tag = frag[in..][0..P.AEAD.tag_length].*;
|
||||
const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8);
|
||||
const operand: V = pad ++ @as([8]u8, @bitCast(big(c.read_seq)));
|
||||
const nonce: [P.AEAD.nonce_length]u8 = @as(V, p.server_iv) ^ operand;
|
||||
const nonce = if (builtin.zig_backend == .stage2_x86_64 and
|
||||
P.AEAD.nonce_length > comptime std.simd.suggestVectorLength(u8) orelse 1)
|
||||
nonce: {
|
||||
var nonce = p.server_iv;
|
||||
const operand = std.mem.readInt(u64, nonce[nonce.len - 8 ..], .big);
|
||||
std.mem.writeInt(u64, nonce[nonce.len - 8 ..], operand ^ c.read_seq, .big);
|
||||
break :nonce nonce;
|
||||
} else nonce: {
|
||||
const V = @Vector(P.AEAD.nonce_length, u8);
|
||||
const pad = [1]u8{0} ** (P.AEAD.nonce_length - 8);
|
||||
const operand: V = pad ++ @as([8]u8, @bitCast(big(c.read_seq)));
|
||||
break :nonce @as(V, p.server_iv) ^ operand;
|
||||
};
|
||||
const out_buf = vp.peek();
|
||||
const cleartext_buf = if (ciphertext.len <= out_buf.len)
|
||||
out_buf
|
||||
|
||||
@ -20136,6 +20136,7 @@ fn finishStructInit(
|
||||
},
|
||||
else => |e| return e,
|
||||
};
|
||||
try sema.resolveStructFieldInits(struct_ty);
|
||||
try sema.queueFullTypeResolution(struct_ty);
|
||||
const struct_val = try block.addAggregateInit(struct_ty, field_inits);
|
||||
return sema.coerce(block, result_ty, struct_val, init_src);
|
||||
@ -35939,7 +35940,7 @@ pub fn resolveTypeFully(sema: *Sema, ty: Type) CompileError!void {
|
||||
return sema.resolveTypeFully(ty.childType(mod));
|
||||
},
|
||||
.Struct => switch (mod.intern_pool.indexToKey(ty.toIntern())) {
|
||||
.struct_type => return sema.resolveStructFully(ty),
|
||||
.struct_type => try sema.resolveStructFully(ty),
|
||||
.anon_struct_type => |tuple| {
|
||||
for (tuple.types.get(ip)) |field_ty| {
|
||||
try sema.resolveTypeFully(Type.fromInterned(field_ty));
|
||||
|
||||
@ -310,11 +310,6 @@ pub fn print(
|
||||
return writer.writeAll(" }");
|
||||
},
|
||||
.ptr => |ptr| {
|
||||
if (ptr.addr == .int) {}
|
||||
|
||||
const ptr_ty = ip.indexToKey(ty.toIntern()).ptr_type;
|
||||
if (ptr_ty.flags.size == .Slice) {}
|
||||
|
||||
switch (ptr.addr) {
|
||||
.decl => |decl_index| {
|
||||
const decl = mod.declPtr(decl_index);
|
||||
@ -348,7 +343,14 @@ pub fn print(
|
||||
.val = Value.fromInterned(field_val_ip),
|
||||
}, writer, level - 1, mod);
|
||||
},
|
||||
.int => unreachable,
|
||||
.int => |int_ip| {
|
||||
try writer.writeAll("@ptrFromInt(");
|
||||
try print(.{
|
||||
.ty = Type.usize,
|
||||
.val = Value.fromInterned(int_ip),
|
||||
}, writer, level - 1, mod);
|
||||
try writer.writeByte(')');
|
||||
},
|
||||
.eu_payload => |eu_ip| {
|
||||
try writer.writeAll("(payload of ");
|
||||
try print(.{
|
||||
|
||||
@ -9978,10 +9978,10 @@ fn fnTypeAssumeCapacity(
|
||||
}
|
||||
pub fn eql(ctx: @This(), lhs_key: Key, _: void, rhs_index: usize) bool {
|
||||
const rhs_data = ctx.builder.type_items.items[rhs_index];
|
||||
if (rhs_data.tag != tag) return false;
|
||||
var rhs_extra = ctx.builder.typeExtraDataTrail(Type.Function, rhs_data.data);
|
||||
const rhs_params = rhs_extra.trail.next(rhs_extra.data.params_len, Type, ctx.builder);
|
||||
return rhs_data.tag == tag and lhs_key.ret == rhs_extra.data.ret and
|
||||
std.mem.eql(Type, lhs_key.params, rhs_params);
|
||||
return lhs_key.ret == rhs_extra.data.ret and std.mem.eql(Type, lhs_key.params, rhs_params);
|
||||
}
|
||||
};
|
||||
const gop = self.type_map.getOrPutAssumeCapacityAdapted(
|
||||
@ -10161,9 +10161,10 @@ fn structTypeAssumeCapacity(
|
||||
}
|
||||
pub fn eql(ctx: @This(), lhs_key: []const Type, _: void, rhs_index: usize) bool {
|
||||
const rhs_data = ctx.builder.type_items.items[rhs_index];
|
||||
if (rhs_data.tag != tag) return false;
|
||||
var rhs_extra = ctx.builder.typeExtraDataTrail(Type.Structure, rhs_data.data);
|
||||
const rhs_fields = rhs_extra.trail.next(rhs_extra.data.fields_len, Type, ctx.builder);
|
||||
return rhs_data.tag == tag and std.mem.eql(Type, lhs_key, rhs_fields);
|
||||
return std.mem.eql(Type, lhs_key, rhs_fields);
|
||||
}
|
||||
};
|
||||
const gop = self.type_map.getOrPutAssumeCapacityAdapted(fields, Adapter{ .builder = self });
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user