Commit graph

2598 commits

Author SHA1 Message Date
gnzlbg d42ef14eba Retry rustup target add 3 times 2019-02-09 17:54:52 +01:00
gnzlbg a7674aa428 Do not allow rustup to fail 2019-02-09 13:59:29 +01:00
bors ed160db4b3 Auto merge of #1249 - arnavb:patch-1, r=gnzlbg
Fix license badge
2019-02-09 08:23:45 +00:00
Arnav Borborah 152fd7e6d2
Fix license badge 2019-02-08 20:22:24 -05:00
bors ff97bdb074 Auto merge of #1247 - gnzlbg:build_all_platforms, r=gnzlbg
Build all platforms

cc @alexcrichton this needs a more thorough review. It turns out libc failed to build on a lot of older Rust versions for various reasons and platforms, so it took a while to fix the build on all of them.
2019-02-08 17:45:38 +00:00
gnzlbg 5c796c5897 Align Rust-version support table of the README 2019-02-07 20:06:50 +01:00
gnzlbg ca12725dbf Document platform support in the README 2019-02-07 13:44:32 +01:00
gnzlbg a17a91cdbf Fix build on all platforms
This PR fixes the build on all platforms and all Rust version down to the
minimum Rust version supported by libc: Rust 1.13.0.

The `build.rs` is extended with logic to detect the newer Rust features used by
`libc` since Rust 1.13.0:

* Rust 1.19.0: `untagged_unions`. APIs using untagged unions are gated on
  `cfg(libc_unions)` and not available on older Rust versions.

* Rust 1.25.0: `repr(align)`. Because `repr(align)` cannot be parsed by older
  Rust versions, all uses of `repr(align)` are split into `align.rs` and
  `no_align.rs` modules, which are gated on the `cfg(libc_align)` at the top
  level. These modules sometimes contain macros that are expanded at the top
  level to avoid privacy issues (`pub(crate)` is not available in older Rust
  versions). Closes #1242 .

* Rust : `const` `mem::size_of`. These uses are worked around with hardcoded
  constants on older Rust versions.

Also, `repr(packed)` structs cannot automatically `derive()` some traits like
`Debug`. These have been moved into `s_no_extra_traits!` and the lint of missing
`Debug` implementations on public items is silenced for these. We can manually
implement the `extra_traits` for these in a follow up PR. This is tracked
in #1243. Also, `extra_traits` does not enable `align` manually anymore.

Since `f64::to_bits` is not available in older Rust versions, its usage
has been replaced with a `transmute` to an `u64` which is what that method
does under the hood.

Closes #1232 .
2019-02-07 13:44:32 +01:00
gnzlbg 8f1acf4643 Build all platforms in CI
This commit adds a `ci/build.sh` script that checks that libc builds correctly
for some common configurations (`--no-default-features`, `default`,
`extra_traits`) on most targets supported by Rust since Rust 1.13.0 (the oldest
Rust version that libc supports).

The build matrix is refactored into two stages.

The first stage is called `tools-and-build-and-tier1` and it aims to discover
issues quickly by running the documentation and linter builds, as well as
checking that the library builds correctly on all targets in all supported
channels and "problematic" Rust versions; Rust versions adding major new
features like `repr(align)`, `union`, etc. This first stage also runs
libc-test for the tier-1 targets on linux and osx. These builds finish
quickly because no emulation is necessary.

The second stage is called `tier2` and it runs libc-test for all other targets
for which we are currently able to do so.

Closes #1229 .
2019-02-07 13:44:32 +01:00
bors a2bf9f1d92 Auto merge of #1246 - gnzlbg:rustfmt_style, r=gnzlbg
Check style using rustfmt and reformat

A couple of recent PRs attempt to reformat the library using rustfmt and run into issues against libc's style checker because rustfmt default settings differ.

This PR uses the rustfmt-preview from nightly to check that the library is appropriately formatted, adding a style as similar to libc's style as possible, so that both style checkers work properly simultaneously.
2019-02-07 12:08:51 +00:00
gnzlbg 0a5484ea72 Check style using rustfmt and reformat 2019-02-07 11:13:38 +01:00
bors f9b96ee6a1 Auto merge of #1235 - asomers:cmsg_osx, r=gnzlbg
Fix cmsg(3) bugs for musl and OSX

