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"),...@@ -165,7 +165,7 @@ sepd1("Zlinker-input"),
165.{165.{
166 .name = "###",166 .name = "###",
167 .syntax = .flag,167 .syntax = .flag,
168 .zig_equivalent = .verbose_cmds,168 .zig_equivalent = .dry_run,
169 .pd1 = true,169 .pd1 = true,
170 .pd2 = false,170 .pd2 = false,
171 .psl = false,171 .psl = false,
...@@ -4439,7 +4439,14 @@ flagpd1("twolevel_namespace_hints"),...@@ -4439,7 +4439,14 @@ flagpd1("twolevel_namespace_hints"),
4439sepd1("umbrella"),4439sepd1("umbrella"),
4440flagpd1("undef"),4440flagpd1("undef"),
4441sepd1("unexported_symbols_list"),4441sepd1("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},
4443flagpd1("vectorize-loops"),4450flagpd1("vectorize-loops"),
4444flagpd1("vectorize-slp"),4451flagpd1("vectorize-slp"),
4445flagpd1("verify"),4452flagpd1("verify"),
src/link/Coff.zig+5-2
...@@ -907,8 +907,11 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {...@@ -907,8 +907,11 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void {
907 // Create an LLD command line and invoke it.907 // Create an LLD command line and invoke it.
908 var argv = std.ArrayList([]const u8).init(self.base.allocator);908 var argv = std.ArrayList([]const u8).init(self.base.allocator);
909 defer argv.deinit();909 defer argv.deinit();
910 // Even though we're calling LLD as a library it thinks the first argument is its own exe name.910 // The first argument is ignored as LLD is called as a library, set it
911 try argv.append("lld");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
913 try argv.append("-ERRORLIMIT:0");916 try argv.append("-ERRORLIMIT:0");
914 try argv.append("-NOLOGO");917 try argv.append("-NOLOGO");
src/link/Elf.zig+5-2
...@@ -1353,8 +1353,11 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {...@@ -1353,8 +1353,11 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void {
1353 // Create an LLD command line and invoke it.1353 // Create an LLD command line and invoke it.
1354 var argv = std.ArrayList([]const u8).init(self.base.allocator);1354 var argv = std.ArrayList([]const u8).init(self.base.allocator);
1355 defer argv.deinit();1355 defer argv.deinit();
1356 // Even though we're calling LLD as a library it thinks the first argument is its own exe name.1356 // The first argument is ignored as LLD is called as a library, set it
1357 try argv.append("lld");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");
1358 if (is_obj) {1361 if (is_obj) {
1359 try argv.append("-r");1362 try argv.append("-r");
1360 }1363 }
src/link/MachO.zig+6-2
...@@ -542,8 +542,12 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {...@@ -542,8 +542,12 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
542 if (self.base.options.system_linker_hack) {542 if (self.base.options.system_linker_hack) {
543 try argv.append("ld");543 try argv.append("ld");
544 } else {544 } else {
545 // Even though we're calling LLD as a library it thinks the first argument is its own exe name.545 // The first argument is ignored as LLD is called as a library, set
546 try argv.append("lld");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
548 try argv.append("-error-limit");552 try argv.append("-error-limit");
549 try argv.append("0");553 try argv.append("0");
src/link/Wasm.zig+5-2
...@@ -339,8 +339,11 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {...@@ -339,8 +339,11 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void {
339 // Create an LLD command line and invoke it.339 // Create an LLD command line and invoke it.
340 var argv = std.ArrayList([]const u8).init(self.base.allocator);340 var argv = std.ArrayList([]const u8).init(self.base.allocator);
341 defer argv.deinit();341 defer argv.deinit();
342 // Even though we're calling LLD as a library it thinks the first argument is its own exe name.342 // The first argument is ignored as LLD is called as a library, set it
343 try argv.append("lld");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");
344 if (is_obj) {347 if (is_obj) {
345 try argv.append("-r");348 try argv.append("-r");
346 }349 }
src/main.zig+12-3
...@@ -1062,9 +1062,17 @@ fn buildOutputType(...@@ -1062,9 +1062,17 @@ fn buildOutputType(
1062 }1062 }
1063 },1063 },
1064 .linker_script => linker_script = it.only_arg,1064 .linker_script => linker_script = it.only_arg,
1065 .verbose_cmds => {1065 .verbose => {
1066 verbose_cc = true;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 => {
1067 verbose_link = true;1073 verbose_link = true;
1074 try clang_argv.append("-###");
1075 // XXX: Don't execute anything!
1068 },1076 },
1069 .for_linker => try linker_args.append(it.only_arg),1077 .for_linker => try linker_args.append(it.only_arg),
1070 .linker_input_z => {1078 .linker_input_z => {
...@@ -2776,7 +2784,8 @@ pub const ClangArgIterator = struct {...@@ -2776,7 +2784,8 @@ pub const ClangArgIterator = struct {
2776 debug,2784 debug,
2777 sanitize,2785 sanitize,
2778 linker_script,2786 linker_script,
2779 verbose_cmds,2787 dry_run,
2788 verbose,
2780 for_linker,2789 for_linker,
2781 linker_input_z,2790 linker_input_z,
2782 lib_dir,2791 lib_dir,
tools/update_clang_options.zig+5-1
...@@ -214,7 +214,11 @@ const known_options = [_]KnownOpt{...@@ -214,7 +214,11 @@ const known_options = [_]KnownOpt{
214 },214 },
215 .{215 .{
216 .name = "###",216 .name = "###",
217 .ident = "verbose_cmds",217 .ident = "dry_run",
218 },
219 .{
220 .name = "v",
221 .ident = "verbose",
218 },222 },
219 .{223 .{
220 .name = "L",224 .name = "L",