Skip to content

Commit 8f9216e

Browse files
committed
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
1 parent 8e0a4ca commit 8f9216e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

build.zig

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -782,7 +782,13 @@ fn addCmakeCfgOptionsToExe(
782782
mod.linkSystemLibrary("unwind", .{});
783783
},
784784
.ios, .macos, .watchos, .tvos, .visionos => {
785-
mod.link_libcpp = true;
785+
if (static or !std.zig.system.darwin.isSdkInstalled(b.allocator)) {
786+
mod.link_libcpp = true;
787+
} else {
788+
const sdk = std.zig.system.darwin.getSdk(b.allocator, b.graph.host.result) orelse return error.SdkDetectFailed;
789+
const @"libc++" = b.pathJoin(&.{ sdk, "usr/lib/libc++.tbd" });
790+
exe.root_module.addObjectFile(.{ .cwd_relative = @"libc++" });
791+
}
786792
},
787793
.windows => {
788794
if (target.abi != .msvc) mod.link_libcpp = true;

0 commit comments

Comments
 (0)