From bcaabae7c22d27fdbb07ea6009a6f4a9c3672fa2 Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Sat, 16 Sep 2017 08:42:30 -0700 Subject: Update libc crate to 0.2.30 Import subrepo libc/:libc at 3520512a8c9cb55661910318a6fb169a75c02a59 --- libc/libc-test/Cargo.toml | 12 ++- libc/libc-test/build-generated.rs | 16 ---- libc/libc-test/build.rs | 136 ++++++++++++++++++++++++++++--- libc/libc-test/generate-files/Cargo.toml | 16 ---- libc/libc-test/run-generated-Cargo.toml | 19 ----- libc/libc-test/src/main-generated.rs | 9 -- libc/libc-test/src/main.rs | 6 -- libc/libc-test/test/linux_fcntl.rs | 7 ++ libc/libc-test/test/main.rs | 6 ++ 9 files changed, 147 insertions(+), 80 deletions(-) delete mode 100644 libc/libc-test/build-generated.rs delete mode 100644 libc/libc-test/generate-files/Cargo.toml delete mode 100644 libc/libc-test/run-generated-Cargo.toml delete mode 100644 libc/libc-test/src/main-generated.rs delete mode 100644 libc/libc-test/src/main.rs create mode 100644 libc/libc-test/test/linux_fcntl.rs create mode 100644 libc/libc-test/test/main.rs (limited to 'libc/libc-test') diff --git a/libc/libc-test/Cargo.toml b/libc/libc-test/Cargo.toml index 4e7c884..dbdb632 100644 --- a/libc/libc-test/Cargo.toml +++ b/libc/libc-test/Cargo.toml @@ -8,4 +8,14 @@ build = "build.rs" libc = { path = ".." } [build-dependencies] -ctest = "0.1" +ctest = { git = 'https://github.com/alexcrichton/ctest', branch = 'long' } + +[[test]] +name = "main" +path = "test/main.rs" +harness = false + +[[test]] +name = "linux-fcntl" +path = "test/linux_fcntl.rs" +harness = false diff --git a/libc/libc-test/build-generated.rs b/libc/libc-test/build-generated.rs deleted file mode 100644 index a51c0e3..0000000 --- a/libc/libc-test/build-generated.rs +++ /dev/null @@ -1,16 +0,0 @@ -// This build script is distinct from the standard build.rs as it is only used -// for the BSDs which run a stripped down version. The `all.c` file is assumed -// to have been already generated for this build script. - -extern crate gcc; - -fn main() { - gcc::Config::new() - .file("all.c") - .flag("-Wall") - .flag("-Wextra") - .flag("-Werror") - .flag("-Wno-deprecated-declarations") - .flag("-Wno-type-limits") - .compile("liball.a"); -} diff --git a/libc/libc-test/build.rs b/libc/libc-test/build.rs index 8e54c82..ce50812 100644 --- a/libc/libc-test/build.rs +++ b/libc/libc-test/build.rs @@ -7,13 +7,15 @@ use std::env; fn main() { let target = env::var("TARGET").unwrap(); let aarch64 = target.contains("aarch64"); + let i686 = target.contains("i686"); let x86_64 = target.contains("x86_64"); let windows = target.contains("windows"); let mingw = target.contains("windows-gnu"); let linux = target.contains("unknown-linux"); let android = target.contains("android"); let apple = target.contains("apple"); - let musl = target.contains("musl"); + let emscripten = target.contains("asm"); + let musl = target.contains("musl") || emscripten; let uclibc = target.contains("uclibc"); let freebsd = target.contains("freebsd"); let dragonfly = target.contains("dragonfly"); @@ -25,7 +27,7 @@ fn main() { let mut cfg = ctest::TestGenerator::new(); // Pull in extra goodies - if linux || android { + if linux || android || emscripten { cfg.define("_GNU_SOURCE", None); } else if netbsd { cfg.define("_NETBSD_SOURCE", Some("1")); @@ -78,6 +80,7 @@ fn main() { cfg.header("netinet/in.h"); cfg.header("netinet/ip.h"); cfg.header("netinet/tcp.h"); + cfg.header("netinet/udp.h"); cfg.header("resolv.h"); cfg.header("pthread.h"); cfg.header("dlfcn.h"); @@ -105,6 +108,7 @@ fn main() { cfg.header("syslog.h"); cfg.header("semaphore.h"); cfg.header("sys/statvfs.h"); + cfg.header("sys/times.h"); } if android { @@ -116,6 +120,9 @@ fn main() { cfg.header("arpa/inet.h"); cfg.header("xlocale.h"); cfg.header("utmp.h"); + if i686 || x86_64 { + cfg.header("sys/reg.h"); + } } else if !windows { cfg.header("glob.h"); cfg.header("ifaddrs.h"); @@ -149,9 +156,13 @@ fn main() { cfg.header("malloc/malloc.h"); cfg.header("util.h"); cfg.header("sys/xattr.h"); + cfg.header("sys/sys_domain.h"); if target.starts_with("x86") { cfg.header("crt_externs.h"); } + cfg.header("net/route.h"); + cfg.header("net/route.h"); + cfg.header("sys/proc_info.h"); } if bsdlike { @@ -164,23 +175,33 @@ fn main() { } } - if linux { + if linux || emscripten { cfg.header("mqueue.h"); cfg.header("ucontext.h"); - cfg.header("sys/signalfd.h"); if !uclibc { // optionally included in uclibc cfg.header("sys/xattr.h"); } cfg.header("sys/ipc.h"); + cfg.header("sys/sem.h"); cfg.header("sys/msg.h"); cfg.header("sys/shm.h"); + cfg.header("sys/user.h"); cfg.header("sys/fsuid.h"); - cfg.header("pty.h"); cfg.header("shadow.h"); + if !emscripten { + cfg.header("linux/input.h"); + cfg.header("linux/falloc.h"); + } + if x86_64 { + cfg.header("sys/io.h"); + } + if i686 || x86_64 { + cfg.header("sys/reg.h"); + } } - if linux || android { + if linux || android || emscripten { cfg.header("malloc.h"); cfg.header("net/ethernet.h"); cfg.header("netpacket/packet.h"); @@ -189,13 +210,21 @@ fn main() { cfg.header("sys/eventfd.h"); cfg.header("sys/prctl.h"); cfg.header("sys/sendfile.h"); + cfg.header("sys/signalfd.h"); cfg.header("sys/vfs.h"); cfg.header("sys/syscall.h"); + cfg.header("sys/personality.h"); + cfg.header("sys/swap.h"); + cfg.header("pty.h"); if !uclibc { cfg.header("sys/sysinfo.h"); } cfg.header("sys/reboot.h"); + if !emscripten { + cfg.header("linux/netfilter_ipv4.h"); + } if !musl { + cfg.header("asm/mman.h"); cfg.header("linux/netlink.h"); cfg.header("linux/magic.h"); cfg.header("linux/reboot.h"); @@ -234,7 +263,7 @@ fn main() { cfg.header("sys/ioctl_compat.h"); } - if linux || freebsd || dragonfly || netbsd || apple { + if linux || freebsd || dragonfly || netbsd || apple || emscripten { if !uclibc { cfg.header("aio.h"); } @@ -293,6 +322,9 @@ fn main() { } } "u64" if struct_ == "epoll_event" => "data.u64".to_string(), + "type_" if linux && + (struct_ == "input_event" || struct_ == "input_mask" || + struct_ == "ff_effect") => "type".to_string(), s => s.to_string(), } }); @@ -321,6 +353,15 @@ fn main() { // This is actually a union, not a struct "sigval" => true, + // Linux kernel headers used on musl are too old to have this + // definition. Because it's tested on other Linux targets, skip it. + "input_mask" if musl => true, + + // These structs have changed since unified headers in NDK r14b. + // `st_atime` and `st_atime_nsec` have changed sign. + // FIXME: unskip it for next major release + "stat" | "stat64" if android => true, + _ => false } }); @@ -399,15 +440,44 @@ fn main() { "KERN_KDENABLE_BG_TRACE" if apple => true, "KERN_KDDISABLE_BG_TRACE" if apple => true, + // These constants were removed in OpenBSD 6 (https://git.io/v7gBO + // https://git.io/v7gBq) + "KERN_USERMOUNT" | + "KERN_ARND" if openbsd => true, + + // These constats were added in OpenBSD 6.2 + "EV_RECEIPT" | "EV_DISPATCH" if openbsd => true, + // These are either unimplemented or optionally built into uClibc "LC_CTYPE_MASK" | "LC_NUMERIC_MASK" | "LC_TIME_MASK" | "LC_COLLATE_MASK" | "LC_MONETARY_MASK" | "LC_MESSAGES_MASK" | "MADV_MERGEABLE" | "MADV_UNMERGEABLE" | "MADV_HWPOISON" | "IPV6_ADD_MEMBERSHIP" | "IPV6_DROP_MEMBERSHIP" | "IPV6_MULTICAST_LOOP" | "IPV6_V6ONLY" | "MAP_STACK" | "RTLD_DEEPBIND" | "SOL_IPV6" | "SOL_ICMPV6" if uclibc => true, + // Musl uses old, patched kernel headers + "FALLOC_FL_COLLAPSE_RANGE" | "FALLOC_FL_ZERO_RANGE" | + "FALLOC_FL_INSERT_RANGE" | "FALLOC_FL_UNSHARE_RANGE" if musl => true, + // Defined by libattr not libc on linux (hard to test). // See constant definition for more details. "ENOATTR" if linux => true, + // On mips*-unknown-linux-gnu* CMSPAR cannot be included with the set of headers we + // want to use here for testing. It's originally defined in asm/termbits.h, which is + // also included by asm/termios.h, but not the standard termios.h. There's no way to + // include both asm/termbits.h and termios.h and there's no way to include both + // asm/termios.h and ioctl.h (+ some other headers) because of redeclared types. + "CMSPAR" if mips && linux && !musl => true, + + // On mips Linux targets, MADV_SOFT_OFFLINE is currently missing, though it's been added but CI has too old + // of a Linux version. Since it exists on all other Linux targets, just ignore this for now and remove once + // it's been fixed in CI. + "MADV_SOFT_OFFLINE" if mips && linux => true, + + // These constants are tested in a separate test program generated below because there + // are header conflicts if we try to include the headers that define them here. + "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => true, + "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => true, + _ => false, } }); @@ -418,7 +488,8 @@ fn main() { "execv" | // crazy stuff with const/mut "execve" | "execvp" | - "execvpe" => true, + "execvpe" | + "fexecve" => true, "getrlimit" | "getrlimit64" | // non-int in 1st arg "setrlimit" | "setrlimit64" | // non-int in 1st arg @@ -504,7 +575,7 @@ fn main() { "backtrace" | "sysinfo" | "newlocale" | "duplocale" | "freelocale" | "uselocale" | "nl_langinfo_l" | "wcslen" | "wcstombs" if uclibc => true, - + // Apparently res_init exists on Android, but isn't defined in a header: // https://mail.gnome.org/archives/commits-list/2013-May/msg01329.html "res_init" if android => true, @@ -515,6 +586,19 @@ fn main() { // https://github.com/rust-lang/libc/pull/585#discussion_r114561460 "res_init" if apple => true, + // On Mac we don't use the default `close()`, instead using their $NOCANCEL variants. + "close" if apple => true, + + // Definition of those functions as changed since unified headers from NDK r14b + // These changes imply some API breaking changes but are still ABI compatible. + // We can wait for the next major release to be compliant with the new API. + // FIXME: unskip these for next major release + "strerror_r" | "madvise" | "msync" | "mprotect" | "recvfrom" | "getpriority" | + "setpriority" | "personality" if android => true, + // In Android 64 bits, these functions have been fixed since unified headers. + // Ignore these until next major version. + "bind" | "writev" | "readv" | "sendmsg" | "recvmsg" if android && (aarch64 || x86_64) => true, + _ => false, } }); @@ -540,7 +624,11 @@ fn main() { // aio_buf is "volatile void*" and Rust doesn't understand volatile (struct_ == "aiocb" && field == "aio_buf") || // stack_t.ss_sp's type changed from FreeBSD 10 to 11 in svn r294930 - (freebsd && struct_ == "stack_t" && field == "ss_sp") + (freebsd && struct_ == "stack_t" && field == "ss_sp") || + // type siginfo_t.si_addr changed from OpenBSD 6.0 to 6.1 + (openbsd && struct_ == "siginfo_t" && field == "si_addr") || + // this one is an anonymous union + (linux && struct_ == "ff_effect" && field == "u") }); cfg.skip_field(move |struct_, field| { @@ -563,9 +651,31 @@ fn main() { } }); - if env::var("SKIP_COMPILE").is_ok() { - cfg.generate_files("../src/lib.rs", "all.rs"); + cfg.generate("../src/lib.rs", "main.rs"); + + // On Linux or Android also generate another script for testing linux/fcntl declarations. + // These cannot be tested normally because including both `linux/fcntl.h` and `fcntl.h` + // fails on a lot of platforms. + let mut cfg = ctest::TestGenerator::new(); + cfg.skip_type(|_| true) + .skip_struct(|_| true) + .skip_fn(|_| true); + if android || linux { + // musl defines these directly in `fcntl.h` + if musl { + cfg.header("fcntl.h"); + } else { + cfg.header("linux/fcntl.h"); + } + cfg.skip_const(move |name| { + match name { + "F_CANCELLK" | "F_ADD_SEALS" | "F_GET_SEALS" => false, + "F_SEAL_SEAL" | "F_SEAL_SHRINK" | "F_SEAL_GROW" | "F_SEAL_WRITE" => false, + _ => true, + } + }); } else { - cfg.generate("../src/lib.rs", "all.rs"); + cfg.skip_const(|_| true); } + cfg.generate("../src/lib.rs", "linux_fcntl.rs"); } diff --git a/libc/libc-test/generate-files/Cargo.toml b/libc/libc-test/generate-files/Cargo.toml deleted file mode 100644 index 8c19856..0000000 --- a/libc/libc-test/generate-files/Cargo.toml +++ /dev/null @@ -1,16 +0,0 @@ -# Cargo.toml which is used to just generate the all.{c,rs} files used to test -# some platforms. These files are then combined with the overlay files commented -# in the above directory as well to assemble a libc-test project which will -# compile/run all tests. - -[package] -name = "generate-files" -version = "0.1.0" -authors = ["Alex Crichton "] - -[[bin]] -name = "generate-files" -path = "../build.rs" - -[dependencies] -ctest = "0.1" diff --git a/libc/libc-test/run-generated-Cargo.toml b/libc/libc-test/run-generated-Cargo.toml deleted file mode 100644 index 64862a5..0000000 --- a/libc/libc-test/run-generated-Cargo.toml +++ /dev/null @@ -1,19 +0,0 @@ -# Note that this Cargo.toml is not used by default, it is only intended to be -# used on the BSDs where it is too expensive to compile syntex_syntax in a QEMU -# emulator without KVM. Scripts will move this file into place on the BSD CI. - -[package] -name = "libc-test" -version = "0.1.0" -authors = ["Alex Crichton "] -build = "build-generated.rs" - -[dependencies] -libc = { path = ".." } - -[[bin]] -name = "libc-test" -path = "src/main-generated.rs" - -[build-dependencies] -gcc = "0.3" diff --git a/libc/libc-test/src/main-generated.rs b/libc/libc-test/src/main-generated.rs deleted file mode 100644 index 608fe4e..0000000 --- a/libc/libc-test/src/main-generated.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Note that this main file is meant to mirror `main.rs` but is only used on the -// BSDs where the generated location of `all.rs` is slightly different - -#![allow(bad_style, improper_ctypes)] -extern crate libc; - -use libc::*; - -include!("../all.rs"); diff --git a/libc/libc-test/src/main.rs b/libc/libc-test/src/main.rs deleted file mode 100644 index fff188d..0000000 --- a/libc/libc-test/src/main.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![allow(bad_style, improper_ctypes)] -extern crate libc; - -use libc::*; - -include!(concat!(env!("OUT_DIR"), "/all.rs")); diff --git a/libc/libc-test/test/linux_fcntl.rs b/libc/libc-test/test/linux_fcntl.rs new file mode 100644 index 0000000..4c8ad52 --- /dev/null +++ b/libc/libc-test/test/linux_fcntl.rs @@ -0,0 +1,7 @@ +#![allow(bad_style, improper_ctypes, unused)] + +extern crate libc; + +use libc::*; + +include!(concat!(env!("OUT_DIR"), "/linux_fcntl.rs")); diff --git a/libc/libc-test/test/main.rs b/libc/libc-test/test/main.rs new file mode 100644 index 0000000..3d33610 --- /dev/null +++ b/libc/libc-test/test/main.rs @@ -0,0 +1,6 @@ +#![allow(bad_style, improper_ctypes)] +extern crate libc; + +use libc::*; + +include!(concat!(env!("OUT_DIR"), "/main.rs")); -- cgit v1.2.1