This PR fixes bugs in the cmsg(3) family of functions for Linux/musl and OSX, introduced by PR #1098 and PR #1212 .  It also adds an integration test which hopefully will validate these functions on every platform.
2019-02-05 17:19:39 +00:00
Alan Somers 38cf5b15c6 Add an integration test for the cmsg(3) functions.
Since these are defined in C as macros, they must be reimplemented in
libc as Rust functions.  They're hard to get exactly right, and they
vary from platform to platform.  The test builds custom C code that uses
the real macros, and compares its output to the Rust versions' output
for various inputs.

Skip the CMSG_NXTHDR test on sparc64 linux because it hits a Bus Error.

Issue #1239

Skip the entire cmsg test program on s390x because it dumps core
seemingly before the kernel finishes booting.

Issue #1240
2019-02-05 08:26:17 -07:00
Alan Somers eddc8d342b Specialize CMSG_NXTHDR for Android and Emscripten 2019-02-05 08:26:14 -07:00
Alan Somers 4300666bf3 Fix Linux's CMSG_NXTHDR and CMSG_SPACE definitions.
This is an error from PR #1098.  The wrong definitions coincidentally
work on Linux/glibc, but fail on Linux/musl.
2019-02-05 08:26:14 -07:00
Alan Somers 73df81fcec Fix CMSG_NXTHDR for OSX.
This was an oversight from PR #1212.  It's been revealed by the new cmsg
test.
2019-02-05 08:24:59 -07:00
bors be1a8dedf0 Auto merge of #1234 - gnzlbg:android_runtest, r=gnzlbg
Update runtest-android

Keep the implementation in sync with packed_simd and stdsimd.
2019-02-05 08:36:09 +00:00
bors 942f6ae707 Auto merge of #1217 - Susurrus:rfc_2235, r=gnzlbg
RFC 2235 - Implement PartialEq,Eq,Hash,Debug for all types

