Skip to content

Commit

Permalink
Auto merge of rust-lang#1247 - gnzlbg:build_all_platforms, r=gnzlbg
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bors committed Feb 8, 2019
2 parents a2bf9f1 + 5c796c5 commit ff97bdb
Show file tree
Hide file tree
Showing 87 changed files with 3,680 additions and 2,673 deletions.
226 changes: 151 additions & 75 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,112 +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: "Style"
install: rustup component add rustfmt-preview
script:
- rustc ci/style.rs && ./style src
- cargo fmt --all -- --check
- 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

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

0 comments on commit ff97bdb

Please sign in to comment.