Skip to content

Commit ff97bdb

Browse files
committed
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.
2 parents a2bf9f1 + 5c796c5 commit ff97bdb

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+3680
-2673
lines changed

.travis.yml

+151-75
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,188 @@
11
language: rust
2-
rust: stable
2+
rust: nightly
33
sudo: required
44
dist: xenial
55
services: docker
66

7+
stages:
8+
- tools-and-build-and-tier1
9+
- tier2
10+
711
matrix:
812
include:
9-
# 1.13.0 compat
10-
- env: TARGET=x86_64-unknown-linux-gnu
11-
rust: 1.13.0
12-
script: rm -f Cargo.lock && cargo build
13-
install: true
14-
15-
# build documentation
16-
- env: TARGET=x86_64-unknown-linux-gnu
17-
rust: nightly
13+
# TOOLS
14+
- name: "Documentation"
15+
env: TARGET=x86_64-unknown-linux-gnu
1816
script: sh ci/dox.sh
1917
install: true
20-
21-
# stable compat
22-
- env: TARGET=x86_64-unknown-linux-gnu
18+
stage: tools-and-build-and-tier1
19+
- name: "Shellcheck"
2320
install: true
24-
- env: TARGET=i686-unknown-linux-gnu
25-
- os: osx
26-
env: TARGET=x86_64-apple-darwin
21+
script:
22+
- shellcheck --version
23+
- shellcheck ci/*.sh
24+
stage: tools-and-build-and-tier1
25+
- name: "Style"
26+
install: rustup component add rustfmt-preview
27+
script:
28+
- rustc ci/style.rs && ./style src
29+
- cargo fmt --all -- --check
30+
stage: tools-and-build-and-tier1
31+
32+
# BUILD stable, beta, nightly
33+
- name: "Build Stable Rust"
34+
script: sh ci/build.sh
35+
stage: tools-and-build-and-tier1
36+
rust: stable
37+
- name: "Build Beta Rust"
38+
script: sh ci/build.sh
39+
stage: tools-and-build-and-tier1
40+
rust: beta
41+
- name: "Build Nightly Rust"
42+
script: sh ci/build.sh
43+
stage: tools-and-build-and-tier1
44+
rust: nightly
45+
- name: "Build Stable Rust"
46+
script: sh ci/build.sh
47+
stage: tools-and-build-and-tier1
48+
rust: stable
49+
os: osx
2750
osx_image: xcode10
28-
install: true
29-
- os: osx
30-
env: TARGET=i686-apple-darwin
51+
- name: "Build Beta Rust"
52+
script: sh ci/build.sh
53+
stage: tools-and-build-and-tier1
54+
rust: beta
55+
os: osx
3156
osx_image: xcode10
32-
- env: TARGET=arm-linux-androideabi
57+
- name: "Build Nightly Rust"
58+
script: sh ci/build.sh
59+
stage: tools-and-build-and-tier1
60+
rust: nightly
61+
os: osx
62+
osx_image: xcode10
63+
- name: "Build Stable Rust 1.13.0"
64+
script: sh ci/build.sh
65+
stage: tools-and-build-and-tier1
66+
rust: 1.13.0
67+
- name: "Build Stable Rust 1.19.0"
68+
script: sh ci/build.sh
69+
stage: tools-and-build-and-tier1
70+
rust: 1.19.0
71+
- name: "Build Stable Rust 1.24.0"
72+
script: sh ci/build.sh
73+
stage: tools-and-build-and-tier1
74+
rust: 1.24.0
75+
- name: "Build Stable Rust 1.25.0"
76+
script: sh ci/build.sh
77+
stage: tools-and-build-and-tier1
78+
rust: 1.25.0
79+
- name: "Build Stable Rust 1.30.0"
80+
script: sh ci/build.sh
81+
stage: tools-and-build-and-tier1
82+
rust: 1.30.0
83+
- name: "Build Stable Rust 1.13.0"
84+
script: sh ci/build.sh
85+
stage: tools-and-build-and-tier1
86+
rust: 1.13.0
87+
os: osx
88+
osx_image: xcode10
89+
- name: "Build Stable Rust 1.19.0"
90+
script: sh ci/build.sh
91+
stage: tools-and-build-and-tier1
92+
rust: 1.19.0
93+
os: osx
94+
osx_image: xcode10
95+
- name: "Build Stable Rust 1.24.0"
96+
script: sh ci/build.sh
97+
stage: tools-and-build-and-tier1
98+
rust: 1.24.0
99+
os: osx
100+
osx_image: xcode10
101+
- name: "Build Stable Rust 1.25.0"
102+
script: sh ci/build.sh
103+
stage: tools-and-build-and-tier1
104+
rust: 1.25.0
105+
os: osx
106+
osx_image: xcode10
107+
- name: "Build Stable Rust 1.30.0"
108+
script: sh ci/build.sh
109+
stage: tools-and-build-and-tier1
110+
rust: 1.30.0
111+
os: osx
112+
osx_image: xcode10
113+
- env: TARGET=i686-apple-darwin
114+
os: osx
115+
osx_image: xcode10
116+
stage: tools-and-build-and-tier1
117+
- env: TARGET=i686-unknown-linux-gnu
118+
stage: tools-and-build-and-tier1
119+
- env: TARGET=x86_64-apple-darwin
120+
os: osx
121+
osx_image: xcode10
122+
stage: tools-and-build-and-tier1
123+
- env: TARGET=x86_64-unknown-linux-gnu
124+
stage: tools-and-build-and-tier1
125+
126+
# Tier 2 targets
33127
- env: TARGET=aarch64-linux-android
34-
# FIXME(#826) should reenable
35-
#- env: TARGET=i686-linux-android
36-
- env: TARGET=x86_64-linux-android
37-
- env: TARGET=x86_64-unknown-linux-musl
38-
- env: TARGET=i686-unknown-linux-musl
39-
- env: TARGET=arm-unknown-linux-gnueabihf
40-
- env: TARGET=arm-unknown-linux-musleabihf
128+
stage: tier2
41129
- env: TARGET=aarch64-unknown-linux-gnu
130+
stage: tier2
42131
- env: TARGET=aarch64-unknown-linux-musl
43-
- env: TARGET=powerpc-unknown-linux-gnu
44-
- env: TARGET=powerpc64-unknown-linux-gnu
45-
- env: TARGET=powerpc64le-unknown-linux-gnu
132+
stage: tier2
133+
- env: TARGET=arm-linux-androideabi
134+
stage: tier2
135+
- env: TARGET=arm-unknown-linux-gnueabihf
136+
stage: tier2
137+
- env: TARGET=arm-unknown-linux-musleabihf
138+
stage: tier2
139+
- env: TARGET=asmjs-unknown-emscripten
140+
stage: tier2
141+
- env: TARGET=i686-unknown-linux-musl
142+
stage: tier2
143+
- env: TARGET=mips-unknown-linux-gnu
144+
stage: tier2
46145
- env: TARGET=mips-unknown-linux-musl
47-
- env: TARGET=mipsel-unknown-linux-musl
146+
stage: tier2
48147
- env: TARGET=mips64-unknown-linux-gnuabi64
148+
stage: tier2
49149
- env: TARGET=mips64el-unknown-linux-gnuabi64
50-
- env: TARGET=mips-unknown-linux-gnu
150+
stage: tier2
151+
- env: TARGET=mipsel-unknown-linux-musl
152+
stage: tier2
153+
- env: TARGET=powerpc-unknown-linux-gnu
154+
stage: tier2
155+
- env: TARGET=powerpc64-unknown-linux-gnu
156+
stage: tier2
157+
- env: TARGET=powerpc64le-unknown-linux-gnu
158+
stage: tier2
51159
- env: TARGET=s390x-unknown-linux-gnu
160+
stage: tier2
52161
- env: TARGET=sparc64-unknown-linux-gnu
53-
- env: TARGET=asmjs-unknown-emscripten
162+
stage: tier2
54163
- env: TARGET=wasm32-unknown-emscripten
55-
56-
# beta
57-
- env: TARGET=x86_64-unknown-linux-gnu
58-
rust: beta
59-
install: true
60-
- os: osx
61-
env: TARGET=x86_64-apple-darwin
62-
osx_image: xcode10
63-
rust: beta
64-
install: true
65-
66-
# nightly
67-
- env: TARGET=x86_64-unknown-linux-gnu
68-
rust: nightly
69-
install: true
70-
- os: osx
71-
env: TARGET=x86_64-apple-darwin
72-
osx_image: xcode10
73-
rust: nightly
74-
install: true
75-
# not available on stable
76-
# without --release the build fails
77-
# see https://github.com/rust-lang/rust/issues/45417
164+
stage: tier2
165+
- env: TARGET=x86_64-linux-android
166+
stage: tier2
78167
- env: TARGET=x86_64-unknown-linux-gnux32 OPT="--release"
79-
rust: nightly
80-
81-
- env: TARGET=wasm32-unknown-unknown
82-
install: rustup target add $TARGET
83-
script: cargo build --no-default-features --target $TARGET --release
84-
- name: "Style"
85-
install: rustup component add rustfmt-preview
86-
script:
87-
- rustc ci/style.rs && ./style src
88-
- cargo fmt --all -- --check
89-
- name: "Shellcheck"
90-
install: true
91-
script:
92-
- shellcheck --version
93-
- shellcheck ci/*.sh
168+
stage: tier2
169+
- env: TARGET=x86_64-unknown-linux-musl
170+
stage: tier2
94171

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

100-
install: rustup target add $TARGET
177+
install: rustup target add $TARGET || true
178+
101179
script:
102180
- cargo generate-lockfile --manifest-path libc-test/Cargo.toml
103-
- if [[ $TRAVIS_OS_NAME = "linux" ]]; then
181+
- if [[ $TRAVIS_OS_NAME = "linux" ]] && [[ $BUILD_ONLY != "1" ]]; then
104182
sh ci/run-docker.sh $TARGET;
105183
else
106-
export CARGO_TARGET_DIR=`pwd`/target;
107184
sh ci/run.sh $TARGET;
108185
fi
109-
110186
env:
111187
global:
112188
secure: "e2/3QjgRN9atOuSHp22TrYG7QVKcYUWY48Hi9b60w+r1+BhPkTseIJLte7WefRhdXtqpjjUJTooKDhnurFOeHaCT+nmBgiv+FPU893sBl4bhesY4m0vgUJVbNZcs6lTImYekWVb+aqjGdgV/XAgCw7c3kPmrZV0MzGDWL64Xaps="

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ default = ["use_std"]
2727
use_std = []
2828
align = []
2929
rustc-dep-of-std = ['align', 'rustc-std-workspace-core']
30-
extra_traits = ["align"]
30+
extra_traits = []
3131

3232
[workspace]
3333
members = ["libc-test"]

README.md

+13-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,19 @@ Raw FFI bindings to platform libraries like `libc`.
88
[![Build Status](https://api.cirrus-ci.com/github/rust-lang/libc.svg)](https://cirrus-ci.com/github/rust-lang/libc)
99
[![Latest version](https://img.shields.io/crates/v/libc.svg)](https://crates.io/crates/libc)
1010
[![Documentation](https://docs.rs/libc/badge.svg)](https://docs.rs/libc)
11-
![License](https://img.shields.io/crates/l/libc.svg)
11+
![License](https://img.shields.io/crates/l/libc.svg**
12+
13+
**NOTE:** The minimum supported Rust version is **Rust 1.13.0** . APIs requiring
14+
newer Rust features are only available on newer Rust versions:
15+
16+
| Feature | Version |
17+
|----------------------|---------|
18+
| `union` | 1.19.0 |
19+
| `const mem::size_of` | 1.24.0 |
20+
| `repr(align)` | 1.25.0 |
21+
| `core::ffi::c_void` | 1.30.0 |
22+
23+
To use `libc` at its fullest, Rust 1.30.0 is required.
1224

1325
## Usage
1426

build.rs

+36-6
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,42 @@ use std::process::Command;
33
use std::str;
44

55
fn main() {
6-
/*
7-
* If `core::ffi::c_void` exists, libc can just re-export it. Otherwise, it
8-
* must define an incompatible type to retain backwards-compatibility.
9-
*/
10-
if rustc_minor_version().expect("Failed to get rustc version") >= 30 {
11-
println!("cargo:rustc-cfg=core_cvoid");
6+
let rustc_minor_ver =
7+
rustc_minor_version().expect("Failed to get rustc version");
8+
let rustc_dep_of_std =
9+
std::env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
10+
let align_cargo_feature = std::env::var("CARGO_FEATURE_ALIGN").is_ok();
11+
12+
// Rust >= 1.15 supports private module use:
13+
if rustc_minor_ver >= 15 || rustc_dep_of_std {
14+
println!("cargo:rustc-cfg=libc_priv_mod_use");
15+
}
16+
17+
// Rust >= 1.19 supports unions:
18+
if rustc_minor_ver >= 19 || rustc_dep_of_std {
19+
println!("cargo:rustc-cfg=libc_union");
20+
}
21+
22+
// Rust >= 1.24 supports const mem::size_of:
23+
if rustc_minor_ver >= 24 || rustc_dep_of_std {
24+
println!("cargo:rustc-cfg=libc_const_size_of");
25+
}
26+
27+
// Rust >= 1.25 supports repr(align):
28+
if rustc_minor_ver >= 25 || rustc_dep_of_std || align_cargo_feature {
29+
println!("cargo:rustc-cfg=libc_align");
30+
}
31+
32+
// Rust >= 1.30 supports `core::ffi::c_void`, so libc can just re-export it.
33+
// Otherwise, it defines an incompatible type to retaining
34+
// backwards-compatibility.
35+
if rustc_minor_ver >= 30 || rustc_dep_of_std {
36+
println!("cargo:rustc-cfg=libc_core_cvoid");
37+
}
38+
39+
// Rust >= 1.33 supports repr(packed(N))
40+
if rustc_minor_ver >= 33 || rustc_dep_of_std {
41+
println!("cargo:rustc-cfg=libc_packedN");
1242
}
1343
}
1444

0 commit comments

Comments
 (0)