authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-09-21 11:18:49-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2016-09-21 11:18:49-04:00
log3f8f0b9bba5407ed5f7279bfdb7d22afaa126674
treef63d6c21e29f2b5cad0c1723a2531f071061c225
parentb97bfc3ecba9655cdd989add13a7582272659268

exporting an object creates an h file


3 files changed, 8 insertions(+), 4 deletions(-)

src/all_types.hpp+1
...@@ -1256,6 +1256,7 @@ struct CodeGen {...@@ -1256,6 +1256,7 @@ struct CodeGen {
1256 bool is_big_endian;1256 bool is_big_endian;
1257 bool is_static;1257 bool is_static;
1258 bool strip_debug_symbols;1258 bool strip_debug_symbols;
1259 bool want_h_file;
1259 bool have_exported_main;1260 bool have_exported_main;
1260 bool link_libc;1261 bool link_libc;
1261 Buf *libc_lib_dir;1262 Buf *libc_lib_dir;
src/codegen.cpp+1
...@@ -63,6 +63,7 @@ CodeGen *codegen_create(Buf *root_source_dir, const ZigTarget *target) {...@@ -63,6 +63,7 @@ CodeGen *codegen_create(Buf *root_source_dir, const ZigTarget *target) {
63 g->generic_table.init(16);63 g->generic_table.init(16);
64 g->is_release_build = false;64 g->is_release_build = false;
65 g->is_test_build = false;65 g->is_test_build = false;
66 g->want_h_file = true;
6667
67 // the error.Ok value68 // the error.Ok value
68 g->error_decls.append(nullptr);69 g->error_decls.append(nullptr);
src/link.cpp+6-4
...@@ -38,6 +38,7 @@ static Buf *build_o(CodeGen *parent_gen, const char *oname) {...@@ -38,6 +38,7 @@ static Buf *build_o(CodeGen *parent_gen, const char *oname) {
38 ZigTarget *child_target = parent_gen->is_native_target ? nullptr : &parent_gen->zig_target;38 ZigTarget *child_target = parent_gen->is_native_target ? nullptr : &parent_gen->zig_target;
39 CodeGen *child_gen = codegen_create(std_dir_path, child_target);39 CodeGen *child_gen = codegen_create(std_dir_path, child_target);
40 child_gen->link_libc = parent_gen->link_libc;40 child_gen->link_libc = parent_gen->link_libc;
41 child_gen->want_h_file = false;
4142
42 codegen_set_is_release(child_gen, parent_gen->is_release_build);43 codegen_set_is_release(child_gen, parent_gen->is_release_build);
4344
...@@ -793,10 +794,8 @@ void codegen_link(CodeGen *g, const char *out_file) {...@@ -793,10 +794,8 @@ void codegen_link(CodeGen *g, const char *out_file) {
793794
794 buf_init_from_buf(&lj.out_file_o, &lj.out_file);795 buf_init_from_buf(&lj.out_file_o, &lj.out_file);
795796
796 if (g->out_type != OutTypeObj) {797 const char *o_ext = get_o_file_extension(g);
797 const char *o_ext = get_o_file_extension(g);798 buf_append_str(&lj.out_file_o, o_ext);
798 buf_append_str(&lj.out_file_o, o_ext);
799 }
800799
801 char *err_msg = nullptr;800 char *err_msg = nullptr;
802 if (LLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(&lj.out_file_o),801 if (LLVMTargetMachineEmitToFile(g->target_machine, g->module, buf_ptr(&lj.out_file_o),
...@@ -806,6 +805,9 @@ void codegen_link(CodeGen *g, const char *out_file) {...@@ -806,6 +805,9 @@ void codegen_link(CodeGen *g, const char *out_file) {
806 }805 }
807806
808 if (g->out_type == OutTypeObj) {807 if (g->out_type == OutTypeObj) {
808 if (g->want_h_file) {
809 codegen_generate_h_file(g);
810 }
809 if (g->verbose) {811 if (g->verbose) {
810 fprintf(stderr, "OK\n");812 fprintf(stderr, "OK\n");
811 }813 }