diff options
author | Alexander Batischev <eual.jp@gmail.com> | 2021-01-17 22:43:33 +0300 |
---|---|---|
committer | Alexander Batischev <eual.jp@gmail.com> | 2021-02-11 01:22:49 +0300 |
commit | 3e4d684dcdd1dff363a45c70c914204013810155 (patch) | |
tree | 7f9cdc41355aae4beef3fab66235f9e6e04e45f4 /build.rs | |
parent | 3c907ed65bee8b85d30361570e628dac2d2ae71a (diff) | |
download | rust-libc-3e4d684dcdd1dff363a45c70c914204013810155.tar.gz |
Add bindings for iconv calls
FreeBSD-likes all implement iconv:
- DragonflyBSD: https://github.com/DragonFlyBSD/DragonFlyBSD/blob/bbb35c81f71fe2a0880a1f8bb77876ee98b63338/include/iconv.h
- FreeBSD: https://github.com/freebsd/freebsd-src/blob/a6dc68c0e0f8a24ffaf0b4e78e58141ef7897047/include/iconv.h
NetBSD-likes:
- NetBSD: https://github.com/NetBSD/src/blob/81a39f60870b617d7fca299c126de6553d78cc5a/include/iconv.h
- OpenBSD doesn't implement it
macOS: apparently ships a conforming implementation as a separate
library:
https://stackoverflow.com/questions/57734434/libiconv-or-iconv-undefined-symbol-on-mac-osx/57734435#57734435
Linux:
- glibc: https://sourceware.org/git/?p=glibc.git;a=blob;f=iconv/iconv.h;h=fdddf53d99c3046ef9c280db01a425c2f499043e;hb=HEAD
- musl: https://git.musl-libc.org/cgit/musl/tree/include/iconv.h?id=455f96857f91d14e193219ca00969354a981c09c
Diffstat (limited to 'build.rs')
-rw-r--r-- | build.rs | 7 |
1 files changed, 7 insertions, 0 deletions
@@ -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,12 @@ fn main() { } println!("cargo:rustc-cfg=libc_const_extern_fn"); } + + // For unknown reason, libiconv can't be linked by adding #[link(name = iconv)] to + // a macOS-specific struct, so we do the linking here. + if target.contains("-apple-") { + println!("cargo:rustc-link-lib=iconv"); + } } fn rustc_minor_nightly() -> Option<(u32, bool)> { |