From 4f1966f5c54220d2f83bf917e91f54129651f654 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 14 Aug 2019 07:30:15 +0200 Subject: [PATCH 1/7] Fix FreeBSD build --- build.rs | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/build.rs b/build.rs index f355447a672c6..339eb195569ba 100644 --- a/build.rs +++ b/build.rs @@ -7,6 +7,8 @@ fn main() { rustc_minor_version().expect("Failed to get rustc version"); let rustc_dep_of_std = env::var("CARGO_FEATURE_RUSTC_DEP_OF_STD").is_ok(); let align_cargo_feature = env::var("CARGO_FEATURE_ALIGN").is_ok(); + #[allow(unused)] + let libc_ci = env::var("LIBC_CI").is_ok(); if env::var("CARGO_FEATURE_USE_STD").is_ok() { println!( @@ -15,15 +17,20 @@ fn main() { ); } - if env::var("LIBC_CI").is_ok() { - if let Some(11) = which_freebsd() { - println!("cargo:rustc-cfg=freebsd11"); - } - if let Some(12) = which_freebsd() { - println!("cargo:rustc-cfg=freebsd12"); - } - if let Some(13) = which_freebsd() { - println!("cargo:rustc-cfg=freebsd13"); + // The ABI of libc is backward compatible with FreeBSD 11. + // + // On CI, we detect the actual FreeBSD version and match its ABI exactly, + // running tests to ensure that the ABI is correct. + #[cfg(target_os = "freebsd")] + match which_freebsd() { + Some(11) if libc_ci => println!("cargo:rustc-cfg=freebsd11"), + Some(12) if libc_ci => println!("cargo:rustc-cfg=freebsd12"), + Some(13) if libc_ci => println!("cargo:rustc-cfg=freebsd13"), + Some(_) => println!("cargo:rustc-cfg=freebsd11"), + None => + /* not FreeBSD - nothing to do here */ + { + () } } @@ -87,6 +94,7 @@ fn rustc_minor_version() -> Option { otry!(pieces.next()).parse().ok() } +#[cfg(target_os = "freebsd")] fn which_freebsd() -> Option { let output = std::process::Command::new("freebsd-version").output().ok(); if output.is_none() { From af88cf1f0f6cbcc02495309a8ba757af8b082bbd Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 14 Aug 2019 07:36:41 +0200 Subject: [PATCH 2/7] Add a build task for FreeBSD11 without LIBC_CI --- .cirrus.yml | 19 +++++++++++++++++-- ci/azure.yml | 10 +++++----- ci/run-docker.sh | 1 + ci/run.sh | 2 -- 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index 178f5b24690c5..b3d8dfb26fd79 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,5 +1,5 @@ task: - name: stable x86_64-unknown-freebsd-11 + name: stable x86_64-unknown-freebsd freebsd_instance: image: freebsd-11-3-stable-amd64-v20190801 setup_script: @@ -11,6 +11,21 @@ task: test_script: - . $HOME/.cargo/env - sh ci/run.sh x86_64-unknown-freebsd + + +task: + name: stable x86_64-unknown-freebsd-11 + freebsd_instance: + image: freebsd-11-3-stable-amd64-v20190801 + setup_script: + - pkg install -y curl + - curl https://sh.rustup.rs -sSf --output rustup.sh + - sh rustup.sh -y + - . $HOME/.cargo/env + - rustup default stable + test_script: + - . $HOME/.cargo/env + - LIBC_CI=1 sh ci/run.sh x86_64-unknown-freebsd task: name: nightly x86_64-unknown-freebsd-12 @@ -24,4 +39,4 @@ task: - rustup default nightly test_script: - . $HOME/.cargo/env - - sh ci/run.sh x86_64-unknown-freebsd + - LIBC_CI=1 sh ci/run.sh x86_64-unknown-freebsd diff --git a/ci/azure.yml b/ci/azure.yml index 04d12dae8f316..4526361aefbe6 100644 --- a/ci/azure.yml +++ b/ci/azure.yml @@ -15,7 +15,7 @@ jobs: vmImage: ubuntu-16.04 steps: - template: azure-install-rust.yml - - bash: sh ./ci/run-docker.sh $TARGET + - bash: LIBC_CI=1 sh ./ci/run-docker.sh $TARGET displayName: Execute run-docker.sh strategy: matrix: @@ -30,7 +30,7 @@ jobs: vmImage: ubuntu-16.04 steps: - template: azure-install-rust.yml - - bash: sh ./ci/run-docker.sh $TARGET + - bash: LIBC_CI=1 sh ./ci/run-docker.sh $TARGET displayName: Execute run-docker.sh strategy: matrix: @@ -88,7 +88,7 @@ jobs: vmImage: macos-10.14 steps: - template: azure-install-rust.yml - - bash: sh ./ci/run.sh $TARGET + - bash: LIBC_CI=1 sh ./ci/run.sh $TARGET displayName: Execute run.sh strategy: matrix: @@ -100,7 +100,7 @@ jobs: vmImage: macos-10.13 steps: - template: azure-install-rust.yml - - bash: sh ./ci/run.sh $TARGET + - bash: LIBC_CI=1 sh ./ci/run.sh $TARGET displayName: Execute run.sh strategy: matrix: @@ -112,7 +112,7 @@ jobs: vmImage: vs2017-win2016 steps: - template: azure-install-rust.yml - - bash: sh ./ci/run.sh $TARGET + - bash: LIBC_CI=1 sh ./ci/run.sh $TARGET displayName: Execute run.sh strategy: matrix: diff --git a/ci/run-docker.sh b/ci/run-docker.sh index 5fd00614462dc..3c0736a265f7b 100755 --- a/ci/run-docker.sh +++ b/ci/run-docker.sh @@ -23,6 +23,7 @@ run() { docker run \ --rm \ --user "$(id -u)":"$(id -g)" \ + --env LIBC_CI \ --env CARGO_HOME=/cargo \ --env CARGO_TARGET_DIR=/checkout/target \ --volume "$(dirname "$(dirname "$(command -v cargo)")")":/cargo \ diff --git a/ci/run.sh b/ci/run.sh index 8c56979ed657f..6f2ca11fe4090 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -87,8 +87,6 @@ if [ "$TARGET" = "x86_64-unknown-linux-gnux32" ]; then opt="--release" fi -export LIBC_CI=1 - cargo test -vv $opt --no-default-features --manifest-path libc-test/Cargo.toml \ --target "${TARGET}" From 077f4321b255bf811621a64b6b426a5b8f2ff19a Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 14 Aug 2019 08:17:44 +0200 Subject: [PATCH 3/7] Test ABI without LIBC_CI on all supported FreeBSD versions --- .cirrus.yml | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/.cirrus.yml b/.cirrus.yml index b3d8dfb26fd79..e3f777b52907f 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -1,18 +1,3 @@ -task: - name: stable x86_64-unknown-freebsd - freebsd_instance: - image: freebsd-11-3-stable-amd64-v20190801 - setup_script: - - pkg install -y curl - - curl https://sh.rustup.rs -sSf --output rustup.sh - - sh rustup.sh -y - - . $HOME/.cargo/env - - rustup default stable - test_script: - - . $HOME/.cargo/env - - sh ci/run.sh x86_64-unknown-freebsd - - task: name: stable x86_64-unknown-freebsd-11 freebsd_instance: @@ -26,6 +11,7 @@ task: test_script: - . $HOME/.cargo/env - LIBC_CI=1 sh ci/run.sh x86_64-unknown-freebsd + - sh ci/run.sh x86_64-unknown-freebsd task: name: nightly x86_64-unknown-freebsd-12 @@ -40,3 +26,4 @@ task: test_script: - . $HOME/.cargo/env - LIBC_CI=1 sh ci/run.sh x86_64-unknown-freebsd + - sh ci/run.sh x86_64-unknown-freebsd From 9db561f04efe839ee4a65cb1ab282c0c4e82b352 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 14 Aug 2019 15:22:20 +0200 Subject: [PATCH 4/7] Remove catch all for FreeBSD11 --- src/unix/bsd/freebsdlike/freebsd/mod.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/unix/bsd/freebsdlike/freebsd/mod.rs b/src/unix/bsd/freebsdlike/freebsd/mod.rs index c178b91b9408e..fea680d2af40c 100644 --- a/src/unix/bsd/freebsdlike/freebsd/mod.rs +++ b/src/unix/bsd/freebsdlike/freebsd/mod.rs @@ -1334,9 +1334,11 @@ cfg_if! { } else if #[cfg(freebsd13)] { mod freebsd12; pub use self::freebsd12::*; - } else { + } else if #[cfg(freebsd11)] { mod freebsd11; pub use self::freebsd11::*; + } else { + // Unknown freebsd version } } From cbc8fb973642dd9e29d2a445f0c992edb4f613c2 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 14 Aug 2019 17:32:21 +0200 Subject: [PATCH 5/7] Set up RUSTDOCFLAGS for building libc --- ci/dox.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/dox.sh b/ci/dox.sh index 49abd546001c8..febe18b35b836 100644 --- a/ci/dox.sh +++ b/ci/dox.sh @@ -47,6 +47,9 @@ while read -r target; do rustup target add "${target}" || true + # Enable extra configuration flags: + export RUSTDOCFLAGS="--cfg freebsd11" + # If cargo doc fails, then try xargo: if ! cargo doc --target "${target}" \ --no-default-features --features extra_traits ; then From eb9f523e657789ab3fd3a3078c6327b5cd0aa443 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Wed, 14 Aug 2019 17:34:26 +0200 Subject: [PATCH 6/7] Update minor patch version to 0.2.62 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c6e1b98c21aee..a39ab2945ceb1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "libc" -version = "0.2.61" +version = "0.2.62" authors = ["The Rust Project Developers"] license = "MIT OR Apache-2.0" readme = "README.md" From f0816947c9e7b975285b178b417b2601744af270 Mon Sep 17 00:00:00 2001 From: gnzlbg Date: Thu, 15 Aug 2019 06:55:13 +0200 Subject: [PATCH 7/7] Always pass freebsd11 - otherwise cross-compiling to FreeBSD fails --- build.rs | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/build.rs b/build.rs index 339eb195569ba..efc95b6627493 100644 --- a/build.rs +++ b/build.rs @@ -21,17 +21,11 @@ fn main() { // // On CI, we detect the actual FreeBSD version and match its ABI exactly, // running tests to ensure that the ABI is correct. - #[cfg(target_os = "freebsd")] match which_freebsd() { Some(11) if libc_ci => println!("cargo:rustc-cfg=freebsd11"), Some(12) if libc_ci => println!("cargo:rustc-cfg=freebsd12"), Some(13) if libc_ci => println!("cargo:rustc-cfg=freebsd13"), - Some(_) => println!("cargo:rustc-cfg=freebsd11"), - None => - /* not FreeBSD - nothing to do here */ - { - () - } + Some(_) | None => println!("cargo:rustc-cfg=freebsd11"), } // Rust >= 1.15 supports private module use: @@ -94,7 +88,6 @@ fn rustc_minor_version() -> Option { otry!(pieces.next()).parse().ok() } -#[cfg(target_os = "freebsd")] fn which_freebsd() -> Option { let output = std::process::Command::new("freebsd-version").output().ok(); if output.is_none() {