authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-05-12 20:17:43+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-05-13 07:55:59+02:00
log6c3050e3c3eee19a9de2c912dc653062e5597b67
tree9b49030c385dea1cccf98a06a37ce101faefc10a
parentfb8527b289db438494e3b86c65d5ade585a77b41

macos: link static libc++ when building stage2

With this change, it is now possible to use zig-bootstrap as the initial C/C++ compiler, and then build stage2 with the resultant stage1 without the need to link any system libs!

1 files changed, 1 insertions(+), 14 deletions(-)

build.zig+1-14
......@@ -344,20 +344,7 @@ fn addCmakeCfgOptionsToExe(
344344 try addCxxKnownPath(b, cfg, exe, "libc++.a", null, need_cpp_includes);
345345 try addCxxKnownPath(b, cfg, exe, "libc++abi.a", null, need_cpp_includes);
346346 } else if (exe.target.isDarwin()) {
347 if (addCxxKnownPath(b, cfg, exe, "libgcc_eh.a", "", need_cpp_includes)) {
348 // Compiler is GCC.
349 try addCxxKnownPath(b, cfg, exe, "libstdc++.a", null, need_cpp_includes);
350 exe.linkSystemLibrary("pthread");
351 // TODO LLD cannot perform this link.
352 // Set ZIG_SYSTEM_LINKER_HACK env var to use system linker ld instead.
353 // See https://github.com/ziglang/zig/issues/1535
354 } else |err| switch (err) {
355 error.RequiredLibraryNotFound => {
356 // System compiler, not gcc.
357 exe.linkSystemLibrary("c++");
358 },
359 else => |e| return e,
360 }
347 exe.linkSystemLibrary("c++");
361348 }
362349
363350 if (cfg.dia_guids_lib.len != 0) {