summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-09-17 17:25:52 -0700
committerAlex Crichton <alex@alexcrichton.com>2015-09-17 17:25:52 -0700
commit15b83c244fbdbf24d797cc0639792414251a6111 (patch)
tree6b7e10214c7644bca118b71bc8431c61a2b8ae8e
parent6de3816a0258de0d4e5144da9127ecb86317b80b (diff)
downloadrust-libc-15b83c244fbdbf24d797cc0639792414251a6111.tar.gz
Use musl-gcc, fix musl headers
-rw-r--r--ci/run-travis.sh2
-rw-r--r--libc-test/build.rs23
-rw-r--r--src/unix/bsd/mod.rs1
-rw-r--r--src/unix/mod.rs7
-rw-r--r--src/unix/notbsd/android/mod.rs4
-rw-r--r--src/unix/notbsd/linux/mod.rs52
-rw-r--r--src/unix/notbsd/linux/notmips/mod.rs13
-rw-r--r--src/unix/notbsd/mod.rs3
8 files changed, 74 insertions, 31 deletions
diff --git a/ci/run-travis.sh b/ci/run-travis.sh
index e4fa0d55a6..f5ddc9dc51 100644
--- a/ci/run-travis.sh
+++ b/ci/run-travis.sh
@@ -19,6 +19,8 @@ if [ "$TARGET" = "arm-linux-androideabi" ]; then
sh ci/run.sh $TARGET
elif [ "$TARGET" = "x86_64-unknown-linux-musl" ]; then
curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib
+ sudo apt-get install musl-tools
+ export CC=musl-gcc
elif [ "$TARGET" = "arm-unknown-linux-gnueabihf" ]; then
curl -s $EXTRA_TARGETS/$TARGET.tar.gz | tar xzf - -C $HOME/rust/lib/rustlib
sudo apt-get install gcc-4.7-arm-linux-gnueabihf qemu-user
diff --git a/libc-test/build.rs b/libc-test/build.rs
index b983819671..0f607c24bd 100644
--- a/libc-test/build.rs
+++ b/libc-test/build.rs
@@ -11,10 +11,11 @@ fn main() {
let linux = target.contains("unknown-linux");
let android = target.contains("android");
let darwin = target.contains("apple-darwin");
+ let musl = target.contains("musl");
let mut cfg = ctest::TestGenerator::new();
// Pull in extra goodies on linux/mingw
- if target.contains("unknown-linux-gnu") {
+ if target.contains("unknown-linux") {
cfg.define("_GNU_SOURCE", None);
} else if windows {
cfg.define("_WIN32_WINNT", Some("0x8000"));
@@ -42,7 +43,7 @@ fn main() {
cfg.header("mach-o/dyld.h");
cfg.header("mach/mach_time.h");
} else if linux || android {
- cfg.header("linux/if_packet.h");
+ cfg.header("netpacket/packet.h");
cfg.header("net/ethernet.h");
}
@@ -89,8 +90,11 @@ fn main() {
} else {
cfg.header("glob.h");
cfg.header("ifaddrs.h");
- cfg.header("sys/sysctl.h");
- cfg.header("execinfo.h");
+
+ if !musl {
+ cfg.header("execinfo.h");
+ cfg.header("sys/sysctl.h");
+ }
}
if darwin {
@@ -192,6 +196,9 @@ fn main() {
"SIG_IGN" => true, // sighandler_t weirdness
+ // types on musl are defined a little differently
+ n if musl && n.contains("PTHREAD") => true,
+
_ => false,
}
});
@@ -220,17 +227,19 @@ fn main() {
// Windows dllimport oddness?
cfg.skip_fn_ptrcheck(move |_| windows);
- cfg.skip_field_type(|struct_, field| {
+ cfg.skip_field_type(move |struct_, field| {
// This is a weird union, don't check the type.
(struct_ == "ifaddrs" && field == "ifa_ifu") ||
// sighandler_t type is super weird
(struct_ == "sigaction" && field == "sa_sigaction")
});
- cfg.skip_field(|struct_, field| {
+ cfg.skip_field(move |struct_, field| {
// this is actually a union on linux, so we can't represent it well and
// just insert some padding.
- (struct_ == "siginfo_t" && field == "_pad")
+ (struct_ == "siginfo_t" && field == "_pad") ||
+ // musl names this __dummy1 but it's still there
+ (musl && struct_ == "glob_t" && field == "gl_flags")
});
cfg.generate("../src/lib.rs", "all.rs");
diff --git a/src/unix/bsd/mod.rs b/src/unix/bsd/mod.rs
index 92b2d8732d..94c90e85a7 100644
--- a/src/unix/bsd/mod.rs
+++ b/src/unix/bsd/mod.rs
@@ -66,6 +66,7 @@ extern {
-> c_int;
pub fn setgroups(ngroups: ::c_int,
ptr: *const ::gid_t) -> ::c_int;
+ pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
}
cfg_if! {
diff --git a/src/unix/mod.rs b/src/unix/mod.rs
index 8f1d1a07aa..4e80d2cf7f 100644
--- a/src/unix/mod.rs
+++ b/src/unix/mod.rs
@@ -40,7 +40,10 @@ s! {
pub ru_msgrcv: c_long,
pub ru_nsignals: c_long,
pub ru_nvcsw: c_long,
- pub ru_nivcsw: c_long
+ pub ru_nivcsw: c_long,
+
+ #[cfg(target_env = "musl")]
+ __reserved: [c_long; 16],
}
pub struct in_addr {
@@ -455,7 +458,6 @@ extern {
pub fn getsid(pid: pid_t) -> pid_t;
pub fn madvise(addr: *mut ::c_void, len: size_t, advice: c_int)
-> c_int;
- pub fn ioctl(fd: c_int, request: c_ulong, ...) -> c_int;
#[cfg_attr(all(target_os = "macos", target_arch = "x86"),
link_name = "putenv$UNIX2003")]
pub fn putenv(string: *mut c_char) -> c_int;
@@ -491,6 +493,7 @@ extern {
buf: *mut ::c_char,
buflen: ::size_t,
result: *mut *mut passwd) -> ::c_int;
+ #[cfg(not(target_env = "musl"))]
pub fn backtrace(buf: *mut *mut ::c_void,
sz: ::c_int) -> ::c_int;
pub fn posix_memalign(memptr: *mut *mut ::c_void,
diff --git a/src/unix/notbsd/android/mod.rs b/src/unix/notbsd/android/mod.rs
index 13519e3256..0ed7098898 100644
--- a/src/unix/notbsd/android/mod.rs
+++ b/src/unix/notbsd/android/mod.rs
@@ -186,6 +186,10 @@ pub const SA_SIGINFO: ::c_ulong = 0x00000004;
pub const SIGBUS: ::c_int = 7;
pub const SIG_SETMASK: ::c_int = 2;
+pub const O_ACCMODE: ::c_int = 3;
+
+pub const RUSAGE_CHILDREN: c_int = -1;
+
extern {
pub fn madvise(addr: *const ::c_void, len: ::size_t, advice: ::c_int)
-> ::c_int;
diff --git a/src/unix/notbsd/linux/mod.rs b/src/unix/notbsd/linux/mod.rs
index cdf4194dc9..eaf7cb257d 100644
--- a/src/unix/notbsd/linux/mod.rs
+++ b/src/unix/notbsd/linux/mod.rs
@@ -73,11 +73,8 @@ s! {
}
}
-pub const BUFSIZ: ::c_uint = 8192;
pub const FILENAME_MAX: ::c_uint = 4096;
-pub const FOPEN_MAX: ::c_uint = 16;
pub const L_tmpnam: ::c_uint = 20;
-pub const TMP_MAX: ::c_uint = 238328;
pub const _PC_NAME_MAX: ::c_int = 3;
pub const _SC_ARG_MAX: ::c_int = 0;
@@ -156,7 +153,6 @@ pub const _SC_XOPEN_CRYPT: ::c_int = 92;
pub const _SC_XOPEN_ENH_I18N: ::c_int = 93;
pub const _SC_XOPEN_SHM: ::c_int = 94;
pub const _SC_2_CHAR_TERM: ::c_int = 95;
-pub const _SC_2_C_VERSION: ::c_int = 96;
pub const _SC_2_UPE: ::c_int = 97;
pub const _SC_XBS5_ILP32_OFF32: ::c_int = 125;
pub const _SC_XBS5_ILP32_OFFBIG: ::c_int = 126;
@@ -168,9 +164,6 @@ pub const _SC_XOPEN_REALTIME_THREADS: ::c_int = 131;
pub const RLIM_SAVED_MAX: ::rlim_t = RLIM_INFINITY;
pub const RLIM_SAVED_CUR: ::rlim_t = RLIM_INFINITY;
-#[cfg(not(target_env = "musl"))]
-pub const RUSAGE_THREAD: ::c_int = 1;
-
pub const GLOB_ERR: ::c_int = 1 << 0;
pub const GLOB_MARK: ::c_int = 1 << 1;
pub const GLOB_NOSORT: ::c_int = 1 << 2;
@@ -187,7 +180,6 @@ pub const POSIX_MADV_NORMAL: ::c_int = 0;
pub const POSIX_MADV_RANDOM: ::c_int = 1;
pub const POSIX_MADV_SEQUENTIAL: ::c_int = 2;
pub const POSIX_MADV_WILLNEED: ::c_int = 3;
-pub const POSIX_MADV_DONTNEED: ::c_int = 4;
pub const S_IEXEC: mode_t = 64;
pub const S_IWRITE: mode_t = 128;
@@ -221,17 +213,10 @@ pub const __SIZEOF_PTHREAD_COND_T: usize = 48;
extern {
pub fn shm_open(name: *const c_char, oflag: ::c_int,
mode: mode_t) -> ::c_int;
- #[cfg(not(target_env = "musl"))]
- pub fn sysctl(name: *mut ::c_int,
- namelen: ::c_int,
- oldp: *mut ::c_void,
- oldlenp: *mut size_t,
- newp: *mut ::c_void,
- newlen: size_t)
- -> ::c_int;
pub fn mprotect(addr: *mut ::c_void, len: ::size_t, prot: ::c_int)
-> ::c_int;
pub fn __errno_location() -> *mut ::c_int;
+
}
cfg_if! {
@@ -244,6 +229,41 @@ cfg_if! {
}
cfg_if! {
+ if #[cfg(target_env = "musl")] {
+ pub const BUFSIZ: ::c_uint = 1024;
+ pub const TMP_MAX: ::c_uint = 10000;
+ pub const FOPEN_MAX: ::c_uint = 1000;
+ pub const POSIX_MADV_DONTNEED: ::c_int = 0;
+ pub const O_ACCMODE: ::c_int = 0o10000003;
+ pub const RUSAGE_CHILDREN: ::c_int = 1;
+
+ extern {
+ pub fn ioctl(fd: ::c_int, request: ::c_int, ...) -> ::c_int;
+ }
+ } else {
+ pub const BUFSIZ: ::c_uint = 8192;
+ pub const TMP_MAX: ::c_uint = 238328;
+ pub const FOPEN_MAX: ::c_uint = 16;
+ pub const POSIX_MADV_DONTNEED: ::c_int = 4;
+ pub const _SC_2_C_VERSION: ::c_int = 96;
+ pub const RUSAGE_THREAD: ::c_int = 1;
+ pub const O_ACCMODE: ::c_int = 3;
+ pub const RUSAGE_CHILDREN: ::c_int = -1;
+
+ extern {
+ pub fn sysctl(name: *mut ::c_int,
+ namelen: ::c_int,
+ oldp: *mut ::c_void,
+ oldlenp: *mut size_t,
+ newp: *mut ::c_void,
+ newlen: size_t)
+ -> ::c_int;
+ pub fn ioctl(fd: ::c_int, request: ::c_ulong, ...) -> ::c_int;
+ }
+ }
+}
+
+cfg_if! {
if #[cfg(any(target_arch = "mips", target_arch = "mipsel"))] {
mod mips;
pub use self::mips::*;
diff --git a/src/unix/notbsd/linux/notmips/mod.rs b/src/unix/notbsd/linux/notmips/mod.rs
index 3b64ecb15e..9a3ca318a9 100644
--- a/src/unix/notbsd/linux/notmips/mod.rs
+++ b/src/unix/notbsd/linux/notmips/mod.rs
@@ -26,8 +26,6 @@ pub const RLIMIT_NOFILE: ::c_int = 7;
pub const RLIMIT_AS: ::c_int = 9;
pub const RLIMIT_NPROC: ::c_int = 6;
pub const RLIMIT_MEMLOCK: ::c_int = 8;
-pub const RLIMIT_RTTIME: ::c_int = 15;
-pub const RLIMIT_NLIMITS: ::c_int = 16;
pub const RLIM_INFINITY: ::rlim_t = !0;
pub const O_APPEND: ::c_int = 1024;
@@ -156,7 +154,6 @@ pub const SO_RCVTIMEO: ::c_int = 20;
pub const SO_SNDTIMEO: ::c_int = 21;
pub const SO_ACCEPTCONN: ::c_int = 30;
-pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15;
pub const TCP_THIN_LINEAR_TIMEOUTS: ::c_int = 16;
pub const TCP_THIN_DUPACK: ::c_int = 17;
pub const TCP_USER_TIMEOUT: ::c_int = 18;
@@ -178,6 +175,16 @@ pub const SIGBUS: ::c_int = 7;
pub const SIG_SETMASK: ::c_int = 2;
cfg_if! {
+ if #[cfg(target_env = "musl")] {
+ pub const RLIMIT_NLIMITS: ::c_int = 15;
+ } else {
+ pub const RLIMIT_NLIMITS: ::c_int = 16;
+ pub const RLIMIT_RTTIME: ::c_int = 15;
+ pub const TCP_COOKIE_TRANSACTIONS: ::c_int = 15;
+ }
+}
+
+cfg_if! {
if #[cfg(any(target_arch = "x86", target_arch = "arm"))] {
mod b32;
pub use self::b32::*;
diff --git a/src/unix/notbsd/mod.rs b/src/unix/notbsd/mod.rs
index d6b7ad046e..ba6c767a4b 100644
--- a/src/unix/notbsd/mod.rs
+++ b/src/unix/notbsd/mod.rs
@@ -103,8 +103,6 @@ pub const F_SETFD: c_int = 2;
pub const F_GETFL: c_int = 3;
pub const F_SETFL: c_int = 4;
-pub const O_ACCMODE: c_int = 3;
-
pub const SIGTRAP: c_int = 5;
pub const PTHREAD_CREATE_JOINABLE: c_int = 0;
@@ -125,7 +123,6 @@ pub const RLIMIT_NICE: c_int = 13;
pub const RLIMIT_RTPRIO: c_int = 14;
pub const RUSAGE_SELF: c_int = 0;
-pub const RUSAGE_CHILDREN: c_int = -1;
pub const O_RDONLY: ::c_int = 0;
pub const O_WRONLY: ::c_int = 1;