macos stage3: add link support for system libc++

- activates when -DZIG_SHARED_LLVM=ON
- activates when llvm_config is used and --shared-mode is shared
- otherwise vendored libc++ is used

closes #23189
This commit is contained in:
Michael Dusan 2025-03-24 17:19:34 -04:00
parent 525466b49d
commit 3ef44a93e6
No known key found for this signature in database
GPG key ID: ED4C5BA849FA1B74

View file

@ -782,7 +782,17 @@ fn addCmakeCfgOptionsToExe(
mod.linkSystemLibrary("unwind", .{});
},
.ios, .macos, .watchos, .tvos, .visionos => {
mod.link_libcpp = true;
if (static or !std.zig.system.darwin.isSdkInstalled(b.allocator)) {
mod.link_libcpp = true;
} else {
// Avoid using `mod.linkSystemLibrary()`, which:
// - is semantically equivalent to `-lc++`
// - and enables `mod.link_libcpp`
// Instead, add the full object pathname.
const sdk = std.zig.system.darwin.getSdk(b.allocator, b.graph.host.result) orelse return error.SdkDetectFailed;
const libcxx = b.pathJoin(&.{ sdk, "usr/lib/libc++.tbd" });
exe.root_module.addObjectFile(.{ .cwd_relative = libcxx });
}
},
.windows => {
if (target.abi != .msvc) mod.link_libcpp = true;