| author | |
| committer | |
| log | ba78ae0ae73ac38a2bb32c618cd145b4d2f9602e |
| tree | 0b2787ddc68361852859e2b1ca5cf7a51e04fe72 |
| parent | 418b2e7d47cbfdd8d04c362b758c96b533674282 |
* build: only do codegen_link when emitting an actual binary. Fixes #1371
* build: only output C header file when explicitely asked to
4 files changed, 5 insertions(+), 18 deletions(-)
src/all_types.hpp-1| ... | ... | @@ -1713,7 +1713,6 @@ struct CodeGen { |
| 1713 | 1713 | uint32_t target_environ_index; |
| 1714 | 1714 | uint32_t target_oformat_index; |
| 1715 | 1715 | bool is_big_endian; |
| 1716 | bool want_h_file; | |
| 1717 | 1716 | bool have_pub_main; |
| 1718 | 1717 | bool have_c_main; |
| 1719 | 1718 | bool have_winmain; |
src/codegen.cpp+2-14| ... | ... | @@ -118,7 +118,6 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out |
| 118 | 118 | g->string_literals_table.init(16); |
| 119 | 119 | g->type_info_cache.init(32); |
| 120 | 120 | g->is_test_build = false; |
| 121 | g->want_h_file = (out_type == OutTypeObj || out_type == OutTypeLib); | |
| 122 | 121 | buf_resize(&g->global_asm, 0); |
| 123 | 122 | |
| 124 | 123 | for (size_t i = 0; i < array_length(symbols_that_llvm_depends_on); i += 1) { |
| ... | ... | @@ -8127,17 +8126,6 @@ static void resolve_out_paths(CodeGen *g) { |
| 8127 | 8126 | } else { |
| 8128 | 8127 | zig_unreachable(); |
| 8129 | 8128 | } |
| 8130 | ||
| 8131 | if (g->want_h_file && !g->out_h_path) { | |
| 8132 | assert(g->root_out_name); | |
| 8133 | Buf *h_basename = buf_sprintf("%s.h", buf_ptr(g->root_out_name)); | |
| 8134 | if (g->enable_cache) { | |
| 8135 | g->out_h_path = buf_alloc(); | |
| 8136 | os_path_join(&g->artifact_dir, h_basename, g->out_h_path); | |
| 8137 | } else { | |
| 8138 | g->out_h_path = h_basename; | |
| 8139 | } | |
| 8140 | } | |
| 8141 | 8129 | } |
| 8142 | 8130 | |
| 8143 | 8131 | |
| ... | ... | @@ -8193,11 +8181,11 @@ void codegen_build_and_link(CodeGen *g) { |
| 8193 | 8181 | codegen_add_time_event(g, "LLVM Emit Output"); |
| 8194 | 8182 | zig_llvm_emit_output(g); |
| 8195 | 8183 | |
| 8196 | if (g->want_h_file) { | |
| 8184 | if (g->out_h_path != nullptr) { | |
| 8197 | 8185 | codegen_add_time_event(g, "Generate .h"); |
| 8198 | 8186 | gen_h_file(g); |
| 8199 | 8187 | } |
| 8200 | if (g->out_type != OutTypeObj) { | |
| 8188 | if (g->out_type != OutTypeObj && g->emit_file_type == EmitFileTypeBinary) { | |
| 8201 | 8189 | codegen_link(g); |
| 8202 | 8190 | } |
| 8203 | 8191 | } |
src/link.cpp+1-1| ... | ... | @@ -34,7 +34,7 @@ static Buf *build_o_raw(CodeGen *parent_gen, const char *oname, Buf *full_path) |
| 34 | 34 | CodeGen *child_gen = codegen_create(full_path, child_target, OutTypeObj, parent_gen->build_mode, |
| 35 | 35 | parent_gen->zig_lib_dir); |
| 36 | 36 | |
| 37 | child_gen->want_h_file = false; | |
| 37 | child_gen->out_h_path = nullptr; | |
| 38 | 38 | child_gen->verbose_tokenize = parent_gen->verbose_tokenize; |
| 39 | 39 | child_gen->verbose_ast = parent_gen->verbose_ast; |
| 40 | 40 | child_gen->verbose_link = parent_gen->verbose_link; |
src/main.cpp+2-2| ... | ... | @@ -52,7 +52,7 @@ static int print_full_usage(const char *arg0) { |
| 52 | 52 | " --libc-include-dir [path] directory where libc stdlib.h resides\n" |
| 53 | 53 | " --name [name] override output name\n" |
| 54 | 54 | " --output [file] override destination path\n" |
| 55 | " --output-h [file] override generated header file path\n" | |
| 55 | " --output-h [file] generate header file\n" | |
| 56 | 56 | " --pkg-begin [name] [path] make pkg available to import and push current pkg\n" |
| 57 | 57 | " --pkg-end pop current pkg\n" |
| 58 | 58 | " --release-fast build with optimizations on and safety off\n" |
| ... | ... | @@ -926,7 +926,7 @@ int main(int argc, char **argv) { |
| 926 | 926 | |
| 927 | 927 | if (out_file) |
| 928 | 928 | codegen_set_output_path(g, buf_create_from_str(out_file)); |
| 929 | if (out_file_h) | |
| 929 | if (out_file_h != nullptr && (out_type == OutTypeObj || out_type == OutTypeLib)) | |
| 930 | 930 | codegen_set_output_h_path(g, buf_create_from_str(out_file_h)); |
| 931 | 931 | |
| 932 | 932 |