First pass at implementing [RFC2235](https://github.com/rust-lang/rfcs/blob/master/text/2235-libc-struct-traits.md). I just started with `PartialEq`/`Eq` and tested locally on my x64 Linux system. Definitely going to run into other types for other platforms that need this treatment, but thought I'd start small.

Open question is whether this should also rely on the `align` feature, which should improve which types can be auto-derived versus manually implemented (as it removed a lot of odd-sized padding arrays). My first pass here doesn't do that, but I might test it out to see if it does simplify quite a few structs. I think it might also be nice to have as it makes it easier for contributors to add new structs.

Part of rust-lang/rust#57715
2019-02-05 07:38:45 +00:00
bors 1f63b26009 Auto merge of #1230 - vdagonneau:master, r=gnzlbg
Added inotify bindings.

Hi, I'd like to add inotify bindings. This is a first throw at it. Can you guide me through the process of merging it ?
2019-02-04 13:31:03 +00:00
bors f8a2c53646 Auto merge of #1221 - MikaelUrankar:powerpc64-unknown-freebsd, r=gnzlbg
Add powerpc64-unknown-freebsd

FreeBSD review: https://reviews.freebsd.org/D18367
2019-02-04 13:02:43 +00:00
Vincent Dagonneau dfb7c0caba Added the proper libc header to libc-test; Removed some defines as they seem to be too new. 2019-02-04 09:11:21 +01:00
Bryant Mairs e33f7609bd Ignore the style executable used for testing
This is used for running style checks on the libc codebase but shouldn't
be committed, so adding it to the .gitignore file.
2019-02-02 16:32:00 -08:00
Bryant Mairs f3684584c9 Check for Copy impls for all types 2019-02-02 16:32:00 -08:00
Bryant Mairs fa9cb78b4a Check for Debug impls for all types
This was not compile-tested on all platforms, but instead all `pub enum`
types had a `Debug` impl derived for them.
2019-02-02 16:32:00 -08:00
Bryant Mairs cd1e16d1af Implement Hash for all types 2019-02-02 16:32:00 -08:00
Bryant Mairs 79ae1217c2 Implement Debug for all types 2019-02-02 13:06:58 -08:00
Bryant Mairs 868a85d05d Implement PartialEq,Eq for all types 2019-02-02 13:06:58 -08:00
MikaelUrankar 69c9c541f7 char is unsigned on FreeBSD aarch64 and powerpc64 2019-02-02 19:38:46 +01:00
Your Name 6c1e2dec8f Add powerpc64-unknown-freebsd 2019-02-02 19:38:46 +01:00
Alex Crichton 118c7aeb19
Merge pull request #1236 from MikaelUrankar/freebsd_arm
Add FreeBSD armv6 and armv7 targets
2019-02-02 11:51:23 -06:00
MikaelUrankar e628de2d7d Add armv6 and armv7 FreeBSD targets 2019-02-02 16:19:08 +01:00
gnzlbg 6732bf1d41 Update runtest-android 2019-01-30 15:35:08 +01:00
Vincent Dagonneau da27966859 Fixed typo; Added inotify headers to the libc-test. 2019-01-28 20:56:15 +01:00
Vincent Dagonneau eb3e48c62f Added inotify headers to the libc-test. 2019-01-28 19:41:29 +01:00
Vincent Dagonneau 01752b3cb4 Added inotify bindings. 2019-01-26 10:29:53 +01:00
Bryant Mairs 51a0587b53 Remove Cargo.lock
This was an artifact from when a git dependency on ctest was used. This
is no longer the case, so removing it to simplify future PRs.
2019-01-23 08:42:58 -08:00
bors 42cd3ba272 Auto merge of #1228 - gnzlbg:release, r=gnzlbg
Bump to 0.2.48

Bumps libc version to 0.2.48. This release contains the breaking changes performed in #1222 .
2019-01-23 13:32:05 +00:00
gnzlbg 9148ae9023 Bump to 0.2.48 2019-01-23 14:14:01 +01:00
bors e979ffff51 Auto merge of #1222 - MikaelUrankar:stack_t_bsd, r=gnzlbg
fix stack_t on FreeBSD

FreeBSD 10.x is EOL, in FreeBSD 11 and later, ss_sp is actually a void* [1]
dragonflybsd still uses c_char [2]

[1] https://svnweb.freebsd.org/base/releng/11.2/sys/sys/signal.h?revision=334459&view=markup#l438
[2] https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/sys/signal.h#L339

should be committed with https://github.com/rust-lang/rust/pull/57810
2019-01-23 11:08:59 +00:00
Your Name 5e187562ee FreeBSD 10.x is EOL, in FreeBSD 11 and later, ss_sp is actually a void* [1]
dragonflybsd still uses c_char [2]

[1] https://svnweb.freebsd.org/base/releng/11.2/sys/sys/signal.h?revision=334459&view=markup#l438
[2] https://github.com/DragonFlyBSD/DragonFlyBSD/blob/master/sys/sys/signal.h#L339
2019-01-22 17:16:26 +01:00
bors fb2b3dac03 Auto merge of #1224 - gnzlbg:fix_android, r=gnzlbg
Re-enable android build jobs

This performs a `yes | ./sdk/tools/bin/sdkmanager --licenses` - the sole purpose of the `--licenses` flag is to allow the user to accept all licenses a priori, so that all other commands don't show any licenses.

For some reason, after all licenses have been accepted, the install step says that some licenses are still not accepted... so we need to accept those too... Why? I have no idea, and accepting licenses while installing still appears to make things hang a little, but it only does so for one non-accepted license, instead of for 5-6 like before, so now things do work.
2019-01-21 21:05:07 +00:00
gnzlbg 4f9cc1a208 Fix indentation of allow_failures 2019-01-21 22:04:14 +01:00
gnzlbg b71ea8ba24 Allow emscripten asmjs and wasm32 targets to fail 2019-01-21 21:23:44 +01:00
gnzlbg 5a7b4e7796 MFD_HUGETLB does not appear to be available on x86_64-android 2019-01-21 20:34:43 +01:00
gnzlbg 45adbf88dd Re-enables android build jobs
Closes #1170 .
2019-01-21 20:34:43 +01:00
bors 70284d78ee Auto merge of #1212 - asomers:cmsg, r=alexcrichton
Fix CMSG_DATA(3) and friends on BSD

PR #1098 added the CMSG_DATA(3) family of functions into libc.  Because
they're defined as macros in C, they had to be rewritten as Rust
functions for libc.  Also, they can't be tested in CI for the same
reason.  But that PR erroneously used the same definitions in BSD as in
Linux.

This commit corrects the definitions for OSX, FreeBSD, DragonflyBSD,
OpenBSD, and NetBSD.  I renamed a few variables and collapsed a few
macros in order to combine the definitions where possible.

Fixes #1210
2019-01-17 16:45:13 +00:00
Alan Somers 8067378d21 Fix CMSG_DATA(3) and friends on BSD
PR #1098 added the CMSG_DATA(3) family of functions into libc.  Because
they're defined as macros in C, they had to be rewritten as Rust
functions for libc.  Also, they can't be tested in CI for the same
reason.  But that PR erroneously used the same definitions in BSD as in
Linux.

This commit corrects the definitions for OSX, FreeBSD, DragonflyBSD,
OpenBSD, and NetBSD.  I renamed a few variables and collapsed a few
macros in order to combine the definitions where possible.

Fixes #1210
2019-01-16 08:32:20 -07:00
bors 6b8ef413a3 Auto merge of #1211 - asomers:netbsd_aio, r=gnzlbg
Fix linking aio_read(3) and friends on NetBSD

The aio functions require librt on NetBSD.
2019-01-15 17:44:10 +00:00
bors ac6e2a79b5 Auto merge of #1201 - thendiscard:master, r=gnzlbg
Remove fexecve from netbsdlike as it's not implemented

Sometimes it causes confusion in downstream users of libc, for example it caused nix-rust/nix to fail to compile on OpenBSD 6.4 (see https://github.com/nix-rust/nix/pull/1000).

OpenBSD doesn't implement fexecve. The only reference of it that I can
find in the OpenBSD source is in the man pages of signal(3) and
sigaction(2) (where it's mentioned that it is not implemented).

OpenBSD official source code link:
https://cvsweb.openbsd.org/src/lib/libc/sys/sigaction.2?rev=1.75&content-type=text/x-cvsweb-markup

OpenBSD Github mirror:
https://github.com/openbsd/src/blob/master/lib/libc/sys/sigaction.2#L619

On NetBSD's unistd.h I see that it is under an ifdef. Calling it returns
78 / ENOSYS / Function not implemented.

NetBSD office source code link:
http://cvsweb.netbsd.org/bsdweb.cgi/src/include/unistd.h?rev=1.151&content-type=text/x-cvsweb-markup&only_with_tag=MAIN

NetBSD Github mirror:
https://github.com/NetBSD/src/blob/trunk/include/unistd.h#L319

Tests on OpenBSD 6.4 after the change:
```bash
user@openbsd64 ~/RUST/libc $ cargo build
   Compiling libc v0.2.46 (/home/user/RUST/libc)
    Finished dev [unoptimized + debuginfo] target(s) in 3.88s

user@openbsd64 ~/RUST/libc $ cargo build --release
   Compiling libc v0.2.46 (/home/user/RUST/libc)
    Finished release [optimized] target(s) in 2.21s

user@openbsd64 ~/RUST/libc/libc-test $ cargo test
   Compiling proc-macro2 v0.4.24
   Compiling unicode-xid v0.1.0
   Compiling semver-parser v0.7.0
   Compiling serde v1.0.84
   Compiling libc v0.2.45
   Compiling num-traits v0.2.6
   Compiling ryu v0.2.7
   Compiling cfg-if v0.1.6
   Compiling itoa v0.4.3
   Compiling term v0.4.6
   Compiling bitflags v0.9.1
   Compiling cc v1.0.28
   Compiling libc v0.2.46 (/home/user/RUST/libc)
   Compiling log v0.4.6
   Compiling semver v0.9.0
   Compiling log v0.3.9
   Compiling rustc_version v0.2.3
   Compiling rand v0.4.3
   Compiling extprim v1.6.0
   Compiling quote v0.6.10
   Compiling syn v0.15.23
   Compiling serde_derive v1.0.84
   Compiling syntex_pos v0.59.1
   Compiling serde_json v1.0.34
   Compiling syntex_errors v0.59.1
   Compiling syntex_syntax v0.59.1
   Compiling ctest v0.2.8
   Compiling libc-test v0.1.0 (/home/user/RUST/libc/libc-test)
    Finished dev [unoptimized + debuginfo] target(s) in 2m 16s
     Running /home/user/RUST/libc/target/debug/deps/linux_fcntl-08861a7cd96d1b94
RUNNING ALL TESTS
PASSED 0 tests
     Running /home/user/RUST/libc/target/debug/deps/main-57e266d38aa58cce
RUNNING ALL TESTS
PASSED 7187 tests
```
I've tried running the tests on a NetBSD 8.0 box unfortunately there `libc-test` fails to compile even before this change.
2019-01-15 11:04:59 +00:00
bors 18b0102b98 Auto merge of #1188 - pusateri:netbsd8, r=gnzlbg
NetBSD 8 adds new address family changing AF_MAX and new ifaddrs flags.

libc-test on NetBSD 8.0  fails without these changes.
ifa_addrflags was added to struct ifaddrs to support AF_CAN.
AF_MAX got bumped up one by AF_CAN.
RT_IFLIST format changed to support ifa_addrflags.
2019-01-15 10:25:04 +00:00