-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add res_init #585
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
Merged
Merged
Add res_init #585
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ef20ddb
Add binding for res_init.
jonhoo f93cf62
OpenBSD can't -lresolv, Android shouldn't need it
jonhoo afebd98
Android doesn't expose res_init in header file
jonhoo b8f5838
OpenBSD also uses res_init like NetBSD?
jonhoo 6eb8d1c
Treat bitrig and openbsd the same (@semarie)
jonhoo b3700e4
Blacklist > whitelist
jonhoo fcf5fc0
Avoid special-casing linking with resolv
jonhoo be7e45f
Skip res_init test on macOS/iOS
jonhoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -206,9 +206,19 @@ pub const PRIO_MAX: ::c_int = 20; | |
| cfg_if! { | ||
| if #[cfg(dox)] { | ||
| // on dox builds don't pull in anything | ||
| } else if #[cfg(all(not(stdbuild), feature = "use_std"))] { | ||
| } else if #[cfg(all(not(stdbuild), | ||
| feature = "use_std", | ||
| not(any(target_os = "macos", | ||
| target_os = "ios") | ||
| )))] { | ||
| // cargo build, don't pull in anything extra as the libstd dep | ||
| // already pulls in all libs. | ||
| } else if #[cfg(all(not(stdbuild), feature = "use_std"))] { | ||
| // except on macOS and iOS, where we must link with lib resolv | ||
| // for res_init, despite libsystem_info including it: | ||
| // http://blog.achernya.com/2013/03/os-x-has-silly-libsystem.html | ||
| #[link(name = "resolv")] | ||
| extern {} | ||
| } else if #[cfg(any(all(target_env = "musl", not(target_arch = "mips"))))] { | ||
| #[link(name = "c", kind = "static", cfg(target_feature = "crt-static"))] | ||
| #[link(name = "c", cfg(not(target_feature = "crt-static")))] | ||
|
|
@@ -223,8 +233,12 @@ cfg_if! { | |
| #[link(name = "m")] | ||
| extern {} | ||
| } else if #[cfg(any(target_os = "macos", | ||
| target_os = "ios", | ||
| target_os = "android", | ||
| target_os = "ios"))] { | ||
| #[link(name = "c")] | ||
| #[link(name = "m")] | ||
| #[link(name = "resolv")] | ||
| extern {} | ||
| } else if #[cfg(any(target_os = "android", | ||
| target_os = "openbsd", | ||
| target_os = "bitrig"))] { | ||
| #[link(name = "c")] | ||
|
|
@@ -694,6 +708,19 @@ extern { | |
| res: *mut *mut addrinfo) -> ::c_int; | ||
| pub fn freeaddrinfo(res: *mut addrinfo); | ||
| pub fn gai_strerror(errcode: ::c_int) -> *const ::c_char; | ||
| #[cfg_attr(all(unix, | ||
| not(target_os = "macos"), | ||
| not(target_os = "ios"), | ||
| not(target_os = "netbsd"), | ||
| not(target_os = "openbsd"), | ||
| not(target_os = "bitrig"), | ||
| not(target_os = "solaris"), | ||
| not(target_env = "musl") | ||
|
Member
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. Perhaps this could be converted to a whitelist? It's mostly just targeting Linux/android/FreebSD it looks like? |
||
| ), | ||
| link_name = "__res_init")] | ||
| #[cfg_attr(any(target_os = "macos", target_os = "ios"), | ||
| link_name = "res_9_init")] | ||
| pub fn res_init() -> ::c_int; | ||
|
|
||
| #[cfg_attr(target_os = "netbsd", link_name = "__gmtime_r50")] | ||
| pub fn gmtime_r(time_p: *const time_t, result: *mut tm) -> *mut tm; | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I'm a little wary of doing this, especially outside the
stdbuildblocks. Just in terms of possible breakage on new platforms. I do realize though that this is required to link correctly as libc on crates.io otherwise doesn't pull in new libs (it relies on libc in std to do that).Perhaps we could elide this section (or move it down below after the clause above) and then update the copy in libstd? We can rely on rust-lang/rust CI to block changes if it'd otherwise cause linkage problems. In the meantime we could just disable verification of the
res_initsymbol in libc as we already know it works!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.
I'm not sure I follow this? What do you mean by "move it down below after the clause above"? And by "update the copy in libstd"?
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.
Ah sorry, basically what I mean is:
cfg_if!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.
So we should simply not link with
resolvon macOS/iOS, both onstdbuildandnot(stdbuild), and disable the test forres_init if apple?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.
Let's start off by disabling linking to
resolveverywhere. Let's then only enable it in thenot(stdbuild)blocks to ensure we don't accidentally break crates.io. By only enabling it innot(stdbuild)then we can't test it in this PR, but it's ok to leave it enabled on all platforms you have it defined on currently.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.
Okay, I've removed all the linking with libresolv in fcf5fc0. As noted in my discussion comment though, it seems like
res_initis just never tested any more following theres_init if android => trueaddition made in afebd98.