| author | |
| committer | |
| log | 8eaaa905f709db623432a95fd9d4e4dfecdb7eae |
| tree | 653c13dfef4ede70444d15895a839a5b9887e37a |
| parent | 647c6e0d0955260947d9a0e07014af2a337d9330 |
| signature | Signed by PGP key 4AEE18F83AFDEB23 |
* 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 | 165 | .{ |
| 166 | 166 | .name = "###", |
| 167 | 167 | .syntax = .flag, |
| 168 | .zig_equivalent = .verbose_cmds, | |
| 168 | .zig_equivalent = .dry_run, | |
| 169 | 169 | .pd1 = true, |
| 170 | 170 | .pd2 = false, |
| 171 | 171 | .psl = false, |
| ... | ... | @@ -4439,7 +4439,14 @@ flagpd1("twolevel_namespace_hints"), |
| 4439 | 4439 | sepd1("umbrella"), |
| 4440 | 4440 | flagpd1("undef"), |
| 4441 | 4441 | sepd1("unexported_symbols_list"), |
| 4442 | flagpd1("v"), | |
| 4442 | .{ | |
| 4443 | .name = "v", | |
| 4444 | .syntax = .flag, | |
| 4445 | .zig_equivalent = .verbose, | |
| 4446 | .pd1 = true, | |
| 4447 | .pd2 = false, | |
| 4448 | .psl = false, | |
| 4449 | }, | |
| 4443 | 4450 | flagpd1("vectorize-loops"), |
| 4444 | 4451 | flagpd1("vectorize-slp"), |
| 4445 | 4452 | flagpd1("verify"), |
src/link/Coff.zig+5-2| ... | ... | @@ -907,8 +907,11 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { |
| 907 | 907 | // Create an LLD command line and invoke it. |
| 908 | 908 | var argv = std.ArrayList([]const u8).init(self.base.allocator); |
| 909 | 909 | 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"); | |
| 912 | 915 | |
| 913 | 916 | try argv.append("-ERRORLIMIT:0"); |
| 914 | 917 | try argv.append("-NOLOGO"); |
src/link/Elf.zig+5-2| ... | ... | @@ -1353,8 +1353,11 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { |
| 1353 | 1353 | // Create an LLD command line and invoke it. |
| 1354 | 1354 | var argv = std.ArrayList([]const u8).init(self.base.allocator); |
| 1355 | 1355 | 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"); | |
| 1358 | 1361 | if (is_obj) { |
| 1359 | 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 | 542 | if (self.base.options.system_linker_hack) { |
| 543 | 543 | try argv.append("ld"); |
| 544 | 544 | } 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"); | |
| 547 | 551 | |
| 548 | 552 | try argv.append("-error-limit"); |
| 549 | 553 | try argv.append("0"); |
src/link/Wasm.zig+5-2| ... | ... | @@ -339,8 +339,11 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { |
| 339 | 339 | // Create an LLD command line and invoke it. |
| 340 | 340 | var argv = std.ArrayList([]const u8).init(self.base.allocator); |
| 341 | 341 | 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"); | |
| 344 | 347 | if (is_obj) { |
| 345 | 348 | try argv.append("-r"); |
| 346 | 349 | } |
src/main.zig+12-3| ... | ... | @@ -1062,9 +1062,17 @@ fn buildOutputType( |
| 1062 | 1062 | } |
| 1063 | 1063 | }, |
| 1064 | 1064 | .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 => { | |
| 1067 | 1073 | verbose_link = true; |
| 1074 | try clang_argv.append("-###"); | |
| 1075 | // XXX: Don't execute anything! | |
| 1068 | 1076 | }, |
| 1069 | 1077 | .for_linker => try linker_args.append(it.only_arg), |
| 1070 | 1078 | .linker_input_z => { |
| ... | ... | @@ -2776,7 +2784,8 @@ pub const ClangArgIterator = struct { |
| 2776 | 2784 | debug, |
| 2777 | 2785 | sanitize, |
| 2778 | 2786 | linker_script, |
| 2779 | verbose_cmds, | |
| 2787 | dry_run, | |
| 2788 | verbose, | |
| 2780 | 2789 | for_linker, |
| 2781 | 2790 | linker_input_z, |
| 2782 | 2791 | lib_dir, |
tools/update_clang_options.zig+5-1| ... | ... | @@ -214,7 +214,11 @@ const known_options = [_]KnownOpt{ |
| 214 | 214 | }, |
| 215 | 215 | .{ |
| 216 | 216 | .name = "###", |
| 217 | .ident = "verbose_cmds", | |
| 217 | .ident = "dry_run", | |
| 218 | }, | |
| 219 | .{ | |
| 220 | .name = "v", | |
| 221 | .ident = "verbose", | |
| 218 | 222 | }, |
| 219 | 223 | .{ |
| 220 | 224 | .name = "L", |