authorgravatar for Sahnvour@users.noreply.github.comSahnvour <Sahnvour@users.noreply.github.com> 2018-09-30 22:59:45+02:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2018-09-30 16:59:45-04:00
logba78ae0ae73ac38a2bb32c618cd145b4d2f9602e
tree0b2787ddc68361852859e2b1ca5cf7a51e04fe72
parent418b2e7d47cbfdd8d04c362b758c96b533674282

Fixes --emit asm on windows and makes C header file generation explicit. (#1612)

* 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,7 +1713,6 @@ struct CodeGen {
1713 uint32_t target_environ_index;1713 uint32_t target_environ_index;
1714 uint32_t target_oformat_index;1714 uint32_t target_oformat_index;
1715 bool is_big_endian;1715 bool is_big_endian;
1716 bool want_h_file;
1717 bool have_pub_main;1716 bool have_pub_main;
1718 bool have_c_main;1717 bool have_c_main;
1719 bool have_winmain;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,7 +118,6 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out
118 g->string_literals_table.init(16);118 g->string_literals_table.init(16);
119 g->type_info_cache.init(32);119 g->type_info_cache.init(32);
120 g->is_test_build = false;120 g->is_test_build = false;
121 g->want_h_file = (out_type == OutTypeObj || out_type == OutTypeLib);
122 buf_resize(&g->global_asm, 0);121 buf_resize(&g->global_asm, 0);
123122
124 for (size_t i = 0; i < array_length(symbols_that_llvm_depends_on); i += 1) {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,17 +8126,6 @@ static void resolve_out_paths(CodeGen *g) {
8127 } else {8126 } else {
8128 zig_unreachable();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}
81428130
81438131
...@@ -8193,11 +8181,11 @@ void codegen_build_and_link(CodeGen *g) {...@@ -8193,11 +8181,11 @@ void codegen_build_and_link(CodeGen *g) {
8193 codegen_add_time_event(g, "LLVM Emit Output");8181 codegen_add_time_event(g, "LLVM Emit Output");
8194 zig_llvm_emit_output(g);8182 zig_llvm_emit_output(g);
81958183
8196 if (g->want_h_file) {8184 if (g->out_h_path != nullptr) {
8197 codegen_add_time_event(g, "Generate .h");8185 codegen_add_time_event(g, "Generate .h");
8198 gen_h_file(g);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 codegen_link(g);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,7 +34,7 @@ static Buf *build_o_raw(CodeGen *parent_gen, const char *oname, Buf *full_path)
34 CodeGen *child_gen = codegen_create(full_path, child_target, OutTypeObj, parent_gen->build_mode,34 CodeGen *child_gen = codegen_create(full_path, child_target, OutTypeObj, parent_gen->build_mode,
35 parent_gen->zig_lib_dir);35 parent_gen->zig_lib_dir);
3636
37 child_gen->want_h_file = false;37 child_gen->out_h_path = nullptr;
38 child_gen->verbose_tokenize = parent_gen->verbose_tokenize;38 child_gen->verbose_tokenize = parent_gen->verbose_tokenize;
39 child_gen->verbose_ast = parent_gen->verbose_ast;39 child_gen->verbose_ast = parent_gen->verbose_ast;
40 child_gen->verbose_link = parent_gen->verbose_link;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,7 +52,7 @@ static int print_full_usage(const char *arg0) {
52 " --libc-include-dir [path] directory where libc stdlib.h resides\n"52 " --libc-include-dir [path] directory where libc stdlib.h resides\n"
53 " --name [name] override output name\n"53 " --name [name] override output name\n"
54 " --output [file] override destination path\n"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 " --pkg-begin [name] [path] make pkg available to import and push current pkg\n"56 " --pkg-begin [name] [path] make pkg available to import and push current pkg\n"
57 " --pkg-end pop current pkg\n"57 " --pkg-end pop current pkg\n"
58 " --release-fast build with optimizations on and safety off\n"58 " --release-fast build with optimizations on and safety off\n"
...@@ -926,7 +926,7 @@ int main(int argc, char **argv) {...@@ -926,7 +926,7 @@ int main(int argc, char **argv) {
926926
927 if (out_file)927 if (out_file)
928 codegen_set_output_path(g, buf_create_from_str(out_file));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 codegen_set_output_h_path(g, buf_create_from_str(out_file_h));930 codegen_set_output_h_path(g, buf_create_from_str(out_file_h));
931931
932932