diff options
| author | Andrew Kelley <superjoe30@gmail.com> | 2018-07-24 00:31:33 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-07-24 00:31:33 -0400 |
| commit | 10bdf73a02c90dc375985e49b08b5020cfc20b93 (patch) | |
| tree | 2485d62496dd7436bcbabe80e7b47ca369ccbd38 /src-self-hosted/codegen.zig | |
| parent | 99153ac0aa390f01091308073b39947c45851ae6 (diff) | |
| parent | 72599d420b1bebb37efb2179a91d8256287f7c28 (diff) | |
| download | zig-10bdf73a02c90dc375985e49b08b5020cfc20b93.tar.gz zig-10bdf73a02c90dc375985e49b08b5020cfc20b93.zip | |
Merge pull request #1266 from ziglang/self-hosted-libc-hello-world
Self hosted libc hello world
Diffstat (limited to 'src-self-hosted/codegen.zig')
| -rw-r--r-- | src-self-hosted/codegen.zig | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src-self-hosted/codegen.zig b/src-self-hosted/codegen.zig index f8233bc795..ad3dce061e 100644 --- a/src-self-hosted/codegen.zig +++ b/src-self-hosted/codegen.zig @@ -15,7 +15,7 @@ pub async fn renderToLlvm(comp: *Compilation, fn_val: *Value.Fn, code: *ir.Code) defer fn_val.base.deref(comp); defer code.destroy(comp.gpa()); - var output_path = try await (async comp.createRandomOutputPath(comp.target.oFileExt()) catch unreachable); + var output_path = try await (async comp.createRandomOutputPath(comp.target.objFileExt()) catch unreachable); errdefer output_path.deinit(); const llvm_handle = try comp.event_loop_local.getAnyLlvmContext(); @@ -78,6 +78,7 @@ pub async fn renderToLlvm(comp: *Compilation, fn_val: *Value.Fn, code: *ir.Code) .dibuilder = dibuilder, .context = context, .lock = event.Lock.init(comp.loop), + .arena = &code.arena.allocator, }; try renderToLlvmModule(&ofile, fn_val, code); @@ -139,6 +140,7 @@ pub const ObjectFile = struct { dibuilder: *llvm.DIBuilder, context: llvm.ContextRef, lock: event.Lock, + arena: *std.mem.Allocator, fn gpa(self: *ObjectFile) *std.mem.Allocator { return self.comp.gpa(); @@ -147,7 +149,7 @@ pub const ObjectFile = struct { pub fn renderToLlvmModule(ofile: *ObjectFile, fn_val: *Value.Fn, code: *ir.Code) !void { // TODO audit more of codegen.cpp:fn_llvm_value and port more logic - const llvm_fn_type = try fn_val.base.typeof.getLlvmType(ofile); + const llvm_fn_type = try fn_val.base.typ.getLlvmType(ofile.arena, ofile.context); const llvm_fn = llvm.AddFunction( ofile.module, fn_val.symbol_name.ptr(), @@ -165,7 +167,7 @@ pub fn renderToLlvmModule(ofile: *ObjectFile, fn_val: *Value.Fn, code: *ir.Code) // try addLLVMFnAttrInt(ofile, llvm_fn, "alignstack", align_stack); //} - const fn_type = fn_val.base.typeof.cast(Type.Fn).?; + const fn_type = fn_val.base.typ.cast(Type.Fn).?; try addLLVMFnAttr(ofile, llvm_fn, "nounwind"); //add_uwtable_attr(g, fn_table_entry->llvm_value); |
