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 {
17131713 uint32_t target_environ_index;
17141714 uint32_t target_oformat_index;
17151715 bool is_big_endian;
1716 bool want_h_file;
17171716 bool have_pub_main;
17181717 bool have_c_main;
17191718 bool have_winmain;
src/codegen.cpp+2-14
......@@ -118,7 +118,6 @@ CodeGen *codegen_create(Buf *root_src_path, const ZigTarget *target, OutType out
118118 g->string_literals_table.init(16);
119119 g->type_info_cache.init(32);
120120 g->is_test_build = false;
121 g->want_h_file = (out_type == OutTypeObj || out_type == OutTypeLib);
122121 buf_resize(&g->global_asm, 0);
123122
124123 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) {
81278126 } else {
81288127 zig_unreachable();
81298128 }
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 }
81418129}
81428130
81438131
......@@ -8193,11 +8181,11 @@ void codegen_build_and_link(CodeGen *g) {
81938181 codegen_add_time_event(g, "LLVM Emit Output");
81948182 zig_llvm_emit_output(g);
81958183
8196 if (g->want_h_file) {
8184 if (g->out_h_path != nullptr) {
81978185 codegen_add_time_event(g, "Generate .h");
81988186 gen_h_file(g);
81998187 }
8200 if (g->out_type != OutTypeObj) {
8188 if (g->out_type != OutTypeObj && g->emit_file_type == EmitFileTypeBinary) {
82018189 codegen_link(g);
82028190 }
82038191 }
src/link.cpp+1-1
......@@ -34,7 +34,7 @@ static Buf *build_o_raw(CodeGen *parent_gen, const char *oname, Buf *full_path)
3434 CodeGen *child_gen = codegen_create(full_path, child_target, OutTypeObj, parent_gen->build_mode,
3535 parent_gen->zig_lib_dir);
3636
37 child_gen->want_h_file = false;
37 child_gen->out_h_path = nullptr;
3838 child_gen->verbose_tokenize = parent_gen->verbose_tokenize;
3939 child_gen->verbose_ast = parent_gen->verbose_ast;
4040 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) {
5252 " --libc-include-dir [path] directory where libc stdlib.h resides\n"
5353 " --name [name] override output name\n"
5454 " --output [file] override destination path\n"
55 " --output-h [file] override generated header file path\n"
55 " --output-h [file] generate header file\n"
5656 " --pkg-begin [name] [path] make pkg available to import and push current pkg\n"
5757 " --pkg-end pop current pkg\n"
5858 " --release-fast build with optimizations on and safety off\n"
......@@ -926,7 +926,7 @@ int main(int argc, char **argv) {
926926
927927 if (out_file)
928928 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))
930930 codegen_set_output_h_path(g, buf_create_from_str(out_file_h));
931931
932932