-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
macos stage3: add link support for system libc++ #23264
base: master
Are you sure you want to change the base?
Conversation
- activates when -DZIG_SHARED_LLVM=ON - activates when llvm_config is used and --shared-mode is shared - otherwise vendored libc++ is used closes ziglang#23189
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.
Thanks; works great. Shipped in Homebrew as Homebrew/homebrew-core#211129.
const sdk = std.zig.system.darwin.getSdk(b.allocator, b.graph.host.result) orelse return error.SdkDetectFailed; | ||
const @"libc++" = b.pathJoin(&.{ sdk, "usr/lib/libc++.tbd" }); | ||
exe.root_module.addObjectFile(.{ .cwd_relative = @"libc++" }); |
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.
Note that you are implicitly assuming that the shared LLVM is linked against the system libc++. That's likely generally true in practice, but in theory one can build their own LLVM and link it against a non-system libc++.
I'm not suggesting that you need to support an LLVM built with a custom libc++. However, it may be worth documenting somewhere that you only support linking to a shared LLVM with the system libc++.
if (static or !std.zig.system.darwin.isSdkInstalled(b.allocator)) { | ||
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++).
Patch pushed to MacPorts: macports/macports-ports@eec7cd1 |
closes #23189