authorgravatar for thatlemon@gmail.comLemonBoy <thatlemon@gmail.com> 2020-11-19 23:30:16+01:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2020-11-19 23:30:16+01:00
log8eaaa905f709db623432a95fd9d4e4dfecdb7eae
tree653c13dfef4ede70444d15895a839a5b9887e37a
parent647c6e0d0955260947d9a0e07014af2a337d9330
signaturebadge-question-mark Signed by PGP key 4AEE18F83AFDEB23

stage2: Make zig cc more verbose (#7166)

* stage2: Make zig cc more verbose Make `zig cc` print more info from Clang itself and from our own linker invocation, this is needed for CMake to properly discover all the include directories and library search paths. Closes #7110 * Update `update_clang_options` * Typo fixes Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>

7 files changed, 47 insertions(+), 14 deletions(-)

src/clang_options_data.zig+9-2
......@@ -165,7 +165,7 @@ sepd1("Zlinker-input"),
165165.{
166166 .name = "###",
167167 .syntax = .flag,
168 .zig_equivalent = .verbose_cmds,
168 .zig_equivalent = .dry_run,
169169 .pd1 = true,
170170 .pd2 = false,
171171 .psl = false,
......@@ -4439,7 +4439,14 @@ flagpd1("twolevel_namespace_hints"),
44394439sepd1("umbrella"),
44404440flagpd1("undef"),
44414441sepd1("unexported_symbols_list"),
4442flagpd1("v"),
4442.{
4443 .name = "v",
4444 .syntax = .flag,
4445 .zig_equivalent = .verbose,
4446 .pd1 = true,
4447 .pd2 = false,
4448 .psl = false,
4449},
44434450flagpd1("vectorize-loops"),
44444451flagpd1("vectorize-slp"),
44454452flagpd1("verify"),
src/link/Coff.zig+5-2
......@@ -907,8 +907,11 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {
907907 // Create an LLD command line and invoke it.
908908 var argv = std.ArrayList([]const u8).init(self.base.allocator);
909909 defer argv.deinit();
910 // Even though we're calling LLD as a library it thinks the first argument is its own exe name.
911 try argv.append("lld");
910 // The first argument is ignored as LLD is called as a library, set it
911 // anyway to the correct LLD driver name for this target so that it's
912 // correctly printed when `verbose_link` is true. This is needed for some
913 // tools such as CMake when Zig is used as C compiler.
914 try argv.append("lld-link");
912915
913916 try argv.append("-ERRORLIMIT:0");
914917 try argv.append("-NOLOGO");
src/link/Elf.zig+5-2
......@@ -1353,8 +1353,11 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
13531353 // Create an LLD command line and invoke it.
13541354 var argv = std.ArrayList([]const u8).init(self.base.allocator);
13551355 defer argv.deinit();
1356 // Even though we're calling LLD as a library it thinks the first argument is its own exe name.
1357 try argv.append("lld");
1356 // The first argument is ignored as LLD is called as a library, set it
1357 // anyway to the correct LLD driver name for this target so that it's
1358 // correctly printed when `verbose_link` is true. This is needed for some
1359 // tools such as CMake when Zig is used as C compiler.
1360 try argv.append("ld.lld");
13581361 if (is_obj) {
13591362 try argv.append("-r");
13601363 }
src/link/MachO.zig+6-2
......@@ -542,8 +542,12 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
542542 if (self.base.options.system_linker_hack) {
543543 try argv.append("ld");
544544 } else {
545 // Even though we're calling LLD as a library it thinks the first argument is its own exe name.
546 try argv.append("lld");
545 // The first argument is ignored as LLD is called as a library, set
546 // it anyway to the correct LLD driver name for this target so that
547 // it's correctly printed when `verbose_link` is true. This is
548 // needed for some tools such as CMake when Zig is used as C
549 // compiler.
550 try argv.append("ld64");
547551
548552 try argv.append("-error-limit");
549553 try argv.append("0");
src/link/Wasm.zig+5-2
......@@ -339,8 +339,11 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
339339 // Create an LLD command line and invoke it.
340340 var argv = std.ArrayList([]const u8).init(self.base.allocator);
341341 defer argv.deinit();
342 // Even though we're calling LLD as a library it thinks the first argument is its own exe name.
343 try argv.append("lld");
342 // The first argument is ignored as LLD is called as a library, set it
343 // anyway to the correct LLD driver name for this target so that it's
344 // correctly printed when `verbose_link` is true. This is needed for some
345 // tools such as CMake when Zig is used as C compiler.
346 try argv.append("ld-wasm");
344347 if (is_obj) {
345348 try argv.append("-r");
346349 }
src/main.zig+12-3
......@@ -1062,9 +1062,17 @@ fn buildOutputType(
10621062 }
10631063 },
10641064 .linker_script => linker_script = it.only_arg,
1065 .verbose_cmds => {
1066 verbose_cc = true;
1065 .verbose => {
1066 verbose_link = true;
1067 // Have Clang print more infos, some tools such as CMake
1068 // parse this to discover any implicit include and
1069 // library dir to look-up into.
1070 try clang_argv.append("-v");
1071 },
1072 .dry_run => {
10671073 verbose_link = true;
1074 try clang_argv.append("-###");
1075 // XXX: Don't execute anything!
10681076 },
10691077 .for_linker => try linker_args.append(it.only_arg),
10701078 .linker_input_z => {
......@@ -2776,7 +2784,8 @@ pub const ClangArgIterator = struct {
27762784 debug,
27772785 sanitize,
27782786 linker_script,
2779 verbose_cmds,
2787 dry_run,
2788 verbose,
27802789 for_linker,
27812790 linker_input_z,
27822791 lib_dir,
tools/update_clang_options.zig+5-1
......@@ -214,7 +214,11 @@ const known_options = [_]KnownOpt{
214214 },
215215 .{
216216 .name = "###",
217 .ident = "verbose_cmds",
217 .ident = "dry_run",
218 },
219 .{
220 .name = "v",
221 .ident = "verbose",
218222 },
219223 .{
220224 .name = "L",