From 36849d8a7b5b0ed62d966ea9c402f192ade0cadf Mon Sep 17 00:00:00 2001 From: Vexu <15308111+Vexu@users.noreply.github.com> Date: Tue, 26 Nov 2019 10:27:51 +0200 Subject: fixes and cleanup in self hosted --- src-self-hosted/type.zig | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'src-self-hosted/type.zig') diff --git a/src-self-hosted/type.zig b/src-self-hosted/type.zig index 3bf39d9085..2fce36aec2 100644 --- a/src-self-hosted/type.zig +++ b/src-self-hosted/type.zig @@ -53,7 +53,7 @@ pub const Type = struct { base: *Type, allocator: *Allocator, llvm_context: *llvm.Context, - ) (error{OutOfMemory}!*llvm.Type) { + ) error{OutOfMemory}!*llvm.Type { switch (base.id) { .Struct => return @fieldParentPtr(Struct, "base", base).getLlvmType(allocator, llvm_context), .Fn => return @fieldParentPtr(Fn, "base", base).getLlvmType(allocator, llvm_context), @@ -184,7 +184,7 @@ pub const Type = struct { /// If you happen to have an llvm context handy, use getAbiAlignmentInContext instead. /// Otherwise, this one will grab one from the pool and then release it. - pub async fn getAbiAlignment(base: *Type, comp: *Compilation) !u32 { + pub fn getAbiAlignment(base: *Type, comp: *Compilation) !u32 { if (base.abi_alignment.start()) |ptr| return ptr.*; { @@ -200,7 +200,7 @@ pub const Type = struct { } /// If you have an llvm conext handy, you can use it here. - pub async fn getAbiAlignmentInContext(base: *Type, comp: *Compilation, llvm_context: *llvm.Context) !u32 { + pub fn getAbiAlignmentInContext(base: *Type, comp: *Compilation, llvm_context: *llvm.Context) !u32 { if (base.abi_alignment.start()) |ptr| return ptr.*; base.abi_alignment.data = base.resolveAbiAlignment(comp, llvm_context); @@ -209,7 +209,7 @@ pub const Type = struct { } /// Lower level function that does the work. See getAbiAlignment. - async fn resolveAbiAlignment(base: *Type, comp: *Compilation, llvm_context: *llvm.Context) !u32 { + fn resolveAbiAlignment(base: *Type, comp: *Compilation, llvm_context: *llvm.Context) !u32 { const llvm_type = try base.getLlvmType(comp.gpa(), llvm_context); return @intCast(u32, llvm.ABIAlignmentOfType(comp.target_data_ref, llvm_type)); } @@ -367,7 +367,7 @@ pub const Type = struct { } /// takes ownership of key.Normal.params on success - pub async fn get(comp: *Compilation, key: Key) !*Fn { + pub fn get(comp: *Compilation, key: Key) !*Fn { { const held = comp.fn_type_table.acquire(); defer held.release(); @@ -564,7 +564,7 @@ pub const Type = struct { return comp.u8_type; } - pub async fn get(comp: *Compilation, key: Key) !*Int { + pub fn get(comp: *Compilation, key: Key) !*Int { { const held = comp.int_type_table.acquire(); defer held.release(); @@ -606,7 +606,7 @@ pub const Type = struct { comp.registerGarbage(Int, &self.garbage_node); } - pub async fn gcDestroy(self: *Int, comp: *Compilation) void { + pub fn gcDestroy(self: *Int, comp: *Compilation) void { { const held = comp.int_type_table.acquire(); defer held.release(); @@ -700,7 +700,7 @@ pub const Type = struct { comp.registerGarbage(Pointer, &self.garbage_node); } - pub async fn gcDestroy(self: *Pointer, comp: *Compilation) void { + pub fn gcDestroy(self: *Pointer, comp: *Compilation) void { { const held = comp.ptr_type_table.acquire(); defer held.release(); @@ -711,14 +711,14 @@ pub const Type = struct { comp.gpa().destroy(self); } - pub async fn getAlignAsInt(self: *Pointer, comp: *Compilation) u32 { + pub fn getAlignAsInt(self: *Pointer, comp: *Compilation) u32 { switch (self.key.alignment) { .Abi => return self.key.child_type.getAbiAlignment(comp), .Override => |alignment| return alignment, } } - pub async fn get( + pub fn get( comp: *Compilation, key: Key, ) !*Pointer { @@ -828,7 +828,7 @@ pub const Type = struct { comp.gpa().destroy(self); } - pub async fn get(comp: *Compilation, key: Key) !*Array { + pub fn get(comp: *Compilation, key: Key) !*Array { key.elem_type.base.ref(); errdefer key.elem_type.base.deref(comp); -- cgit v1.2.3 From 798d05dd02a1c350c1ae48b25b84c0b88db9f449 Mon Sep 17 00:00:00 2001 From: Vexu <15308111+Vexu@users.noreply.github.com> Date: Tue, 26 Nov 2019 21:36:57 +0200 Subject: add workaround for #3190 --- src-self-hosted/link.zig | 4 +++- src-self-hosted/type.zig | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'src-self-hosted/type.zig') diff --git a/src-self-hosted/link.zig b/src-self-hosted/link.zig index 54835f9a02..67490b4e1f 100644 --- a/src-self-hosted/link.zig +++ b/src-self-hosted/link.zig @@ -58,7 +58,8 @@ pub fn link(comp: *Compilation) !void { try ctx.args.append("lld"); if (comp.haveLibC()) { - ctx.libc = ctx.comp.override_libc orelse blk: { + // TODO https://github.com/ziglang/zig/issues/3190 + var libc = ctx.comp.override_libc orelse blk: { switch (comp.target) { Target.Native => { break :blk comp.zig_compiler.getNativeLibC() catch return error.LibCRequiredButNotProvidedOrFound; @@ -66,6 +67,7 @@ pub fn link(comp: *Compilation) !void { else => return error.LibCRequiredButNotProvidedOrFound, } }; + ctx.libc = libc; } try constructLinkerArgs(&ctx); diff --git a/src-self-hosted/type.zig b/src-self-hosted/type.zig index 2fce36aec2..8b068150b6 100644 --- a/src-self-hosted/type.zig +++ b/src-self-hosted/type.zig @@ -726,8 +726,10 @@ pub const Type = struct { switch (key.alignment) { .Abi => {}, .Override => |alignment| { + // TODO https://github.com/ziglang/zig/issues/3190 + var align_spill = alignment; const abi_align = try key.child_type.getAbiAlignment(comp); - if (abi_align == alignment) { + if (abi_align == align_spill) { normal_key.alignment = .Abi; } }, -- cgit v1.2.3