-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Don't unconditionally link libiconv on macOS. #2150
Conversation
This adds `#[link(name = "iconv")]` to just the iconv symbols so that the library is only linked if the symbols are used.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @JohnTitor (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
r? @Amanieu |
If CI is happy then it's fine. @bors r+ |
📌 Commit 28f07a4 has been approved by |
☀️ Test successful - checks-actions, checks-cirrus-freebsd-11, checks-cirrus-freebsd-12, checks-cirrus-freebsd-13 |
Many buildRustPackage-based derivations require libiconv as a build input on Darwin. This is caused by `libc` unconditionally linking against libiconv. However, this was recently changed: rust-lang/libc#2150 We will probably see this dependency disappear over the coming months once a new `libc` crate version is released and other crates adopt this new version. Since this is already an optional dependency and it will disappear in the coming time, we should probably not unconditionally add it to all Rust crates.
@goffrie It seems that
The |
This adds
#[link(name = "iconv")]
to just the iconv symbols so that thelibrary is only linked if the symbols are used.
#2037 added a build.rs directive to always link libiconv on Apple platforms,
but that shouldn't be necessary. With this change, we can see using
otool -L
that a binary that uses an
iconv
symbol links libiconv, but other binariesdon't.
Note that this can only be seen with a rustc prior to nightly-2021-03-09, as
nightly-2021-03-10 includes rust-lang/rust#82731 which
includes #2037, therefore unconditionally linking all Rust binaries to
libiconv.