diff --git a/build.rs b/build.rs index 27cfb0240123c..56a2270c5074a 100644 --- a/build.rs +++ b/build.rs @@ -10,6 +10,7 @@ fn main() { let const_extern_fn_cargo_feature = env::var("CARGO_FEATURE_CONST_EXTERN_FN").is_ok(); let libc_ci = env::var("LIBC_CI").is_ok(); + let target = env::var("TARGET").unwrap(); if env::var("CARGO_FEATURE_USE_STD").is_ok() { println!( @@ -82,6 +83,10 @@ fn main() { } println!("cargo:rustc-cfg=libc_const_extern_fn"); } + + if target.contains("-apple-") { + println!("cargo:rustc-link-lib=iconv"); + } } fn rustc_minor_nightly() -> Option<(u32, bool)> { diff --git a/src/unix/mod.rs b/src/unix/mod.rs index 0028cc918b57e..cf7cbd9718851 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -297,10 +297,8 @@ cfg_if! { if #[cfg(target_os = "l4re")] { // required libraries for L4Re are linked externally, ATM } else if #[cfg(feature = "std")] { - // cargo build. Most libraries are already pulled in by libstd dep - #[cfg_attr( - any(target_os = "macos", target_os = "ios"), - link(name = "iconv"))] + // cargo build, don't pull in anything extra as the libstd dep + // already pulls in all libs. extern {} } else if #[cfg(all(target_os = "linux", target_env = "gnu",