Commit 562f91e875
Changed files (5)
src/codegen.cpp
@@ -152,6 +152,10 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out
return g;
}
+void codegen_destroy(CodeGen *codegen) {
+ LLVMDisposeTargetMachine(codegen->target_machine);
+}
+
void codegen_set_output_h_path(CodeGen *g, Buf *h_path) {
g->out_h_path = h_path;
}
src/codegen.hpp
@@ -16,6 +16,7 @@
CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out_type, BuildMode build_mode,
Buf *zig_lib_dir);
+void codegen_destroy(CodeGen *codegen);
void codegen_set_clang_argv(CodeGen *codegen, const char **args, size_t len);
void codegen_set_llvm_argv(CodeGen *codegen, const char **args, size_t len);
src/link.cpp
@@ -65,6 +65,8 @@ static Buf *build_o_raw(CodeGen *parent_gen, const char *oname, Buf *full_path)
os_path_join(parent_gen->cache_dir, o_out_name, output_path);
codegen_link(child_gen, buf_ptr(output_path));
+ codegen_destroy(child_gen);
+
return output_path;
}
src/main.cpp
@@ -421,6 +421,7 @@ int main(int argc, char **argv) {
g->root_package->package_table.put(buf_create_from_str("@build"), build_pkg);
codegen_build(g);
codegen_link(g, buf_ptr(path_to_build_exe));
+ codegen_destroy(g);
Termination term;
os_spawn_process(buf_ptr(path_to_build_exe), args, &term);
src/zig_llvm.cpp
@@ -165,7 +165,8 @@ bool ZigLLVMTargetMachineEmitToFile(LLVMTargetMachineRef targ_machine_ref, LLVMM
MPM.run(*module);
- dest.flush();
+ dest.close();
+
return false;
}