Skip to content

Commit 37f8f8d

Browse files
committed
Auto merge of #1467 - gnzlbg:fix_freebsd, r=gnzlbg
Fix FreeBSD #1440 broke FreeBSD by changing `libc` FreeBSD targets to require a `cfg(freebsdXX)` to be defined, but not updating `build.rs` to define `freebsd11` when `LIBC_CI` is not available. Since `LIBC_CI` is always defined on CI, this issue went undetected. This PR fixes that issue in the `build.rs` and introduces a build task that tests FreeBSD without `LIBC_CI` on FreeBSD11, although I'm not sure this would have caught the issue in #1466 . Closes #1466 .
2 parents d7907c0 + f081694 commit 37f8f8d

File tree

8 files changed

+26
-19
lines changed

8 files changed

+26
-19
lines changed

.cirrus.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ task:
1010
- rustup default stable
1111
test_script:
1212
- . $HOME/.cargo/env
13+
- LIBC_CI=1 sh ci/run.sh x86_64-unknown-freebsd
1314
- sh ci/run.sh x86_64-unknown-freebsd
1415

1516
task:
@@ -24,4 +25,5 @@ task:
2425
- rustup default nightly
2526
test_script:
2627
- . $HOME/.cargo/env
28+
- LIBC_CI=1 sh ci/run.sh x86_64-unknown-freebsd
2729
- sh ci/run.sh x86_64-unknown-freebsd

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "libc"
3-
version = "0.2.61"
3+
version = "0.2.62"
44
authors = ["The Rust Project Developers"]
55
license = "MIT OR Apache-2.0"
66
readme = "README.md"

build.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ fn main() {
77
rustc_minor_version().expect("Failed to get rustc version");
88
let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok();
99
let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok();
10+
#[allow(unused)]
11+
let libc_ci = env::var("LIBC_CI").is_ok();
1012

1113
if env::var("CARGO_FEATURE_USE_STD").is_ok() {
1214
println!(
@@ -15,16 +17,15 @@ fn main() {
1517
);
1618
}
1719

18-
if env::var("LIBC_CI").is_ok() {
19-
if let Some(11) = which_freebsd() {
20-
println!("cargo:rustc-cfg=freebsd11");
21-
}
22-
if let Some(12) = which_freebsd() {
23-
println!("cargo:rustc-cfg=freebsd12");
24-
}
25-
if let Some(13) = which_freebsd() {
26-
println!("cargo:rustc-cfg=freebsd13");
27-
}
20+
// The ABI of libc is backward compatible with FreeBSD 11.
21+
//
22+
// On CI, we detect the actual FreeBSD version and match its ABI exactly,
23+
// running tests to ensure that the ABI is correct.
24+
match which_freebsd() {
25+
Some(11) if libc_ci => println!("cargo:rustc-cfg=freebsd11"),
26+
Some(12) if libc_ci => println!("cargo:rustc-cfg=freebsd12"),
27+
Some(13) if libc_ci => println!("cargo:rustc-cfg=freebsd13"),
28+
Some(_) | None => println!("cargo:rustc-cfg=freebsd11"),
2829
}
2930

3031
// Rust >= 1.15 supports private module use:

ci/azure.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
vmImage: ubuntu-16.04
1616
steps:
1717
- template: azure-install-rust.yml
18-
- bash: sh ./ci/run-docker.sh $TARGET
18+
- bash: LIBC_CI=1 sh ./ci/run-docker.sh $TARGET
1919
displayName: Execute run-docker.sh
2020
strategy:
2121
matrix:
@@ -30,7 +30,7 @@ jobs:
3030
vmImage: ubuntu-16.04
3131
steps:
3232
- template: azure-install-rust.yml
33-
- bash: sh ./ci/run-docker.sh $TARGET
33+
- bash: LIBC_CI=1 sh ./ci/run-docker.sh $TARGET
3434
displayName: Execute run-docker.sh
3535
strategy:
3636
matrix:
@@ -88,7 +88,7 @@ jobs:
8888
vmImage: macos-10.14
8989
steps:
9090
- template: azure-install-rust.yml
91-
- bash: sh ./ci/run.sh $TARGET
91+
- bash: LIBC_CI=1 sh ./ci/run.sh $TARGET
9292
displayName: Execute run.sh
9393
strategy:
9494
matrix:
@@ -100,7 +100,7 @@ jobs:
100100
vmImage: macos-10.13
101101
steps:
102102
- template: azure-install-rust.yml
103-
- bash: sh ./ci/run.sh $TARGET
103+
- bash: LIBC_CI=1 sh ./ci/run.sh $TARGET
104104
displayName: Execute run.sh
105105
strategy:
106106
matrix:
@@ -112,7 +112,7 @@ jobs:
112112
vmImage: vs2017-win2016
113113
steps:
114114
- template: azure-install-rust.yml
115-
- bash: sh ./ci/run.sh $TARGET
115+
- bash: LIBC_CI=1 sh ./ci/run.sh $TARGET
116116
displayName: Execute run.sh
117117
strategy:
118118
matrix:

ci/dox.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ while read -r target; do
4747

4848
rustup target add "${target}" || true
4949

50+
# Enable extra configuration flags:
51+
export RUSTDOCFLAGS="--cfg freebsd11"
52+
5053
# If cargo doc fails, then try xargo:
5154
if ! cargo doc --target "${target}" \
5255
--no-default-features --features extra_traits ; then

ci/run-docker.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ run() {
2323
docker run \
2424
--rm \
2525
--user "$(id -u)":"$(id -g)" \
26+
--env LIBC_CI \
2627
--env CARGO_HOME=/cargo \
2728
--env CARGO_TARGET_DIR=/checkout/target \
2829
--volume "$(dirname "$(dirname "$(command -v cargo)")")":/cargo \

ci/run.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,6 @@ if [ "$TARGET" = "x86_64-unknown-linux-gnux32" ]; then
8787
opt="--release"
8888
fi
8989

90-
export LIBC_CI=1
91-
9290
cargo test -vv $opt --no-default-features --manifest-path libc-test/Cargo.toml \
9391
--target "${TARGET}"
9492

src/unix/bsd/freebsdlike/freebsd/mod.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1334,9 +1334,11 @@ cfg_if! {
13341334
} else if #[cfg(freebsd13)] {
13351335
mod freebsd12;
13361336
pub use self::freebsd12::*;
1337-
} else {
1337+
} else if #[cfg(freebsd11)] {
13381338
mod freebsd11;
13391339
pub use self::freebsd11::*;
1340+
} else {
1341+
// Unknown freebsd version
13401342
}
13411343
}
13421344

0 commit comments

Comments
 (0)