-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
macos stage3: add link support for system libc++ #23264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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. | ||
Comment on lines
+788
to
+791
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, thank you. This reveals a contradiction in this implementation:
Instead of working around it, the build system should be modified to recognize that there are two choices when linking libc++, because the logic that makes my code snippet not work for this use case is based on this incorrect assumption. Then, my simpler code snippet which does not rely on something that requires access outside of a build sandbox (#14286) will work correctly. |
||
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; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per my comment here, it's probably still worth rethinking linking to the vendored libc++ when you are using a third-party LLVM (i.e. one built not using the vendored libc++).