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 {
15081508 size_t version_minor;
15091509 size_t version_patch;
15101510 bool verbose;
1511 bool verbose_link;
15111512 ErrColor err_color;
15121513 ImportTableEntry *root_import;
15131514 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)
3737
3838 codegen_set_omit_zigrt(child_gen, true);
3939 child_gen->want_h_file = false;
40 child_gen->verbose_link = parent_gen->verbose_link;
4041
4142 codegen_set_cache_dir(child_gen, parent_gen->cache_dir);
4243
......@@ -816,7 +817,7 @@ void codegen_link(CodeGen *g, const char *out_file) {
816817 fprintf(stderr, "---------------\n");
817818 LLVMDumpModule(g->module);
818819 }
819 if (g->verbose) {
820 if (g->verbose || g->verbose_link) {
820821 fprintf(stderr, "\nLink:\n");
821822 fprintf(stderr, "-------\n");
822823 }
......@@ -840,7 +841,7 @@ void codegen_link(CodeGen *g, const char *out_file) {
840841 zig_panic("unable to rename object file into final output: %s", err_str(err));
841842 }
842843 }
843 if (g->verbose) {
844 if (g->verbose || g->verbose_link) {
844845 fprintf(stderr, "OK\n");
845846 }
846847 return;
......@@ -860,7 +861,7 @@ void codegen_link(CodeGen *g, const char *out_file) {
860861 construct_linker_job(&lj);
861862
862863
863 if (g->verbose) {
864 if (g->verbose || g->verbose_link) {
864865 for (size_t i = 0; i < lj.args.length; i += 1) {
865866 const char *space = (i != 0) ? " " : "";
866867 fprintf(stderr, "%s%s", space, lj.args.at(i));
......@@ -878,7 +879,7 @@ void codegen_link(CodeGen *g, const char *out_file) {
878879
879880 codegen_add_time_event(g, "Done");
880881
881 if (g->verbose) {
882 if (g->verbose || g->verbose_link) {
882883 fprintf(stderr, "OK\n");
883884 }
884885}
src/main.cpp+5
......@@ -47,6 +47,7 @@ static int usage(const char *arg0) {
4747 " --target-environ [name] specify target environment\n"
4848 " --target-os [name] specify target operating system\n"
4949 " --verbose turn on compiler debug output\n"
50 " --verbose-link turn on compiler debug output for linking only\n"
5051 " --zig-std-dir [path] directory where zig standard library resides\n"
5152 " -dirafter [dir] same as -isystem but do it last\n"
5253 " -isystem [dir] add additional search path for other .h files\n"
......@@ -184,6 +185,7 @@ int main(int argc, char **argv) {
184185 OutType out_type = OutTypeUnknown;
185186 const char *out_name = nullptr;
186187 bool verbose = false;
188 bool verbose_link = false;
187189 ErrColor color = ErrColorAuto;
188190 const char *libc_lib_dir = nullptr;
189191 const char *libc_static_lib_dir = nullptr;
......@@ -348,6 +350,8 @@ int main(int argc, char **argv) {
348350 is_static = true;
349351 } else if (strcmp(arg, "--verbose") == 0) {
350352 verbose = true;
353 } else if (strcmp(arg, "--verbose-link") == 0) {
354 verbose_link = true;
351355 } else if (strcmp(arg, "-mwindows") == 0) {
352356 mwindows = true;
353357 } else if (strcmp(arg, "-mconsole") == 0) {
......@@ -625,6 +629,7 @@ int main(int argc, char **argv) {
625629 if (dynamic_linker)
626630 codegen_set_dynamic_linker(g, buf_create_from_str(dynamic_linker));
627631 codegen_set_verbose(g, verbose);
632 g->verbose_link = verbose_link;
628633 codegen_set_errmsg_color(g, color);
629634
630635 for (size_t i = 0; i < lib_dirs.length; i += 1) {