Skip to content

[WIP] Test all targets with Rust nightly, beta, stable, and 1.13.0 #1233

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 72 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
8806c2d
Test all targets with Rust nightly, beta, stable, and 1.13.0
gnzlbg Jan 29, 2019
9ff771f
Use unions and const size_of only if the Rust version supports them
gnzlbg Jan 29, 2019
35dfbae
Handle unions in the s macro
gnzlbg Jan 29, 2019
096d6a8
Fix openbsd build without unions
gnzlbg Jan 29, 2019
c9ed265
Add build-only jobs for targets where libc-test does not run.
gnzlbg Jan 29, 2019
6d839ec
Update style to not use trim_left and trim_right deprecated methods
gnzlbg Jan 29, 2019
95330a0
Remove unnecesary rust version from travis.yml
gnzlbg Jan 29, 2019
4cda895
Print path to cargo in ci/run.sh
gnzlbg Jan 29, 2019
fa014a0
Fix style issues in apple module
gnzlbg Jan 29, 2019
32bafd8
Allow docker containers to use rustup
gnzlbg Jan 29, 2019
fb2ed99
Advertise Rust version support in README
gnzlbg Feb 6, 2019
1fe0482
Update cfg_if macro
gnzlbg Feb 6, 2019
867f87f
Automatically enable packed(N) and align when the Rust version suppor…
gnzlbg Feb 6, 2019
9326333
Put cfg(feature = extra_traits) behind cfg_ifs
gnzlbg Feb 6, 2019
7ab9a80
Introduce Travis-CI stages, check style in a single build job, and fi…
gnzlbg Feb 6, 2019
3990b09
repr(align) enabled/disabled is now automatically tested depending on…
gnzlbg Feb 6, 2019
ca10983
Do not derive extra traits for OpenBSD union mount_info
gnzlbg Feb 6, 2019
b412322
Add Rust 1.25 toolchain; only check that extra_traits builds, fix Ope…
gnzlbg Feb 6, 2019
14d0069
Fix packed(N) detection in build.rs
gnzlbg Feb 6, 2019
6cde517
Test most Rust targets
gnzlbg Feb 6, 2019
74fdc2d
Detect running in docker, add cargo/bin to PATH, allow modifying the …
gnzlbg Feb 6, 2019
1d1b167
Allow deprecated items in libc-test tests
gnzlbg Feb 6, 2019
55a026d
Do not assume libstd is available
gnzlbg Feb 6, 2019
df7cc95
Do not derive traits for packed structs
gnzlbg Feb 6, 2019
155de44
Fix documentation and style builds; import core modules in crate root
gnzlbg Feb 6, 2019
28bd578
Refactor in_addr
gnzlbg Feb 6, 2019
38d4148
Add rustfmt support
gnzlbg Feb 6, 2019
7dc6176
Only run libc-test on nightly
gnzlbg Feb 6, 2019
221cf7e
Pass NO_STD to docker, simplify travis script
gnzlbg Feb 6, 2019
3f140ce
Fix aarch64-fuchsia build
gnzlbg Feb 6, 2019
c28e45c
Use the proper rustc path when building android runtest
gnzlbg Feb 6, 2019
b52f3c2
Very verbose builds
gnzlbg Feb 6, 2019
af85110
Add script to test all builds and build jobs specific to that
gnzlbg Feb 6, 2019
e695917
fixup
gnzlbg Feb 6, 2019
db270ec
Reorganize Travis-CI stages
gnzlbg Feb 6, 2019
b889d3d
Rename Travis-CI stages
gnzlbg Feb 6, 2019
91856cf
Fix typo in build script
gnzlbg Feb 6, 2019
95f3296
Reorganize stages
gnzlbg Feb 6, 2019
f28f9e6
Reorganize stages
gnzlbg Feb 6, 2019
1948d32
Fix more build issues
gnzlbg Feb 6, 2019
49ba25a
Do not allow unused_macros for the whole crate
gnzlbg Feb 6, 2019
c4e1855
enable more build targets on all build jobs
gnzlbg Feb 6, 2019
170d67d
Enable netbsd build jobs on nightly linux
gnzlbg Feb 6, 2019
e79c5c3
Do not test i686/x86_64 openbsd
gnzlbg Feb 6, 2019
9f4ade5
Bump minimum required Rust version to Rust 1.25.0
gnzlbg Feb 6, 2019
5b804c6
Re-add support for Rust 1.13.0
gnzlbg Feb 6, 2019
d86ed84
Fix nightly build
gnzlbg Feb 6, 2019
e1e89ff
Use num::Float in s390x
gnzlbg Feb 6, 2019
a23301b
Fix align on Rust 1.24
gnzlbg Feb 6, 2019
d54b638
Fix typo
gnzlbg Feb 6, 2019
55749a0
Fix typo
gnzlbg Feb 6, 2019
cfc4412
Fix typo
gnzlbg Feb 6, 2019
4e92848
extra traits should not enable align
gnzlbg Feb 7, 2019
bb00074
Transmute to integer instead of using f64::to_bits
gnzlbg Feb 7, 2019
a956165
Style
gnzlbg Feb 7, 2019
a4898c6
Fix uses of const size_of in freebsd
gnzlbg Feb 7, 2019
0f7b6a8
Workaround private root module use in Rust 1.13
gnzlbg Feb 7, 2019
2ba155d
Fix attributes on struct patterns
gnzlbg Feb 7, 2019
3b86817
Fix all uses of const size_of
gnzlbg Feb 7, 2019
60050ea
Expand align types using a macro
gnzlbg Feb 7, 2019
fad7e0c
don't test armv7-unknown-linux-musleabihf in old Rust versions
gnzlbg Feb 7, 2019
756701b
don't test x86_64-sun-solaris on old Rust versions
gnzlbg Feb 7, 2019
70a0a7a
Fix typos in build.sh
gnzlbg Feb 7, 2019
4a6a90b
don't test sparc64-unknown-linux-gnu on old Rust versions
gnzlbg Feb 7, 2019
891ce1a
don't test sparcv9-sun-solaris on old Rust versions
gnzlbg Feb 7, 2019
a98fdcb
don't test x86_64-linux-android on old Rust versions
gnzlbg Feb 7, 2019
dc632af
Fix bug in build script
gnzlbg Feb 7, 2019
92cc83d
test more platforms
gnzlbg Feb 7, 2019
2d68674
test more platforms
gnzlbg Feb 7, 2019
b62033c
Refactor build script
gnzlbg Feb 7, 2019
f3d799b
fixup
gnzlbg Feb 7, 2019
9f577e1
fixup
gnzlbg Feb 7, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
224 changes: 152 additions & 72 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,108 +1,188 @@
language: rust
rust: stable
rust: nightly
sudo: required
dist: xenial
services: docker

