From 0ffba9f96b39dca74287015ee2bd0d1c1cacb8b3 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 13 Feb 2019 10:27:47 +0100 Subject: [PATCH 01/19] Test that targets without a libstd component build on CI using xargo --- ci/build.sh | 58 +++++++++++++-- src/dox.rs | 211 ---------------------------------------------------- src/lib.rs | 102 +++++++++++-------------- 3 files changed, 95 insertions(+), 276 deletions(-) delete mode 100644 src/dox.rs diff --git a/ci/build.sh b/ci/build.sh index 69805fcbc281d..09a05be121c8b 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -11,7 +11,8 @@ OS=${TRAVIS_OS_NAME} echo "Testing Rust ${RUST} on ${OS}" test_target() { - TARGET="${1}" + CARGO="${1}" + TARGET="${2}" opt= if [ "${TARGET}" = "x86_64-unknown-linux-gnux32" ]; then @@ -22,7 +23,7 @@ test_target() { opt="--release" fi - NO_STD= + NO_STD="${3}" case ${TARGET} in thumbv*) NO_STD=1 @@ -32,25 +33,62 @@ test_target() { rustup target add "${TARGET}" --toolchain "${RUST}" || true # Test that libc builds without any default features (no libstd) - cargo "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" + "$CARGO" "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" # Test that libc builds with default features (e.g. libstd) # if the target supports libstd if [ "$NO_STD" != "1" ]; then - cargo "+${RUST}" build -vv $opt --target "${TARGET}" + "$CARGO" "+${RUST}" build -vv $opt --target "${TARGET}" fi # Test that libc builds with the `extra_traits` feature - cargo "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" \ + "$CARGO" "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" \ --features extra_traits # Also test that it builds with `extra_traits` and default features: if [ "$NO_STD" != "1" ]; then - cargo "+${RUST}" build -vv $opt --target "${TARGET}" \ + "$CARGO" "+${RUST}" build -vv $opt --target "${TARGET}" \ --features extra_traits fi } +rustup component add rust-src || true +cargo install xargo || true + + +RUST_LINUX_NO_CORE_TARGETS="\ +x86_64-unknown-dragonfly \ +aarch64-pc-windows-msvc \ +aarch64-unknown-cloudabi \ +armv7-unknown-cloudabi-eabihf \ +i586-pc-windows-msvc \ +i686-pc-windows-gnu \ +i686-pc-windows-msvc \ +i686-unknown-cloudabi \ +i686-unknown-haiku \ +i686-unknown-netbsd \ +mips-unknown-linux-uclib \ +mipsel-unknown-unknown-linux-uclib \ +nvptx64-nvidia-cuda \ +powerpc-unknown-linux-gnuspe \ +riscv32imac-unknown-none-elf \ +riscv32imc-unknown-none-elf \ +sparc-unknown-linux-gnu \ +sparc64-unknown-netbsd \ +thumbv8m.main-none-eabi \ +x86_64-pc-windows-gnu \ +x86_64-pc-windows-msvc +x86_64-unknown-bitrig \ +x86_64-unknown-haiku \ +x86_64-unknown-openbsd +" + +for TARGET in $RUST_LINUX_NO_CORE_TARGETS; do + if [ "${RUST}" = "nightly" ]; then + RUST_LIBC_NO_CORE_BUILD=1 test_target xargo "$TARGET" 1 + fi +done + RUST_LINUX_TARGETS="\ aarch64-linux-android \ aarch64-unknown-linux-gnu \ @@ -103,6 +141,12 @@ x86_64-unknown-cloudabi \ RUST_NIGHTLY_LINUX_TARGETS="\ aarch64-fuchsia \ +armv5te-unknown-linux-gnueabi \ +armv5te-unknown-linux-musleabi \ +armebv7r-none-eabi \ +armebv7r-none-eabihf \ +armv7r-none-eabi \ +armv7r-none-eabihf \ thumbv6m-none-eabi \ thumbv7em-none-eabi \ thumbv7em-none-eabihf \ @@ -161,5 +205,5 @@ case "${OS}" in esac for TARGET in $TARGETS; do - test_target "$TARGET" + test_target cargo "$TARGET" done diff --git a/src/dox.rs b/src/dox.rs deleted file mode 100644 index d9899bb2249d3..0000000000000 --- a/src/dox.rs +++ /dev/null @@ -1,211 +0,0 @@ -pub enum Option { - Some(T), - None, -} -impl Copy for Option {} -impl Clone for Option { - fn clone(&self) -> Option { - loop {} - } -} - -impl Copy for *mut T {} -impl Clone for *mut T { - fn clone(&self) -> *mut T { - loop {} - } -} - -impl Copy for *const T {} -impl Clone for *const T { - fn clone(&self) -> *const T { - loop {} - } -} - -pub trait Clone { - fn clone(&self) -> Self; -} - -#[lang = "copy"] -pub trait Copy {} - -#[lang = "freeze"] -pub trait Freeze {} - -#[lang = "sync"] -pub trait Sync {} -impl Sync for T {} - -#[lang = "sized"] -pub trait Sized {} - -#[lang = "receiver"] -pub trait Receiver {} -impl Receiver for &T {} -impl Receiver for &mut T {} - -macro_rules! each_int { - ($mac:ident) => { - $mac!(u8); - $mac!(u16); - $mac!(u32); - $mac!(u64); - $mac!(usize); - each_signed_int!($mac); - }; -} - -macro_rules! each_signed_int { - ($mac:ident) => { - $mac!(i8); - $mac!(i16); - $mac!(i32); - $mac!(i64); - $mac!(isize); - }; -} - -#[lang = "div"] -pub trait Div { - type Output; - fn div(self, rhs: RHS) -> Self::Output; -} - -#[lang = "shl"] -pub trait Shl { - type Output; - fn shl(self, rhs: RHS) -> Self::Output; -} - -#[lang = "mul"] -pub trait Mul { - type Output; - fn mul(self, rhs: RHS) -> Self::Output; -} - -#[lang = "sub"] -pub trait Sub { - type Output; - fn sub(self, rhs: RHS) -> Self::Output; -} - -#[lang = "bitand"] -pub trait BitAnd { - type Output; - fn bitand(self, rhs: RHS) -> Self::Output; -} - -#[lang = "bitand_assign"] -pub trait BitAndAssign { - fn bitand_assign(&mut self, rhs: RHS); -} - -#[lang = "bitor"] -pub trait BitOr { - type Output; - fn bitor(self, rhs: RHS) -> Self::Output; -} - -#[lang = "bitor_assign"] -pub trait BitOrAssign { - fn bitor_assign(&mut self, rhs: RHS); -} - -#[lang = "bitxor"] -pub trait BitXor { - type Output; - fn bitxor(self, rhs: RHS) -> Self::Output; -} - -#[lang = "bitxor_assign"] -pub trait BitXorAssign { - fn bitxor_assign(&mut self, rhs: RHS); -} - -#[lang = "neg"] -pub trait Neg { - type Output; - fn neg(self) -> Self::Output; -} - -#[lang = "not"] -pub trait Not { - type Output; - fn not(self) -> Self::Output; -} - -#[lang = "add"] -pub trait Add { - type Output; - fn add(self, r: RHS) -> Self::Output; -} - -macro_rules! impl_traits { - ($($i:ident)*) => ($( - impl Div<$i> for $i { - type Output = $i; - fn div(self, rhs: $i) -> $i { self / rhs } - } - impl Shl<$i> for $i { - type Output = $i; - fn shl(self, rhs: $i) -> $i { self << rhs } - } - impl Mul for $i { - type Output = $i; - fn mul(self, rhs: $i) -> $i { self * rhs } - } - - impl Sub for $i { - type Output = $i; - fn sub(self, rhs: $i) -> $i { self - rhs } - } - impl BitAnd for $i { - type Output = $i; - fn bitand(self, rhs: $i) -> $i { self & rhs } - } - impl BitAndAssign for $i { - fn bitand_assign(&mut self, rhs: $i) { *self &= rhs; } - } - impl BitOr for $i { - type Output = $i; - fn bitor(self, rhs: $i) -> $i { self | rhs } - } - impl BitOrAssign for $i { - fn bitor_assign(&mut self, rhs: $i) { *self |= rhs; } - } - impl BitXor for $i { - type Output = $i; - fn bitxor(self, rhs: $i) -> $i { self ^ rhs } - } - impl BitXorAssign for $i { - fn bitxor_assign(&mut self, rhs: $i) { *self ^= rhs; } - } - impl Neg for $i { - type Output = $i; - fn neg(self) -> $i { -self } - } - impl Not for $i { - type Output = $i; - fn not(self) -> $i { !self } - } - impl Add<$i> for $i { - type Output = $i; - fn add(self, other: $i) -> $i { self + other } - } - impl Copy for $i {} - impl Clone for $i { - fn clone(&self) -> $i { loop {} } - } - )*) -} -each_int!(impl_traits); - -pub mod mem { - pub fn size_of_val(_: &T) -> usize { - 4 - } - pub const fn size_of() -> usize { - 4 - } -} diff --git a/src/lib.rs b/src/lib.rs index 8a7750acb0aca..b1afc08a01afa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -8,13 +8,10 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. //! libc - Raw FFI bindings to platforms' system libraries - #![crate_name = "libc"] #![crate_type = "rlib"] #![cfg_attr(not(feature = "rustc-dep-of-std"), deny(warnings))] #![allow(bad_style, overflowing_literals, improper_ctypes, unknown_lints)] -#![cfg_attr(cross_platform_docs, feature(no_core, lang_items, const_fn))] -#![cfg_attr(cross_platform_docs, no_core)] // Attributes needed when building as part of the standard library #![cfg_attr( feature = "rustc-dep-of-std", @@ -28,7 +25,7 @@ not(any( feature = "use_std", feature = "rustc-dep-of-std", - cross_platform_docs + cross_platform_docs, )), no_std )] @@ -50,60 +47,49 @@ cfg_if! { } cfg_if! { - if #[cfg(not(cross_platform_docs))] { - cfg_if! { - if #[cfg(libc_priv_mod_use)] { - #[cfg(libc_core_cvoid)] - #[allow(unused_imports)] - use core::ffi; - #[allow(unused_imports)] - use core::fmt; - #[allow(unused_imports)] - use core::hash; - #[allow(unused_imports)] - use core::num; - #[allow(unused_imports)] - use core::mem; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::clone::Clone; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::marker::Copy; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::option::Option; - } else { - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::fmt; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::hash; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::num; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::mem; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::clone::Clone; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::marker::Copy; - #[doc(hidden)] - #[allow(unused_imports)] - pub use core::option::Option; - } - } - } -} - -cfg_if! { - if #[cfg(cross_platform_docs)] { - mod dox; - pub use self::dox::*; + if #[cfg(libc_priv_mod_use)] { + #[cfg(libc_core_cvoid)] + #[allow(unused_imports)] + use core::ffi; + #[allow(unused_imports)] + use core::fmt; + #[allow(unused_imports)] + use core::hash; + #[allow(unused_imports)] + use core::num; + #[allow(unused_imports)] + use core::mem; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::clone::Clone; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::marker::Copy; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::option::Option; + } else { + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::fmt; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::hash; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::num; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::mem; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::clone::Clone; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::marker::Copy; + #[doc(hidden)] + #[allow(unused_imports)] + pub use core::option::Option; } } From dcf20b75d4ea3fc432b8c4beacf3a8bedc02bfa2 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Mon, 18 Feb 2019 20:26:40 +0100 Subject: [PATCH 02/19] Fix DragonflyBSD build --- src/unix/bsd/freebsdlike/dragonfly/mod.rs | 111 ++++++++++++---------- 1 file changed, 59 insertions(+), 52 deletions(-) diff --git a/src/unix/bsd/freebsdlike/dragonfly/mod.rs b/src/unix/bsd/freebsdlike/dragonfly/mod.rs index c4fc528439644..7c96ebcf0e669 100644 --- a/src/unix/bsd/freebsdlike/dragonfly/mod.rs +++ b/src/unix/bsd/freebsdlike/dragonfly/mod.rs @@ -31,23 +31,6 @@ s! { pub e_exit: u16 } - pub struct utmpx { - pub ut_name: [::c_char; 32], - pub ut_id: [::c_char; 4], - - pub ut_line: [::c_char; 32], - pub ut_host: [::c_char; 256], - - pub ut_unused: [u8; 16], - pub ut_session: u16, - pub ut_type: u16, - pub ut_pid: ::pid_t, - ut_exit: exit_status, - ut_ss: ::sockaddr_storage, - pub ut_tv: ::timeval, - pub ut_unused2: [u8; 16], - } - pub struct aiocb { pub aio_fildes: ::c_int, pub aio_offset: ::off_t, @@ -60,15 +43,6 @@ s! { _aio_err: ::c_int } - pub struct dirent { - pub d_fileno: ::ino_t, - pub d_namlen: u16, - pub d_type: u8, - __unused1: u8, - __unused2: u32, - pub d_name: [::c_char; 256], - } - pub struct uuid { pub time_low: u32, pub time_mid: u16, @@ -120,27 +94,6 @@ s! { pub f_uid_uuid: ::uuid_t, } - pub struct statfs { - pub f_bsize: ::c_long, - pub f_iosize: ::c_long, - pub f_blocks: ::c_long, - pub f_bfree: ::c_long, - pub f_bavail: ::c_long, - pub f_files: ::c_long, - pub f_ffree: ::c_long, - pub f_fsid: ::fsid_t, - pub f_owner: ::uid_t, - pub f_type: ::int32_t, - pub f_flags: ::int32_t, - pub f_syncwrites: ::c_long, - pub f_asyncwrites: ::c_long, - pub f_fstypename: [::c_char; 16], - pub f_mntonname: [::c_char; 90], - pub f_syncreads: ::c_long, - pub f_asyncreads: ::c_long, - pub f_mntfromname: [::c_char; 90], - } - pub struct stat { pub st_ino: ::ino_t, pub st_nlink: ::nlink_t, @@ -223,6 +176,58 @@ s! { } } +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct utmpx { + pub ut_name: [::c_char; 32], + pub ut_id: [::c_char; 4], + + pub ut_line: [::c_char; 32], + pub ut_host: [::c_char; 256], + + pub ut_unused: [u8; 16], + pub ut_session: u16, + pub ut_type: u16, + pub ut_pid: ::pid_t, + ut_exit: exit_status, + ut_ss: ::sockaddr_storage, + pub ut_tv: ::timeval, + pub ut_unused2: [u8; 16], + } + + #[allow(missing_debug_implementations)] + pub struct dirent { + pub d_fileno: ::ino_t, + pub d_namlen: u16, + pub d_type: u8, + __unused1: u8, + __unused2: u32, + pub d_name: [::c_char; 256], + } + + #[allow(missing_debug_implementations)] + pub struct statfs { + pub f_bsize: ::c_long, + pub f_iosize: ::c_long, + pub f_blocks: ::c_long, + pub f_bfree: ::c_long, + pub f_bavail: ::c_long, + pub f_files: ::c_long, + pub f_ffree: ::c_long, + pub f_fsid: ::fsid_t, + pub f_owner: ::uid_t, + pub f_type: ::int32_t, + pub f_flags: ::int32_t, + pub f_syncwrites: ::c_long, + pub f_asyncwrites: ::c_long, + pub f_fstypename: [::c_char; 16], + pub f_mntonname: [::c_char; 90], + pub f_syncreads: ::c_long, + pub f_asyncreads: ::c_long, + pub f_mntfromname: [::c_char; 90], + } +} + pub const RAND_MAX: ::c_int = 0x7fff_ffff; pub const PTHREAD_STACK_MIN: ::size_t = 16384; pub const SIGSTKSZ: ::size_t = 40960; @@ -804,26 +809,28 @@ f! { } pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { - _CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) + length as usize + (_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) + length as usize) + as ::c_uint } pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr) -> *mut ::cmsghdr { - let next = cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len) + let next = cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize) + _CMSG_ALIGN(::mem::size_of::<::cmsghdr>()); let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; if next <= max { - (cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len)) as *mut ::cmsghdr + (cmsg as usize + _CMSG_ALIGN((*cmsg).cmsg_len as usize)) + as *mut ::cmsghdr } else { 0 as *mut ::cmsghdr } } pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { - _CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) + - _CMSG_ALIGN(length as usize) + (_CMSG_ALIGN(::mem::size_of::<::cmsghdr>()) + + _CMSG_ALIGN(length as usize)) as ::c_uint } } From 2130d45fb18ac954e6855eaea98f10a1e60d8434 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Mon, 18 Feb 2019 20:29:18 +0100 Subject: [PATCH 03/19] Fix Haiku build --- src/unix/haiku/mod.rs | 49 +++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/src/unix/haiku/mod.rs b/src/unix/haiku/mod.rs index 4d2082fa2cccc..d73967781bb04 100644 --- a/src/unix/haiku/mod.rs +++ b/src/unix/haiku/mod.rs @@ -69,20 +69,6 @@ s! { pub sin6_scope_id: u32, } - pub struct sockaddr_un { - pub sun_len: u8, - pub sun_family: sa_family_t, - pub sun_path: [::c_char; 126] - } - - pub struct sockaddr_storage { - pub ss_len: u8, - pub ss_family: sa_family_t, - __ss_pad1: [u8; 6], - __ss_pad2: u64, - __ss_pad3: [u8; 112], - } - pub struct addrinfo { pub ai_flags: ::c_int, pub ai_family: ::c_int, @@ -211,15 +197,6 @@ s! { pub st_blocks: blkcnt_t, } - pub struct dirent { - pub d_dev: dev_t, - pub d_pdev: dev_t, - pub d_ino: ino_t, - pub d_pino: i64, - pub d_reclen: ::c_ushort, - pub d_name: [::c_char; 1024], // Max length is _POSIX_PATH_MAX - } - pub struct glob_t { pub gl_pathc: ::size_t, __unused1: ::size_t, @@ -331,6 +308,32 @@ s! { } } +s_no_extra_traits! { + #[allow(missing_debug_implementations)] + pub struct sockaddr_un { + pub sun_len: u8, + pub sun_family: sa_family_t, + pub sun_path: [::c_char; 126] + } + #[allow(missing_debug_implementations)] + pub struct sockaddr_storage { + pub ss_len: u8, + pub ss_family: sa_family_t, + __ss_pad1: [u8; 6], + __ss_pad2: u64, + __ss_pad3: [u8; 112], + } + #[allow(missing_debug_implementations)] + pub struct dirent { + pub d_dev: dev_t, + pub d_pdev: dev_t, + pub d_ino: ino_t, + pub d_pino: i64, + pub d_reclen: ::c_ushort, + pub d_name: [::c_char; 1024], // Max length is _POSIX_PATH_MAX + } +} + // intentionally not public, only used for fd_set cfg_if! { if #[cfg(target_pointer_width = "32")] { From bbe4571216f2fa7226d1aef44e9a91bee18b62be Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Mon, 18 Feb 2019 20:39:17 +0100 Subject: [PATCH 04/19] Remove non-existent uclib targets --- ci/build.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 09a05be121c8b..05e1e9a849f56 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -67,8 +67,6 @@ i686-pc-windows-msvc \ i686-unknown-cloudabi \ i686-unknown-haiku \ i686-unknown-netbsd \ -mips-unknown-linux-uclib \ -mipsel-unknown-unknown-linux-uclib \ nvptx64-nvidia-cuda \ powerpc-unknown-linux-gnuspe \ riscv32imac-unknown-none-elf \ From 0180e40f22fb9372c88c3d501a58ccde915474d2 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Mon, 18 Feb 2019 21:05:34 +0100 Subject: [PATCH 05/19] Libcore fails to build for sparc-unknown-linux-gnu --- ci/build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/build.sh b/ci/build.sh index 05e1e9a849f56..d98b302674590 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -56,6 +56,8 @@ rustup component add rust-src || true cargo install xargo || true +# FIXME: https://github.com/rust-lang/rust/issues/58564 +# sparc-unknown-linux-gnu RUST_LINUX_NO_CORE_TARGETS="\ x86_64-unknown-dragonfly \ aarch64-pc-windows-msvc \ @@ -71,7 +73,6 @@ nvptx64-nvidia-cuda \ powerpc-unknown-linux-gnuspe \ riscv32imac-unknown-none-elf \ riscv32imc-unknown-none-elf \ -sparc-unknown-linux-gnu \ sparc64-unknown-netbsd \ thumbv8m.main-none-eabi \ x86_64-pc-windows-gnu \ From 2e2e4e10c39eccf396f9af11913315738113b130 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Mon, 18 Feb 2019 21:07:06 +0100 Subject: [PATCH 06/19] Fix unclosed delimiter in openbsd --- src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs index 5c9eea1db4308..4a032286e829e 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs @@ -305,6 +305,7 @@ cfg_if! { } } } +} //https://github.com/openbsd/src/blob/master/sys/sys/mount.h pub const ISOFSMNT_NORRIP: ::c_int = 0x1; // disable Rock Ridge Ext From 1c264bdafac55ed5711790d210207f55db6f9645 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Mon, 18 Feb 2019 21:09:52 +0100 Subject: [PATCH 07/19] Fix use of std:: in the OpenBSD-like module --- src/unix/bsd/netbsdlike/openbsdlike/mod.rs | 40 +++++++++---------- .../bsd/netbsdlike/openbsdlike/openbsd/mod.rs | 18 ++++----- 2 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/unix/bsd/netbsdlike/openbsdlike/mod.rs b/src/unix/bsd/netbsdlike/openbsdlike/mod.rs index a003a0d0cea72..843a5457ce1d7 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/mod.rs @@ -242,8 +242,8 @@ cfg_if! { impl Eq for dirent {} - impl std::fmt::Debug for dirent { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl ::fmt::Debug for dirent { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("dirent") .field("d_fileno", &self.d_fileno) .field("d_off", &self.d_off) @@ -255,8 +255,8 @@ cfg_if! { } } - impl std::hash::Hash for dirent { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for dirent { + fn hash(&self, state: &mut H) { self.d_fileno.hash(state); self.d_off.hash(state); self.d_reclen.hash(state); @@ -275,8 +275,8 @@ cfg_if! { impl Eq for sockaddr_storage {} - impl std::fmt::Debug for sockaddr_storage { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl ::fmt::Debug for sockaddr_storage { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("sockaddr_storage") .field("ss_len", &self.ss_len) .field("ss_family", &self.ss_family) @@ -284,8 +284,8 @@ cfg_if! { } } - impl std::hash::Hash for sockaddr_storage { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for sockaddr_storage { + fn hash(&self, state: &mut H) { self.ss_len.hash(state); self.ss_family.hash(state); } @@ -302,8 +302,8 @@ cfg_if! { impl Eq for siginfo_t {} - impl std::fmt::Debug for siginfo_t { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl ::fmt::Debug for siginfo_t { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("siginfo_t") .field("si_signo", &self.si_signo) .field("si_code", &self.si_code) @@ -313,8 +313,8 @@ cfg_if! { } } - impl std::hash::Hash for siginfo_t { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for siginfo_t { + fn hash(&self, state: &mut H) { self.si_signo.hash(state); self.si_code.hash(state); self.si_errno.hash(state); @@ -340,8 +340,8 @@ cfg_if! { impl Eq for lastlog {} - impl std::fmt::Debug for lastlog { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl ::fmt::Debug for lastlog { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("lastlog") .field("ll_time", &self.ll_time) // FIXME: .field("ll_line", &self.ll_line) @@ -350,8 +350,8 @@ cfg_if! { } } - impl std::hash::Hash for lastlog { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for lastlog { + fn hash(&self, state: &mut H) { self.ll_time.hash(state); self.ll_line.hash(state); self.ll_host.hash(state); @@ -381,8 +381,8 @@ cfg_if! { impl Eq for utmp {} - impl std::fmt::Debug for utmp { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl ::fmt::Debug for utmp { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("utmp") // FIXME: .field("ut_line", &self.ut_line) // FIXME: .field("ut_name", &self.ut_name) @@ -392,8 +392,8 @@ cfg_if! { } } - impl std::hash::Hash for utmp { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for utmp { + fn hash(&self, state: &mut H) { self.ut_line.hash(state); self.ut_name.hash(state); self.ut_host.hash(state); diff --git a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs index 4a032286e829e..a2cd83c682829 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs @@ -157,16 +157,16 @@ cfg_if! { impl Eq for mount_info { } - impl std::fmt::Debug for mount_info { - fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + impl ::fmt::Debug for mount_info { + fn fmt(&self, f: &mut ::fmt::Formatter) -> ::fmt::Result { f.debug_struct("mount_info") // FIXME: .field("align", &self.align) .finish() } } - impl std::hash::Hash for mount_info { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for mount_info { + fn hash(&self, state: &mut H) { unsafe { self.align.hash(state) }; } } @@ -246,9 +246,9 @@ cfg_if! { impl Eq for statfs { } - impl std::fmt::Debug for statfs { - fn fmt(&self, f: &mut std::fmt::Formatter) - -> std::fmt::Result { + impl ::fmt::Debug for statfs { + fn fmt(&self, f: &mut ::fmt::Formatter) + -> ::fmt::Result { f.debug_struct("statfs") .field("f_flags", &self.f_flags) .field("f_bsize", &self.f_bsize) @@ -276,8 +276,8 @@ cfg_if! { } } - impl std::hash::Hash for statfs { - fn hash(&self, state: &mut H) { + impl ::hash::Hash for statfs { + fn hash(&self, state: &mut H) { self.f_flags.hash(state); self.f_bsize.hash(state); self.f_iosize.hash(state); From 971027d5358aa034be9230fcd4c1ae981a32f5b5 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Mon, 18 Feb 2019 21:25:19 +0100 Subject: [PATCH 08/19] Fix bitrig build --- ci/build.sh | 71 +++++++++---------- .../bsd/netbsdlike/openbsdlike/bitrig/x86.rs | 11 +++ .../netbsdlike/openbsdlike/bitrig/x86_64.rs | 11 +++ 3 files changed, 57 insertions(+), 36 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index d98b302674590..b33d89c40fc37 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -52,42 +52,6 @@ test_target() { fi } -rustup component add rust-src || true -cargo install xargo || true - - -# FIXME: https://github.com/rust-lang/rust/issues/58564 -# sparc-unknown-linux-gnu -RUST_LINUX_NO_CORE_TARGETS="\ -x86_64-unknown-dragonfly \ -aarch64-pc-windows-msvc \ -aarch64-unknown-cloudabi \ -armv7-unknown-cloudabi-eabihf \ -i586-pc-windows-msvc \ -i686-pc-windows-gnu \ -i686-pc-windows-msvc \ -i686-unknown-cloudabi \ -i686-unknown-haiku \ -i686-unknown-netbsd \ -nvptx64-nvidia-cuda \ -powerpc-unknown-linux-gnuspe \ -riscv32imac-unknown-none-elf \ -riscv32imc-unknown-none-elf \ -sparc64-unknown-netbsd \ -thumbv8m.main-none-eabi \ -x86_64-pc-windows-gnu \ -x86_64-pc-windows-msvc -x86_64-unknown-bitrig \ -x86_64-unknown-haiku \ -x86_64-unknown-openbsd -" - -for TARGET in $RUST_LINUX_NO_CORE_TARGETS; do - if [ "${RUST}" = "nightly" ]; then - RUST_LIBC_NO_CORE_BUILD=1 test_target xargo "$TARGET" 1 - fi -done - RUST_LINUX_TARGETS="\ aarch64-linux-android \ aarch64-unknown-linux-gnu \ @@ -206,3 +170,38 @@ esac for TARGET in $TARGETS; do test_target cargo "$TARGET" done + +# FIXME: https://github.com/rust-lang/rust/issues/58564 +# sparc-unknown-linux-gnu +RUST_LINUX_NO_CORE_TARGETS="\ +x86_64-unknown-dragonfly \ +aarch64-pc-windows-msvc \ +aarch64-unknown-cloudabi \ +armv7-unknown-cloudabi-eabihf \ +i586-pc-windows-msvc \ +i686-pc-windows-gnu \ +i686-pc-windows-msvc \ +i686-unknown-cloudabi \ +i686-unknown-haiku \ +i686-unknown-netbsd \ +nvptx64-nvidia-cuda \ +powerpc-unknown-linux-gnuspe \ +riscv32imac-unknown-none-elf \ +riscv32imc-unknown-none-elf \ +sparc64-unknown-netbsd \ +thumbv8m.main-none-eabi \ +x86_64-pc-windows-gnu \ +x86_64-pc-windows-msvc +x86_64-unknown-bitrig \ +x86_64-unknown-haiku \ +x86_64-unknown-openbsd +" + +if [ "${RUST}" = "nightly" ]; then + rustup component add rust-src || true + cargo install xargo || true + + for TARGET in $RUST_LINUX_NO_CORE_TARGETS; do + RUST_LIBC_NO_CORE_BUILD=1 test_target xargo "$TARGET" 1 + done +fi diff --git a/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86.rs b/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86.rs index 9b0b338b91e5b..85a106227e0f1 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86.rs @@ -1,2 +1,13 @@ pub type c_long = i32; pub type c_ulong = u32; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 4 - 1; + } +} diff --git a/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs b/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs index d3971aa35b87b..b6ce54e2c2641 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs @@ -8,3 +8,14 @@ pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 3; pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 4; + +// should be pub(crate), but that requires Rust 1.18.0 +cfg_if! { + if #[cfg(libc_const_size_of)] { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; + } else { + #[doc(hidden)] + pub const _ALIGNBYTES: usize = 8 - 1; + } +} From 9a1d1f644543aacee6bf8c8476b12d7e41d9d545 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Mon, 18 Feb 2019 22:56:19 +0100 Subject: [PATCH 09/19] Remove more documentation cruft --- src/lib.rs | 3 +-- src/macros.rs | 7 ------- src/unix/mod.rs | 4 +--- 3 files changed, 2 insertions(+), 12 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index b1afc08a01afa..3fddb3f504b0f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,12 +25,11 @@ not(any( feature = "use_std", feature = "rustc-dep-of-std", - cross_platform_docs, )), no_std )] -#[cfg(all(not(cross_platform_docs), feature = "use_std"))] +#[cfg(feature = "use_std")] extern crate std as core; #[macro_use] diff --git a/src/macros.rs b/src/macros.rs index af7bbdd37bb94..c48ae8bc40b41 100644 --- a/src/macros.rs +++ b/src/macros.rs @@ -124,16 +124,9 @@ macro_rules! f { $($body:stmt);* })*) => ($( #[inline] - #[cfg(not(cross_platform_docs))] pub unsafe extern fn $i($($arg: $argty),*) -> $ret { $($body);* } - - #[cfg(cross_platform_docs)] - #[allow(dead_code)] - pub unsafe extern fn $i($($arg: $argty),*) -> $ret { - loop {} - } )*) } diff --git a/src/unix/mod.rs b/src/unix/mod.rs index cb0862f55ad63..057a93bd75266 100644 --- a/src/unix/mod.rs +++ b/src/unix/mod.rs @@ -301,9 +301,7 @@ pub const ATF_PUBL: ::c_int = 0x08; pub const ATF_USETRAILERS: ::c_int = 0x10; cfg_if! { - if #[cfg(cross_platform_docs)] { - // on dox builds don't pull in anything - } else if #[cfg(target_os = "l4re")] { + if #[cfg(target_os = "l4re")] { // required libraries for L4Re are linked externally, ATM } else if #[cfg(feature = "use_std")] { // cargo build, don't pull in anything extra as the libstd dep From 34dd2da3f993b8e6d020ace9f513ffd32c10b66f Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 19 Feb 2019 11:06:21 +0100 Subject: [PATCH 10/19] Run xargo only on Linux --- ci/build.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index b33d89c40fc37..bb8a91a8faec1 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -106,8 +106,6 @@ RUST_NIGHTLY_LINUX_TARGETS="\ aarch64-fuchsia \ armv5te-unknown-linux-gnueabi \ armv5te-unknown-linux-musleabi \ -armebv7r-none-eabi \ -armebv7r-none-eabihf \ armv7r-none-eabi \ armv7r-none-eabihf \ thumbv6m-none-eabi \ @@ -177,6 +175,8 @@ RUST_LINUX_NO_CORE_TARGETS="\ x86_64-unknown-dragonfly \ aarch64-pc-windows-msvc \ aarch64-unknown-cloudabi \ +armebv7r-none-eabi \ +armebv7r-none-eabihf \ armv7-unknown-cloudabi-eabihf \ i586-pc-windows-msvc \ i686-pc-windows-gnu \ @@ -197,7 +197,7 @@ x86_64-unknown-haiku \ x86_64-unknown-openbsd " -if [ "${RUST}" = "nightly" ]; then +if [ "${RUST}" = "nightly" ] && [ "${OS}" = "linux" ]; then rustup component add rust-src || true cargo install xargo || true From 9bdc5122daaa782e3d7f5f3cd27371cb285cd91d Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 19 Feb 2019 11:17:00 +0100 Subject: [PATCH 11/19] The armv7r targets are not available on nightly --- ci/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index bb8a91a8faec1..a1a6b03dbd3d6 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -106,8 +106,6 @@ RUST_NIGHTLY_LINUX_TARGETS="\ aarch64-fuchsia \ armv5te-unknown-linux-gnueabi \ armv5te-unknown-linux-musleabi \ -armv7r-none-eabi \ -armv7r-none-eabihf \ thumbv6m-none-eabi \ thumbv7em-none-eabi \ thumbv7em-none-eabihf \ @@ -178,6 +176,8 @@ aarch64-unknown-cloudabi \ armebv7r-none-eabi \ armebv7r-none-eabihf \ armv7-unknown-cloudabi-eabihf \ +armv7r-none-eabi \ +armv7r-none-eabihf \ i586-pc-windows-msvc \ i686-pc-windows-gnu \ i686-pc-windows-msvc \ From e3914cf31a4f27fa02845bd59328afff1f7eb5b5 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 19 Feb 2019 12:12:49 +0100 Subject: [PATCH 12/19] Make the build script fail faster --- .travis.yml | 4 +++- ci/build.sh | 5 +---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5a5bbebfa403e..115a516ad0b3c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,7 +48,9 @@ matrix: script: sh ci/build.sh stage: tools-and-build-and-tier1 rust: nightly - install: true + install: + - rustup component add rust-src + - cargo install xargo - name: "Build Stable Rust" script: sh ci/build.sh stage: tools-and-build-and-tier1 diff --git a/ci/build.sh b/ci/build.sh index a1a6b03dbd3d6..0666bf14160c0 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -30,7 +30,7 @@ test_target() { ;; esac - rustup target add "${TARGET}" --toolchain "${RUST}" || true + rustup target add "${TARGET}" --toolchain "${RUST}" # Test that libc builds without any default features (no libstd) "$CARGO" "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" @@ -198,9 +198,6 @@ x86_64-unknown-openbsd " if [ "${RUST}" = "nightly" ] && [ "${OS}" = "linux" ]; then - rustup component add rust-src || true - cargo install xargo || true - for TARGET in $RUST_LINUX_NO_CORE_TARGETS; do RUST_LIBC_NO_CORE_BUILD=1 test_target xargo "$TARGET" 1 done From 6a6dd26447642028fad4953db52fc1576c2d7569 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 19 Feb 2019 14:19:45 +0100 Subject: [PATCH 13/19] Only fetch std component when there is something to fetch --- ci/build.sh | 27 ++++++++++++--------------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 0666bf14160c0..c97d61a1a971a 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -13,6 +13,7 @@ echo "Testing Rust ${RUST} on ${OS}" test_target() { CARGO="${1}" TARGET="${2}" + NO_STD="${3}" opt= if [ "${TARGET}" = "x86_64-unknown-linux-gnux32" ]; then @@ -23,14 +24,10 @@ test_target() { opt="--release" fi - NO_STD="${3}" - case ${TARGET} in - thumbv*) - NO_STD=1 - ;; - esac - - rustup target add "${TARGET}" --toolchain "${RUST}" + # If there is a std component, fetch it: + if [ "${NO_STD}" != "1" ]; then + rustup target add "${TARGET}" --toolchain "${RUST}" + fi # Test that libc builds without any default features (no libstd) "$CARGO" "+${RUST}" build -vv $opt --no-default-features --target "${TARGET}" @@ -106,12 +103,6 @@ RUST_NIGHTLY_LINUX_TARGETS="\ aarch64-fuchsia \ armv5te-unknown-linux-gnueabi \ armv5te-unknown-linux-musleabi \ -thumbv6m-none-eabi \ -thumbv7em-none-eabi \ -thumbv7em-none-eabihf \ -thumbv7m-none-eabi \ -thumbv7neon-linux-androideabi \ -thumbv7neon-unknown-linux-gnueabihf \ x86_64-fortanix-unknown-sgx \ x86_64-fuchsia \ x86_64-unknown-linux-gnux32 \ @@ -189,6 +180,12 @@ powerpc-unknown-linux-gnuspe \ riscv32imac-unknown-none-elf \ riscv32imc-unknown-none-elf \ sparc64-unknown-netbsd \ +thumbv6m-none-eabi \ +thumbv7em-none-eabi \ +thumbv7em-none-eabihf \ +thumbv7m-none-eabi \ +thumbv7neon-linux-androideabi \ +thumbv7neon-unknown-linux-gnueabihf \ thumbv8m.main-none-eabi \ x86_64-pc-windows-gnu \ x86_64-pc-windows-msvc @@ -199,6 +196,6 @@ x86_64-unknown-openbsd if [ "${RUST}" = "nightly" ] && [ "${OS}" = "linux" ]; then for TARGET in $RUST_LINUX_NO_CORE_TARGETS; do - RUST_LIBC_NO_CORE_BUILD=1 test_target xargo "$TARGET" 1 + test_target xargo "$TARGET" 1 done fi From 7da4f477d027b5eef72b924349490a5c21d1ca72 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Tue, 19 Feb 2019 14:57:16 +0100 Subject: [PATCH 14/19] cross-compile to the gnu windows targets on nightly with libstd --- ci/build.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index c97d61a1a971a..a97af20a459e0 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -103,8 +103,10 @@ RUST_NIGHTLY_LINUX_TARGETS="\ aarch64-fuchsia \ armv5te-unknown-linux-gnueabi \ armv5te-unknown-linux-musleabi \ +i686-pc-windows-gnu \ x86_64-fortanix-unknown-sgx \ x86_64-fuchsia \ +x86_64-pc-windows-gnu \ x86_64-unknown-linux-gnux32 \ x86_64-unknown-redox \ " @@ -170,7 +172,6 @@ armv7-unknown-cloudabi-eabihf \ armv7r-none-eabi \ armv7r-none-eabihf \ i586-pc-windows-msvc \ -i686-pc-windows-gnu \ i686-pc-windows-msvc \ i686-unknown-cloudabi \ i686-unknown-haiku \ @@ -187,7 +188,6 @@ thumbv7m-none-eabi \ thumbv7neon-linux-androideabi \ thumbv7neon-unknown-linux-gnueabihf \ thumbv8m.main-none-eabi \ -x86_64-pc-windows-gnu \ x86_64-pc-windows-msvc x86_64-unknown-bitrig \ x86_64-unknown-haiku \ From 5f9be7eebe3290514f8e7c6fdfc430895f13d92a Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 20 Feb 2019 09:39:34 +0100 Subject: [PATCH 15/19] Remove the CMSG_ APIs from bitrig --- src/unix/bsd/netbsdlike/mod.rs | 50 ----------------- src/unix/bsd/netbsdlike/netbsd/mod.rs | 54 +++++++++++++++++-- .../bsd/netbsdlike/openbsdlike/bitrig/x86.rs | 11 ---- .../netbsdlike/openbsdlike/bitrig/x86_64.rs | 11 ---- .../bsd/netbsdlike/openbsdlike/openbsd/mod.rs | 50 +++++++++++++++++ 5 files changed, 101 insertions(+), 75 deletions(-) diff --git a/src/unix/bsd/netbsdlike/mod.rs b/src/unix/bsd/netbsdlike/mod.rs index 7ba19931fd824..c06d4793f9022 100644 --- a/src/unix/bsd/netbsdlike/mod.rs +++ b/src/unix/bsd/netbsdlike/mod.rs @@ -595,56 +595,6 @@ pub const SF_APPEND: ::c_ulong = 0x00040000; pub const TIMER_ABSTIME: ::c_int = 1; -fn _ALIGN(p: usize) -> usize { - (p + _ALIGNBYTES) & !_ALIGNBYTES -} - -f! { - pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar { - (cmsg as *mut ::c_uchar) - .offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize) - } - - pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { - _ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length - } - - pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr) - -> *mut ::cmsghdr - { - if cmsg.is_null() { - return ::CMSG_FIRSTHDR(mhdr); - }; - let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) - + _ALIGN(::mem::size_of::<::cmsghdr>()); - let max = (*mhdr).msg_control as usize - + (*mhdr).msg_controllen as usize; - if next > max { - 0 as *mut ::cmsghdr - } else { - (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) - as *mut ::cmsghdr - } - } - - pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { - (_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize)) - as ::c_uint - } - - pub fn WSTOPSIG(status: ::c_int) -> ::c_int { - status >> 8 - } - - pub fn WIFSIGNALED(status: ::c_int) -> bool { - (status & 0o177) != 0o177 && (status & 0o177) != 0 - } - - pub fn WIFSTOPPED(status: ::c_int) -> bool { - (status & 0o177) == 0o177 - } -} - #[link(name = "util")] extern { pub fn mincore(addr: *mut ::c_void, len: ::size_t, diff --git a/src/unix/bsd/netbsdlike/netbsd/mod.rs b/src/unix/bsd/netbsdlike/netbsd/mod.rs index 1bc6743ac188a..e1ba222bf7b72 100644 --- a/src/unix/bsd/netbsdlike/netbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/netbsd/mod.rs @@ -1060,10 +1060,58 @@ pub const SF_SNAPSHOT: ::c_ulong = 0x00200000; pub const SF_LOG: ::c_ulong = 0x00400000; pub const SF_SNAPINVAL: ::c_ulong = 0x00800000; -// dirfd() is a macro on netbsd to access -// the first field of the struct where dirp points to: -// http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36 +fn _ALIGN(p: usize) -> usize { + (p + _ALIGNBYTES) & !_ALIGNBYTES +} + f! { + pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar { + (cmsg as *mut ::c_uchar) + .offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize) + } + + pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { + _ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length + } + + pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr) + -> *mut ::cmsghdr + { + if cmsg.is_null() { + return ::CMSG_FIRSTHDR(mhdr); + }; + let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + + _ALIGN(::mem::size_of::<::cmsghdr>()); + let max = (*mhdr).msg_control as usize + + (*mhdr).msg_controllen as usize; + if next > max { + 0 as *mut ::cmsghdr + } else { + (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) + as *mut ::cmsghdr + } + } + + pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { + (_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize)) + as ::c_uint + } + + pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + status >> 8 + } + + pub fn WIFSIGNALED(status: ::c_int) -> bool { + (status & 0o177) != 0o177 && (status & 0o177) != 0 + } + + pub fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0o177) == 0o177 + } + + // dirfd() is a macro on netbsd to access + // the first field of the struct where dirp points to: + // http://cvsweb.netbsd.org/bsdweb.cgi/src/include/dirent.h?rev=1.36 pub fn dirfd(dirp: *mut ::DIR) -> ::c_int { *(dirp as *const ::c_int) } diff --git a/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86.rs b/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86.rs index 85a106227e0f1..9b0b338b91e5b 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86.rs @@ -1,13 +1,2 @@ pub type c_long = i32; pub type c_ulong = u32; - -// should be pub(crate), but that requires Rust 1.18.0 -cfg_if! { - if #[cfg(libc_const_size_of)] { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_int>() - 1; - } else { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = 4 - 1; - } -} diff --git a/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs b/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs index b6ce54e2c2641..d3971aa35b87b 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/bitrig/x86_64.rs @@ -8,14 +8,3 @@ pub const PT_GETREGS: ::c_int = PT_FIRSTMACH + 1; pub const PT_SETREGS: ::c_int = PT_FIRSTMACH + 2; pub const PT_GETFPREGS: ::c_int = PT_FIRSTMACH + 3; pub const PT_SETFPREGS: ::c_int = PT_FIRSTMACH + 4; - -// should be pub(crate), but that requires Rust 1.18.0 -cfg_if! { - if #[cfg(libc_const_size_of)] { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = ::mem::size_of::<::c_long>() - 1; - } else { - #[doc(hidden)] - pub const _ALIGNBYTES: usize = 8 - 1; - } -} diff --git a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs index a2cd83c682829..69859cbb1a424 100644 --- a/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs +++ b/src/unix/bsd/netbsdlike/openbsdlike/openbsd/mod.rs @@ -392,6 +392,56 @@ pub const SIGSTKSZ : ::size_t = 28672; pub const PT_FIRSTMACH: ::c_int = 32; +fn _ALIGN(p: usize) -> usize { + (p + _ALIGNBYTES) & !_ALIGNBYTES +} + +f! { + pub fn CMSG_DATA(cmsg: *const ::cmsghdr) -> *mut ::c_uchar { + (cmsg as *mut ::c_uchar) + .offset(_ALIGN(::mem::size_of::<::cmsghdr>()) as isize) + } + + pub fn CMSG_LEN(length: ::c_uint) -> ::c_uint { + _ALIGN(::mem::size_of::<::cmsghdr>()) as ::c_uint + length + } + + pub fn CMSG_NXTHDR(mhdr: *const ::msghdr, cmsg: *const ::cmsghdr) + -> *mut ::cmsghdr + { + if cmsg.is_null() { + return ::CMSG_FIRSTHDR(mhdr); + }; + let next = cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize) + + _ALIGN(::mem::size_of::<::cmsghdr>()); + let max = (*mhdr).msg_control as usize + + (*mhdr).msg_controllen as usize; + if next > max { + 0 as *mut ::cmsghdr + } else { + (cmsg as usize + _ALIGN((*cmsg).cmsg_len as usize)) + as *mut ::cmsghdr + } + } + + pub fn CMSG_SPACE(length: ::c_uint) -> ::c_uint { + (_ALIGN(::mem::size_of::<::cmsghdr>()) + _ALIGN(length as usize)) + as ::c_uint + } + + pub fn WSTOPSIG(status: ::c_int) -> ::c_int { + status >> 8 + } + + pub fn WIFSIGNALED(status: ::c_int) -> bool { + (status & 0o177) != 0o177 && (status & 0o177) != 0 + } + + pub fn WIFSTOPPED(status: ::c_int) -> bool { + (status & 0o177) == 0o177 + } +} + extern { pub fn accept4(s: ::c_int, addr: *mut ::sockaddr, addrlen: *mut ::socklen_t, flags: ::c_int) -> ::c_int; From 863d70391046dbccfa6ba9004549934601de2059 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 20 Feb 2019 13:01:00 +0100 Subject: [PATCH 16/19] Retry downloading artifacts to prevent spurious failures due to network issues --- .travis.yml | 4 ++-- ci/build.sh | 18 ++++++++++-------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 115a516ad0b3c..2467c99078cc3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -49,8 +49,8 @@ matrix: stage: tools-and-build-and-tier1 rust: nightly install: - - rustup component add rust-src - - cargo install xargo + - travis_retry rustup component add rust-src + - travis_retry cargo install xargo - name: "Build Stable Rust" script: sh ci/build.sh stage: tools-and-build-and-tier1 diff --git a/ci/build.sh b/ci/build.sh index a97af20a459e0..78c65be9714b4 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -26,7 +26,16 @@ test_target() { # If there is a std component, fetch it: if [ "${NO_STD}" != "1" ]; then - rustup target add "${TARGET}" --toolchain "${RUST}" + # FIXME: rustup often fails to download some artifacts due to network + # issues, so we retry this N times. + N=5 + n=0 + until [ $n -ge $N ] + do + rustup target add "${TARGET}" --toolchain "${RUST}" && break + n=$((n+1)) + sleep 1 + done fi # Test that libc builds without any default features (no libstd) @@ -110,13 +119,6 @@ x86_64-pc-windows-gnu \ x86_64-unknown-linux-gnux32 \ x86_64-unknown-redox \ " -# FIXME: these do not have a rust-std component available -# aarch64-unknown-cloudabi armv7-unknown-cloudabi-eabihf -# i686-unknown-cloudabi powerpc-unknown-linux-gnuspe -# sparc-unknown-linux-gnu mips-unknown-linux-uclib -# i686-unknown-haiku mipsel-unknown-unknown-linux-uclib -# sparc64-unknown-netbsd x86_64-unknown-bitrig x86_64-unknown-haiku -# x86_64-unknown-openbsd i686-unknown-netbsd RUST_OSX_TARGETS="\ aarch64-apple-ios \ From 7017701b219e9f545e5359da4669cfdd3185df54 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 20 Feb 2019 13:11:30 +0100 Subject: [PATCH 17/19] Re-enable target-specific docs --- .travis.yml | 4 +++- ci/dox.sh | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2467c99078cc3..b50cb44a20376 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,7 +14,9 @@ matrix: - name: "Documentation" env: TARGET=x86_64-unknown-linux-gnu script: sh ci/dox.sh - install: true + install: + - travis_retry rustup component add rust-src + - travis_retry cargo install xargo stage: tools-and-build-and-tier1 - name: "Shellcheck" install: true diff --git a/ci/dox.sh b/ci/dox.sh index 3456288a3791d..21a63dd755914 100644 --- a/ci/dox.sh +++ b/ci/dox.sh @@ -27,8 +27,11 @@ printf '### Platform-specific documentation\n' >> $PLATFORM_SUPPORT while read -r target; do echo "documenting ${target}" - #rustdoc -o "$TARGET_DOC_DIR/${target}" --target "${target}" src/lib.rs --cfg cross_platform_docs \ - # --crate-name libc + rustup target add "${target}" || true + xargo doc --target "${target}" \ + --no-default-features --features extra_traits + + cp -r "target/${target}/doc" "${TARGET_DOC_DIR}/${target}" echo "* [${target}](${target}/libc/index.html)" >> $PLATFORM_SUPPORT done < targets From 575fdc8c0db8ed9adeb6d844e51af66770c73a2d Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 20 Feb 2019 17:57:01 +0100 Subject: [PATCH 18/19] Do not try to build documentation for apple targets from Linux --- ci/dox.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/ci/dox.sh b/ci/dox.sh index 21a63dd755914..ff49298c1aac1 100644 --- a/ci/dox.sh +++ b/ci/dox.sh @@ -25,15 +25,25 @@ rm $PLATFORM_SUPPORT || true printf '### Platform-specific documentation\n' >> $PLATFORM_SUPPORT while read -r target; do - echo "documenting ${target}" + echo "documenting ${target}" - rustup target add "${target}" || true - xargo doc --target "${target}" \ - --no-default-features --features extra_traits + case "${target}" in + *apple*) + # FIXME: + # We can't build docs of apple targets from Linux yet. + continue + ;; + *) + ;; + esac - cp -r "target/${target}/doc" "${TARGET_DOC_DIR}/${target}" + rustup target add "${target}" || true + xargo doc --target "${target}" \ + --no-default-features --features extra_traits - echo "* [${target}](${target}/libc/index.html)" >> $PLATFORM_SUPPORT + cp -r "target/${target}/doc" "${TARGET_DOC_DIR}/${target}" + + echo "* [${target}](${target}/libc/index.html)" >> $PLATFORM_SUPPORT done < targets # Replace
with the contents of $PLATFORM_SUPPORT From a25a42be76f1e5fb1b86c115b5665a9743076c4d Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 20 Feb 2019 18:42:34 +0100 Subject: [PATCH 19/19] Speed up documentation build by using cargo when possible --- ci/build.sh | 4 +++- ci/dox.sh | 9 +++++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/ci/build.sh b/ci/build.sh index 78c65be9714b4..74727a3313a1f 100644 --- a/ci/build.sh +++ b/ci/build.sh @@ -32,7 +32,9 @@ test_target() { n=0 until [ $n -ge $N ] do - rustup target add "${TARGET}" --toolchain "${RUST}" && break + if rustup target add "${TARGET}" --toolchain "${RUST}" ; then + break + fi n=$((n+1)) sleep 1 done diff --git a/ci/dox.sh b/ci/dox.sh index ff49298c1aac1..6c0f1a0c64023 100644 --- a/ci/dox.sh +++ b/ci/dox.sh @@ -38,8 +38,13 @@ while read -r target; do esac rustup target add "${target}" || true - xargo doc --target "${target}" \ - --no-default-features --features extra_traits + + # If cargo doc fails, then try xargo: + if ! cargo doc --target "${target}" \ + --no-default-features --features extra_traits ; then + xargo doc --target "${target}" \ + --no-default-features --features extra_traits + fi cp -r "target/${target}/doc" "${TARGET_DOC_DIR}/${target}"