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 {
12561256 bool is_big_endian;
12571257 bool is_static;
12581258 bool strip_debug_symbols;
1259 bool want_h_file;
12591260 bool have_exported_main;
12601261 bool link_libc;
12611262 Buf *libc_lib_dir;
src/codegen.cpp+1
......@@ -63,6 +63,7 @@ CodeGen *codegen_create(Buf *root_source_dir, const ZigTarget *target) {
6363 g->generic_table.init(16);
6464 g->is_release_build = false;
6565 g->is_test_build = false;
66 g->want_h_file = true;
6667
6768 // the error.Ok value
6869 g->error_decls.append(nullptr);
src/link.cpp+6-4
......@@ -38,6 +38,7 @@ static Buf *build_o(CodeGen *parent_gen, const char *oname) {
3838 ZigTarget *child_target = parent_gen->is_native_target ? nullptr : &parent_gen->zig_target;
3939 CodeGen *child_gen = codegen_create(std_dir_path, child_target);
4040 child_gen->link_libc = parent_gen->link_libc;
41 child_gen->want_h_file = false;
4142
4243 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) {
793794
794795 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);
798 buf_append_str(&lj.out_file_o, o_ext);
799 }
797 const char *o_ext = get_o_file_extension(g);
798 buf_append_str(&lj.out_file_o, o_ext);
800799
801800 char *err_msg = nullptr;
802801 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) {
806805 }
807806
808807 if (g->out_type == OutTypeObj) {
808 if (g->want_h_file) {
809 codegen_generate_h_file(g);
810 }
809811 if (g->verbose) {
810812 fprintf(stderr, "OK\n");
811813 }