stages:
- tools-and-build-and-tier1
- tier2

matrix:
include:
# 1.13.0 compat
- env: TARGET=x86_64-unknown-linux-gnu
rust: 1.13.0
script: rm -f Cargo.lock && cargo build
install: true

# build documentation
- env: TARGET=x86_64-unknown-linux-gnu
rust: nightly
# TOOLS
- name: "Documentation"
env: TARGET=x86_64-unknown-linux-gnu
script: sh ci/dox.sh
install: true

# stable compat
- env: TARGET=x86_64-unknown-linux-gnu
stage: tools-and-build-and-tier1
- name: "Shellcheck"
install: true
- env: TARGET=i686-unknown-linux-gnu
- os: osx
env: TARGET=x86_64-apple-darwin
script:
- shellcheck --version
- shellcheck ci/*.sh
stage: tools-and-build-and-tier1
- name: "Style"
install: rustup component add rustfmt-preview
script:
- rustc ci/style.rs && ./style src
- cargo fmt --all -- --check
stage: tools-and-build-and-tier1

# BUILD stable, beta, nightly
- name: "Build Stable Rust"
script: sh ci/build.sh
stage: tools-and-build-and-tier1
rust: stable
- name: "Build Beta Rust"
script: sh ci/build.sh
stage: tools-and-build-and-tier1
rust: beta
- name: "Build Nightly Rust"
script: sh ci/build.sh
stage: tools-and-build-and-tier1
rust: nightly
- name: "Build Stable Rust"
script: sh ci/build.sh
stage: tools-and-build-and-tier1
rust: stable
os: osx
osx_image: xcode10
install: true
- os: osx
env: TARGET=i686-apple-darwin
- name: "Build Beta Rust"
script: sh ci/build.sh
stage: tools-and-build-and-tier1
rust: beta
os: osx
osx_image: xcode10
- env: TARGET=arm-linux-androideabi
- name: "Build Nightly Rust"
script: sh ci/build.sh
stage: tools-and-build-and-tier1
rust: nightly
os: osx
osx_image: xcode10
- name: "Build Stable Rust 1.13.0"
script: sh ci/build.sh
stage: tools-and-build-and-tier1
rust: 1.13.0
- name: "Build Stable Rust 1.19.0"
script: sh ci/build.sh
stage: tools-and-build-and-tier1
rust: 1.19.0
- name: "Build Stable Rust 1.24.0"
script: sh ci/build.sh
stage: tools-and-build-and-tier1
rust: 1.24.0
- name: "Build Stable Rust 1.25.0"
script: sh ci/build.sh
stage: tools-and-build-and-tier1
rust: 1.25.0
- name: "Build Stable Rust 1.30.0"
script: sh ci/build.sh
stage: tools-and-build-and-tier1
rust: 1.30.0
- name: "Build Stable Rust 1.13.0"
script: sh ci/build.sh
stage: tools-and-build-and-tier1
rust: 1.13.0
os: osx
osx_image: xcode10
- name: "Build Stable Rust 1.19.0"
script: sh ci/build.sh
stage: tools-and-build-and-tier1
rust: 1.19.0
os: osx
osx_image: xcode10
- name: "Build Stable Rust 1.24.0"
script: sh ci/build.sh
stage: tools-and-build-and-tier1
rust: 1.24.0
os: osx
osx_image: xcode10
- name: "Build Stable Rust 1.25.0"
script: sh ci/build.sh
stage: tools-and-build-and-tier1
rust: 1.25.0
os: osx
osx_image: xcode10
- name: "Build Stable Rust 1.30.0"
script: sh ci/build.sh
stage: tools-and-build-and-tier1
rust: 1.30.0
os: osx
osx_image: xcode10
- env: TARGET=i686-apple-darwin
os: osx
osx_image: xcode10
stage: tools-and-build-and-tier1
- env: TARGET=i686-unknown-linux-gnu
stage: tools-and-build-and-tier1
- env: TARGET=x86_64-apple-darwin
os: osx
osx_image: xcode10
stage: tools-and-build-and-tier1
- env: TARGET=x86_64-unknown-linux-gnu
stage: tools-and-build-and-tier1

# Tier 2 targets
- env: TARGET=aarch64-linux-android
# FIXME(#826) should reenable
#- env: TARGET=i686-linux-android
- env: TARGET=x86_64-linux-android
- env: TARGET=x86_64-unknown-linux-musl
- env: TARGET=i686-unknown-linux-musl
- env: TARGET=arm-unknown-linux-gnueabihf
- env: TARGET=arm-unknown-linux-musleabihf
stage: tier2
- env: TARGET=aarch64-unknown-linux-gnu
stage: tier2
- env: TARGET=aarch64-unknown-linux-musl
- env: TARGET=powerpc-unknown-linux-gnu
- env: TARGET=powerpc64-unknown-linux-gnu
- env: TARGET=powerpc64le-unknown-linux-gnu
stage: tier2
- env: TARGET=arm-linux-androideabi
stage: tier2
- env: TARGET=arm-unknown-linux-gnueabihf
stage: tier2
- env: TARGET=arm-unknown-linux-musleabihf
stage: tier2
- env: TARGET=asmjs-unknown-emscripten
stage: tier2
- env: TARGET=i686-unknown-linux-musl
stage: tier2
- env: TARGET=mips-unknown-linux-gnu
stage: tier2
- env: TARGET=mips-unknown-linux-musl
- env: TARGET=mipsel-unknown-linux-musl
stage: tier2
- env: TARGET=mips64-unknown-linux-gnuabi64
stage: tier2
- env: TARGET=mips64el-unknown-linux-gnuabi64
- env: TARGET=mips-unknown-linux-gnu
stage: tier2
- env: TARGET=mipsel-unknown-linux-musl
stage: tier2
- env: TARGET=powerpc-unknown-linux-gnu
stage: tier2
- env: TARGET=powerpc64-unknown-linux-gnu
stage: tier2
- env: TARGET=powerpc64le-unknown-linux-gnu
stage: tier2
- env: TARGET=s390x-unknown-linux-gnu
stage: tier2
- env: TARGET=sparc64-unknown-linux-gnu
- env: TARGET=asmjs-unknown-emscripten
stage: tier2
- env: TARGET=wasm32-unknown-emscripten

# beta
- env: TARGET=x86_64-unknown-linux-gnu
rust: beta
install: true
- os: osx
env: TARGET=x86_64-apple-darwin
osx_image: xcode10
rust: beta
install: true

# nightly
- env: TARGET=x86_64-unknown-linux-gnu
rust: nightly
install: true
- os: osx
env: TARGET=x86_64-apple-darwin
osx_image: xcode10
rust: nightly
install: true
# not available on stable
# without --release the build fails
# see https://github.com/rust-lang/rust/issues/45417
stage: tier2
- env: TARGET=x86_64-linux-android
stage: tier2
- env: TARGET=x86_64-unknown-linux-gnux32 OPT="--release"
rust: nightly

- env: TARGET=wasm32-unknown-unknown
install: rustup target add $TARGET
script: cargo build --no-default-features --target $TARGET --release

- name: "Shellcheck"
install: true
script:
- shellcheck --version
- shellcheck ci/*.sh
stage: tier2
- env: TARGET=x86_64-unknown-linux-musl
stage: tier2

allow_failures:
# FIXME: https://github.com/rust-lang/libc/issues/1226
- env: TARGET=asmjs-unknown-emscripten
- env: TARGET=wasm32-unknown-emscripten

install: rustup target add $TARGET
install: rustup target add $TARGET || true

script:
- cargo generate-lockfile --manifest-path libc-test/Cargo.toml
- if [[ $TRAVIS_OS_NAME = "linux" ]]; then
- if [[ $TRAVIS_OS_NAME = "linux" ]] && [[ $BUILD_ONLY != "1" ]]; then
sh ci/run-docker.sh $TARGET;
else
export CARGO_TARGET_DIR=`pwd`/target;
sh ci/run.sh $TARGET;
fi
- rustc ci/style.rs && ./style src

env:
global:
secure: "e2/3QjgRN9atOuSHp22TrYG7QVKcYUWY48Hi9b60w+r1+BhPkTseIJLte7WefRhdXtqpjjUJTooKDhnurFOeHaCT+nmBgiv+FPU893sBl4bhesY4m0vgUJVbNZcs6lTImYekWVb+aqjGdgV/XAgCw7c3kPmrZV0MzGDWL64Xaps="
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ default = ["use_std"]
use_std = []
align = []
rustc-dep-of-std = ['align', 'rustc-std-workspace-core']
extra_traits = ["align"]
extra_traits = []

[workspace]
members = ["libc-test"]
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,19 @@ Raw FFI bindings to platform libraries like `libc`.
[![Build Status](https://api.cirrus-ci.com/github/rust-lang/libc.svg)](https://cirrus-ci.com/github/rust-lang/libc)
[![Latest version](https://img.shields.io/crates/v/libc.svg)](https://crates.io/crates/libc)
[![Documentation](https://docs.rs/libc/badge.svg)](https://docs.rs/libc)
![License](https://img.shields.io/crates/l/libc.svg)
![License](https://img.shields.io/crates/l/libc.svg**

**NOTE:** The minimum supported Rust version is **Rust 1.13.0** . APIs requiring
newer Rust features are only available on newer Rust versions:

| Feature | Version |
|-------------------------|---------|
| `union` | 1.19.0 |
| `const mem::size_of` | 1.24.0 |
| `repr(align)` | 1.25.0 |
| `core::ffi::c_void` | 1.30.0 |

To use `libc` at its fullest, Rust 1.30.0 is required.

## Usage

Expand Down
42 changes: 36 additions & 6 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,42 @@ use std::process::Command;
use std::str;

fn main() {
/*
* If `core::ffi::c_void` exists, libc can just re-export it. Otherwise, it
* must define an incompatible type to retain backwards-compatibility.
*/
if rustc_minor_version().expect("Failed to get rustc version") >= 30 {
println!("cargo:rustc-cfg=core_cvoid");
let rustc_minor_ver =
rustc_minor_version().expect("Failed to get rustc version");
let rustc_dep_of_std =
std::env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
let align_cargo_feature = std::env::var("CARGO_FEATURE_ALIGN").is_ok();

// Rust >= 1.15 supports private module use:
if rustc_minor_ver >= 15 || rustc_dep_of_std {
println!("cargo:rustc-cfg=libc_priv_mod_use");
}

// Rust >= 1.19 supports unions:
if rustc_minor_ver >= 19 || rustc_dep_of_std {
println!("cargo:rustc-cfg=libc_union");
}

// Rust >= 1.24 supports const mem::size_of:
if rustc_minor_ver >= 24 || rustc_dep_of_std {
println!("cargo:rustc-cfg=libc_const_size_of");
}

// Rust >= 1.25 supports repr(align):
if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature {
println!("cargo:rustc-cfg=libc_align");
}

// Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it.
// Otherwise, it defines an incompatible type to retaining
// backwards-compatibility.
if rustc_minor_ver >= 30 || rustc_dep_of_std {
println!("cargo:rustc-cfg=libc_core_cvoid");
}

// Rust >= 1.33 supports repr(packed(N))
if rustc_minor_ver >= 33 || rustc_dep_of_std {
println!("cargo:rustc-cfg=libc_packedN");
}
}

Expand Down
Loading