@@ -206,9 +206,22 @@ pub const PRIO_MAX: ::c_int = 20;
206
206
cfg_if ! {
207
207
if #[ cfg( dox) ] {
208
208
// on dox builds don't pull in anything
209
- } else if #[ cfg( all( not( stdbuild) , feature = "use_std" ) ) ] {
209
+ } else if #[ cfg( all( not( stdbuild) ,
210
+ feature = "use_std" ,
211
+ not( any( target_os = "macos" ,
212
+ target_os = "ios" ,
213
+ target_os = "android" ,
214
+ target_os = "openbsd" ,
215
+ target_os = "bitrig" )
216
+ ) ) ) ] {
210
217
// cargo build, don't pull in anything extra as the libstd dep
211
218
// already pulls in all libs.
219
+ } else if #[ cfg( all( not( stdbuild) , feature = "use_std" ) ) ] {
220
+ // except on macOS and iOS, where we must link with lib resolv
221
+ // for res_init, despite libsystem_info including it:
222
+ // http://blog.achernya.com/2013/03/os-x-has-silly-libsystem.html
223
+ #[ link( name = "resolv" ) ]
224
+ extern { }
212
225
} else if #[ cfg( any( all( target_env = "musl" , not( target_arch = "mips" ) ) ) ) ] {
213
226
#[ link( name = "c" , kind = "static" , cfg( target_feature = "crt-static" ) ) ]
214
227
#[ link( name = "c" , cfg( not( target_feature = "crt-static" ) ) ) ]
@@ -229,6 +242,7 @@ cfg_if! {
229
242
target_os = "bitrig" ) ) ] {
230
243
#[ link( name = "c" ) ]
231
244
#[ link( name = "m" ) ]
245
+ #[ link( name = "resolv" ) ]
232
246
extern { }
233
247
} else if #[ cfg( target_os = "haiku" ) ] {
234
248
#[ link( name = "root" ) ]
@@ -694,6 +708,17 @@ extern {
694
708
res : * mut * mut addrinfo ) -> :: c_int ;
695
709
pub fn freeaddrinfo ( res : * mut addrinfo ) ;
696
710
pub fn gai_strerror ( errcode : :: c_int ) -> * const :: c_char ;
711
+ #[ cfg_attr( all( unix,
712
+ not( target_os = "macos" ) ,
713
+ not( target_os = "ios" ) ,
714
+ not( target_os = "netbsd" ) ,
715
+ not( target_os = "solaris" ) ,
716
+ not( target_env = "musl" )
717
+ ) ,
718
+ link_name = "__res_init" ) ]
719
+ #[ cfg_attr( any( target_os = "macos" , target_os = "ios" ) ,
720
+ link_name = "res_9_init" ) ]
721
+ pub fn res_init ( ) -> :: c_int ;
697
722
698
723
#[ cfg_attr( target_os = "netbsd" , link_name = "__gmtime_r50" ) ]
699
724
pub fn gmtime_r ( time_p : * const time_t , result : * mut tm ) -> * mut tm ;
0 commit comments