-
Notifications
You must be signed in to change notification settings - Fork 12.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
Allow macOS to build LLVM as shared library #98418
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @Mark-Simulacrum (or someone else) soon. Please see the contribution instructions for more information. |
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.
How likely is this to break? Has homebrew ever had to change the way they do this?
IMO, the workaround should be pretty stable. I'll be tracking closely whether LLVM has any upstream fixes as I'm building rustc regularly for the ONDK Project |
Has this been reported upstream to LLVM? Is there a reason to fix this in our code, vs. in LLVM? |
Yup, you can check out this comment. There is no response in upstream LLVM, which is why Homebrew decided to workaround the issue instead. |
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.
LGTM except for the nits
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.
r=me with the dry_run check added
This comment has been minimized.
This comment has been minimized.
Create symlinks to workaround file missing error in llvm-config
@bors r+ |
📌 Commit b6e28b5 has been approved by |
Allow macOS to build LLVM as shared library Inspired by how [homebrew](https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/llvm.rb) builds and distributes llvm, here we manually create a symlink with a versioned dylib path to make `llvm-config` work properly. Note, the resulting `rustc` executable and `librustc_driver-<hash>.dylib` still links to the un-versioned `libLLVM.dylib` as expected when distributed in the final output. I have confirmed this by checking `otool -L` on both binaries. After the change, enabling `llvm.link-shared` and `llvm.thin-lto` will be possible on macOS.
…laumeGomez Rollup of 5 pull requests Successful merges: - rust-lang#97249 (`<details>`/`<summary>` UI fixes) - rust-lang#98418 (Allow macOS to build LLVM as shared library) - rust-lang#98460 (Use CSS variables to handle theming) - rust-lang#98497 (Improve some inference diagnostics) - rust-lang#98708 (rustdoc: fix 98690 Panic if invalid path for -Z persist-doctests) Failed merges: - rust-lang#98761 (more `need_type_info` improvements) r? `@ghost` `@rustbot` modify labels: rollup
Proper macOS libLLVM symlink when cross compiling Follow up of rust-lang#98418 When cross compiling on macOS with `llvm.link-shared` enabled, the symlink creation will fail after compiling LLVM for the target architecture, because it will attempt to create the symlink in the host LLVM directory, which was already created when being built. This commit changes the symlink path to the actual LLVM output. r? `@jyn514`
Inspired by how homebrew builds and distributes llvm, here we manually create a symlink with a versioned dylib path to make
llvm-config
work properly. Note, the resultingrustc
executable andlibrustc_driver-<hash>.dylib
still links to the un-versionedlibLLVM.dylib
as expected when distributed in the final output. I have confirmed this by checkingotool -L
on both binaries.After the change, enabling
llvm.link-shared
andllvm.thin-lto
will be possible on macOS.