This commit is contained in:
Michael Dusan 2025-11-25 02:27:39 +03:00 committed by GitHub
commit b31ce64398
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -799,7 +799,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;