From 8eaaa905f709db623432a95fd9d4e4dfecdb7eae Mon Sep 17 00:00:00 2001 From: LemonBoy Date: Thu, 19 Nov 2020 23:30:16 +0100 Subject: 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 --- src/link/Coff.zig | 7 +++++-- src/link/Elf.zig | 7 +++++-- src/link/MachO.zig | 8 ++++++-- src/link/Wasm.zig | 7 +++++-- 4 files changed, 21 insertions(+), 8 deletions(-) (limited to 'src/link') diff --git a/src/link/Coff.zig b/src/link/Coff.zig index 34093bba01..e89ace95c0 100644 --- a/src/link/Coff.zig +++ b/src/link/Coff.zig @@ -907,8 +907,11 @@ fn linkWithLLD(self: *Coff, comp: *Compilation) !void { // Create an LLD command line and invoke it. var argv = std.ArrayList([]const u8).init(self.base.allocator); defer argv.deinit(); - // Even though we're calling LLD as a library it thinks the first argument is its own exe name. - try argv.append("lld"); + // The first argument is ignored as LLD is called as a library, set it + // anyway to the correct LLD driver name for this target so that it's + // correctly printed when `verbose_link` is true. This is needed for some + // tools such as CMake when Zig is used as C compiler. + try argv.append("lld-link"); try argv.append("-ERRORLIMIT:0"); try argv.append("-NOLOGO"); diff --git a/src/link/Elf.zig b/src/link/Elf.zig index 8fb9a93950..18388f0589 100644 --- a/src/link/Elf.zig +++ b/src/link/Elf.zig @@ -1353,8 +1353,11 @@ fn linkWithLLD(self: *Elf, comp: *Compilation) !void { // Create an LLD command line and invoke it. var argv = std.ArrayList([]const u8).init(self.base.allocator); defer argv.deinit(); - // Even though we're calling LLD as a library it thinks the first argument is its own exe name. - try argv.append("lld"); + // The first argument is ignored as LLD is called as a library, set it + // anyway to the correct LLD driver name for this target so that it's + // correctly printed when `verbose_link` is true. This is needed for some + // tools such as CMake when Zig is used as C compiler. + try argv.append("ld.lld"); if (is_obj) { try argv.append("-r"); } diff --git a/src/link/MachO.zig b/src/link/MachO.zig index bf3dee9c87..799a94bb20 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -542,8 +542,12 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void { if (self.base.options.system_linker_hack) { try argv.append("ld"); } else { - // Even though we're calling LLD as a library it thinks the first argument is its own exe name. - try argv.append("lld"); + // The first argument is ignored as LLD is called as a library, set + // it anyway to the correct LLD driver name for this target so that + // it's correctly printed when `verbose_link` is true. This is + // needed for some tools such as CMake when Zig is used as C + // compiler. + try argv.append("ld64"); try argv.append("-error-limit"); try argv.append("0"); diff --git a/src/link/Wasm.zig b/src/link/Wasm.zig index bf6b34ed76..580a5df576 100644 --- a/src/link/Wasm.zig +++ b/src/link/Wasm.zig @@ -339,8 +339,11 @@ fn linkWithLLD(self: *Wasm, comp: *Compilation) !void { // Create an LLD command line and invoke it. var argv = std.ArrayList([]const u8).init(self.base.allocator); defer argv.deinit(); - // Even though we're calling LLD as a library it thinks the first argument is its own exe name. - try argv.append("lld"); + // The first argument is ignored as LLD is called as a library, set it + // anyway to the correct LLD driver name for this target so that it's + // correctly printed when `verbose_link` is true. This is needed for some + // tools such as CMake when Zig is used as C compiler. + try argv.append("ld-wasm"); if (is_obj) { try argv.append("-r"); } -- cgit v1.2.3