authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-18 21:06:53-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-09-18 21:06:53-04:00
log46ddeb0bafd68cf88867e4268253a41ac0050215
tree41f05646aa4707ee86df9d33b7c3c2ab3d5cf3ca
parent10ad3253de4dad4675fbd84da874f2cd73cd2deb

add --verbose-link option

only prints the link line

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

src/all_types.hpp+1
...@@ -1508,6 +1508,7 @@ struct CodeGen {...@@ -1508,6 +1508,7 @@ struct CodeGen {
1508 size_t version_minor;1508 size_t version_minor;
1509 size_t version_patch;1509 size_t version_patch;
1510 bool verbose;1510 bool verbose;
1511 bool verbose_link;
1511 ErrColor err_color;1512 ErrColor err_color;
1512 ImportTableEntry *root_import;1513 ImportTableEntry *root_import;
1513 ImportTableEntry *bootstrap_import;1514 ImportTableEntry *bootstrap_import;
src/link.cpp+5-4
...@@ -37,6 +37,7 @@ static Buf *build_o_raw(CodeGen *parent_gen, const char *oname, Buf *full_path)...@@ -37,6 +37,7 @@ static Buf *build_o_raw(CodeGen *parent_gen, const char *oname, Buf *full_path)
3737
38 codegen_set_omit_zigrt(child_gen, true);38 codegen_set_omit_zigrt(child_gen, true);
39 child_gen->want_h_file = false;39 child_gen->want_h_file = false;
40 child_gen->verbose_link = parent_gen->verbose_link;
4041
41 codegen_set_cache_dir(child_gen, parent_gen->cache_dir);42 codegen_set_cache_dir(child_gen, parent_gen->cache_dir);
4243
...@@ -816,7 +817,7 @@ void codegen_link(CodeGen *g, const char *out_file) {...@@ -816,7 +817,7 @@ void codegen_link(CodeGen *g, const char *out_file) {
816 fprintf(stderr, "---------------\n");817 fprintf(stderr, "---------------\n");
817 LLVMDumpModule(g->module);818 LLVMDumpModule(g->module);
818 }819 }
819 if (g->verbose) {820 if (g->verbose || g->verbose_link) {
820 fprintf(stderr, "\nLink:\n");821 fprintf(stderr, "\nLink:\n");
821 fprintf(stderr, "-------\n");822 fprintf(stderr, "-------\n");
822 }823 }
...@@ -840,7 +841,7 @@ void codegen_link(CodeGen *g, const char *out_file) {...@@ -840,7 +841,7 @@ void codegen_link(CodeGen *g, const char *out_file) {
840 zig_panic("unable to rename object file into final output: %s", err_str(err));841 zig_panic("unable to rename object file into final output: %s", err_str(err));
841 }842 }
842 }843 }
843 if (g->verbose) {844 if (g->verbose || g->verbose_link) {
844 fprintf(stderr, "OK\n");845 fprintf(stderr, "OK\n");
845 }846 }
846 return;847 return;
...@@ -860,7 +861,7 @@ void codegen_link(CodeGen *g, const char *out_file) {...@@ -860,7 +861,7 @@ void codegen_link(CodeGen *g, const char *out_file) {
860 construct_linker_job(&lj);861 construct_linker_job(&lj);
861862
862863
863 if (g->verbose) {864 if (g->verbose || g->verbose_link) {
864 for (size_t i = 0; i < lj.args.length; i += 1) {865 for (size_t i = 0; i < lj.args.length; i += 1) {
865 const char *space = (i != 0) ? " " : "";866 const char *space = (i != 0) ? " " : "";
866 fprintf(stderr, "%s%s", space, lj.args.at(i));867 fprintf(stderr, "%s%s", space, lj.args.at(i));
...@@ -878,7 +879,7 @@ void codegen_link(CodeGen *g, const char *out_file) {...@@ -878,7 +879,7 @@ void codegen_link(CodeGen *g, const char *out_file) {
878879
879 codegen_add_time_event(g, "Done");880 codegen_add_time_event(g, "Done");
880881
881 if (g->verbose) {882 if (g->verbose || g->verbose_link) {
882 fprintf(stderr, "OK\n");883 fprintf(stderr, "OK\n");
883 }884 }
884}885}
src/main.cpp+5
...@@ -47,6 +47,7 @@ static int usage(const char *arg0) {...@@ -47,6 +47,7 @@ static int usage(const char *arg0) {
47 " --target-environ [name] specify target environment\n"47 " --target-environ [name] specify target environment\n"
48 " --target-os [name] specify target operating system\n"48 " --target-os [name] specify target operating system\n"
49 " --verbose turn on compiler debug output\n"49 " --verbose turn on compiler debug output\n"
50 " --verbose-link turn on compiler debug output for linking only\n"
50 " --zig-std-dir [path] directory where zig standard library resides\n"51 " --zig-std-dir [path] directory where zig standard library resides\n"
51 " -dirafter [dir] same as -isystem but do it last\n"52 " -dirafter [dir] same as -isystem but do it last\n"
52 " -isystem [dir] add additional search path for other .h files\n"53 " -isystem [dir] add additional search path for other .h files\n"
...@@ -184,6 +185,7 @@ int main(int argc, char **argv) {...@@ -184,6 +185,7 @@ int main(int argc, char **argv) {
184 OutType out_type = OutTypeUnknown;185 OutType out_type = OutTypeUnknown;
185 const char *out_name = nullptr;186 const char *out_name = nullptr;
186 bool verbose = false;187 bool verbose = false;
188 bool verbose_link = false;
187 ErrColor color = ErrColorAuto;189 ErrColor color = ErrColorAuto;
188 const char *libc_lib_dir = nullptr;190 const char *libc_lib_dir = nullptr;
189 const char *libc_static_lib_dir = nullptr;191 const char *libc_static_lib_dir = nullptr;
...@@ -348,6 +350,8 @@ int main(int argc, char **argv) {...@@ -348,6 +350,8 @@ int main(int argc, char **argv) {
348 is_static = true;350 is_static = true;
349 } else if (strcmp(arg, "--verbose") == 0) {351 } else if (strcmp(arg, "--verbose") == 0) {
350 verbose = true;352 verbose = true;
353 } else if (strcmp(arg, "--verbose-link") == 0) {
354 verbose_link = true;
351 } else if (strcmp(arg, "-mwindows") == 0) {355 } else if (strcmp(arg, "-mwindows") == 0) {
352 mwindows = true;356 mwindows = true;
353 } else if (strcmp(arg, "-mconsole") == 0) {357 } else if (strcmp(arg, "-mconsole") == 0) {
...@@ -625,6 +629,7 @@ int main(int argc, char **argv) {...@@ -625,6 +629,7 @@ int main(int argc, char **argv) {
625 if (dynamic_linker)629 if (dynamic_linker)
626 codegen_set_dynamic_linker(g, buf_create_from_str(dynamic_linker));630 codegen_set_dynamic_linker(g, buf_create_from_str(dynamic_linker));
627 codegen_set_verbose(g, verbose);631 codegen_set_verbose(g, verbose);
632 g->verbose_link = verbose_link;
628 codegen_set_errmsg_color(g, color);633 codegen_set_errmsg_color(g, color);
629634
630 for (size_t i = 0; i < lib_dirs.length; i += 1) {635 for (size_t i = 0; i < lib_dirs.length; i += 1) {