diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 5bc079890481..e154fe3ea926 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -116,23 +116,23 @@ jobs: strategy: matrix: include: - - target: aarch64-apple-darwin - os: macos-15 - - target: aarch64-pc-windows-msvc - os: windows-11-arm - - target: aarch64-unknown-linux-gnu - os: ubuntu-24.04-arm - # FIXME: It currently causes segfaults. - #- target: i686-pc-windows-gnu - # env: { ARCH_BITS: 32, ARCH: i686 } - - target: i686-pc-windows-msvc - os: windows-2025 + # - target: aarch64-apple-darwin + # os: macos-15 + # - target: aarch64-pc-windows-msvc + # os: windows-11-arm + # - target: aarch64-unknown-linux-gnu + # os: ubuntu-24.04-arm + # # FIXME: It currently causes segfaults. + # #- target: i686-pc-windows-gnu + # # env: { ARCH_BITS: 32, ARCH: i686 } + # - target: i686-pc-windows-msvc + # os: windows-2025 - target: i686-unknown-linux-gnu - - target: x86_64-pc-windows-gnu - os: windows-2025 - env: { ARCH_BITS: 64, ARCH: x86_64 } - - target: x86_64-pc-windows-msvc - os: windows-2025 + # - target: x86_64-pc-windows-gnu + # os: windows-2025 + # env: { ARCH_BITS: 64, ARCH: x86_64 } + # - target: x86_64-pc-windows-msvc + # os: windows-2025 - target: x86_64-unknown-linux-gnu runs-on: ${{ matrix.os && matrix.os || 'ubuntu-24.04' }} timeout-minutes: 25 @@ -173,16 +173,16 @@ jobs: test_tier2: name: Test tier2 - needs: [test_tier1, style_check] + # needs: [test_tier1, style_check] strategy: - fail-fast: true + fail-fast: false max-parallel: 16 matrix: include: # FIXME(sparc): this takes much longer to run than any other job, put # it first to make sure it gets a head start. - target: sparc64-unknown-linux-gnu - - target: aarch64-linux-android + # - target: aarch64-linux-android - target: aarch64-unknown-linux-musl - target: aarch64-unknown-linux-musl env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } @@ -199,25 +199,25 @@ jobs: - target: i686-unknown-linux-musl env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } artifact-tag: new-musl - - target: loongarch64-unknown-linux-gnu - - target: loongarch64-unknown-linux-musl - - target: loongarch64-unknown-linux-musl - env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } - artifact-tag: new-musl - - target: powerpc64-unknown-linux-gnu - - target: powerpc64le-unknown-linux-gnu - - target: powerpc64le-unknown-linux-musl - - target: powerpc64le-unknown-linux-musl - env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } - artifact-tag: new-musl - - target: riscv64gc-unknown-linux-gnu - - target: s390x-unknown-linux-gnu - - target: wasm32-unknown-emscripten - - target: wasm32-wasip1 - - target: wasm32-wasip2 - - target: x86_64-apple-darwin - os: macos-15-intel - - target: x86_64-linux-android + # - target: loongarch64-unknown-linux-gnu + # - target: loongarch64-unknown-linux-musl + # - target: loongarch64-unknown-linux-musl + # env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } + # artifact-tag: new-musl + # - target: powerpc64-unknown-linux-gnu + # - target: powerpc64le-unknown-linux-gnu + # - target: powerpc64le-unknown-linux-musl + # - target: powerpc64le-unknown-linux-musl + # env: { RUST_LIBC_UNSTABLE_MUSL_V1_2_3: 1 } + # artifact-tag: new-musl + # - target: riscv64gc-unknown-linux-gnu + # - target: s390x-unknown-linux-gnu + # - target: wasm32-unknown-emscripten + # - target: wasm32-wasip1 + # - target: wasm32-wasip2 + # - target: x86_64-apple-darwin + # os: macos-15-intel + # - target: x86_64-linux-android # FIXME: Exec format error (os error 8) # - target: x86_64-unknown-linux-gnux32 - target: x86_64-unknown-linux-musl @@ -267,55 +267,55 @@ jobs: path: ${{ env.ARCHIVE_PATH }} retention-days: 5 - test_tier2_vm: - name: Test tier2 VM - needs: [test_tier1, style_check] - runs-on: ubuntu-latest - strategy: - fail-fast: true - matrix: - include: - - target: x86_64-pc-solaris - - target: x86_64-unknown-netbsd - timeout-minutes: 25 - steps: - - uses: actions/checkout@v6 - - name: test on Solaris - uses: vmactions/solaris-vm@v1.1.8 - if: contains(matrix.target, 'solaris') - with: - release: "11.4-gcc" - usesh: true - mem: 4096 - copyback: false - prepare: | - set -x - source <(curl -s https://raw.githubusercontent.com/psumbera/solaris-rust/refs/heads/main/sh.rust-web-install) - rustc --version - uname -a - run: | - export PATH=$HOME/.rust_solaris/bin:$PATH - ./ci/run.sh ${{ matrix.target }} + # test_tier2_vm: + # name: Test tier2 VM + # needs: [test_tier1, style_check] + # runs-on: ubuntu-latest + # strategy: + # fail-fast: true + # matrix: + # include: + # - target: x86_64-pc-solaris + # - target: x86_64-unknown-netbsd + # timeout-minutes: 25 + # steps: + # - uses: actions/checkout@v6 + # - name: test on Solaris + # uses: vmactions/solaris-vm@v1.1.8 + # if: contains(matrix.target, 'solaris') + # with: + # release: "11.4-gcc" + # usesh: true + # mem: 4096 + # copyback: false + # prepare: | + # set -x + # source <(curl -s https://raw.githubusercontent.com/psumbera/solaris-rust/refs/heads/main/sh.rust-web-install) + # rustc --version + # uname -a + # run: | + # export PATH=$HOME/.rust_solaris/bin:$PATH + # ./ci/run.sh ${{ matrix.target }} - - name: Test on NetBSD - uses: vmactions/netbsd-vm@v1 - if: contains(matrix.target, 'netbsd') - with: - release: "10.1" - usesh: true - mem: 4096 - copyback: false - prepare: | - set -x - /usr/sbin/pkg_add curl - curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \ - --profile minimal --default-toolchain nightly -y - run: | - set -x - . "$HOME/.cargo/env" - which rustc - rustc -Vv - ./ci/run.sh ${{ matrix.target }} + # - name: Test on NetBSD + # uses: vmactions/netbsd-vm@v1 + # if: contains(matrix.target, 'netbsd') + # with: + # release: "10.1" + # usesh: true + # mem: 4096 + # copyback: false + # prepare: | + # set -x + # /usr/sbin/pkg_add curl + # curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- \ + # --profile minimal --default-toolchain nightly -y + # run: | + # set -x + # . "$HOME/.cargo/env" + # which rustc + # rustc -Vv + # ./ci/run.sh ${{ matrix.target }} ctest_msrv: name: Check ctest MSRV @@ -357,7 +357,7 @@ jobs: - style_check - test_tier1 - test_tier2 - - test_tier2_vm + # - test_tier2_vm - verify_build - ctest_msrv - docs diff --git a/build.rs b/build.rs index c21a1c642bca..e9722b93d732 100644 --- a/build.rs +++ b/build.rs @@ -65,9 +65,9 @@ fn main() { // // On CI, we detect the actual FreeBSD version and match its ABI exactly, // running tests to ensure that the ABI is correct. - println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_FREEBSD_VERSION"); - // Allow overriding the default version for testing - let which_freebsd = if let Ok(version) = env::var("RUST_LIBC_UNSTABLE_FREEBSD_VERSION") { + // + // The env allows overriding the default version for testing + let which_freebsd = if let Some(version) = env_value("RUST_LIBC_UNSTABLE_FREEBSD_VERSION") { let vers = version.parse().unwrap(); println!("cargo:warning=setting FreeBSD version to {vers}"); vers @@ -100,14 +100,11 @@ fn main() { } let musl_v1_2_3 = env_flag("RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); - println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); // loongarch64 and ohos have already updated if musl_v1_2_3 || target_arch == "loongarch64" || target_env == "ohos" { // FIXME(musl): enable time64 api as well set_cfg("musl_v1_2_3"); } - println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"); - println!("cargo:rerun-if-env-changed=RUST_LIBC_UNSTABLE_GNU_TIME_BITS"); if target_env == "gnu" && target_os == "linux" && target_ptr_width == "32" @@ -116,16 +113,16 @@ fn main() { { let defaultbits = "32".to_string(); let (timebits, filebits) = match ( - env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS"), - env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), + env_value("RUST_LIBC_UNSTABLE_GNU_TIME_BITS"), + env_value("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), ) { - (Ok(_), Ok(_)) => panic!("Do not set both RUST_LIBC_UNSTABLE_GNU_TIME_BITS and RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), - (Err(_), Err(_)) => (defaultbits.clone(), defaultbits.clone()), - (Ok(tb), Err(_)) if tb == "64" => (tb.clone(), tb.clone()), - (Ok(tb), Err(_)) if tb == "32" => (tb, defaultbits.clone()), - (Ok(_), Err(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_TIME_BITS, must be 32 or 64"), - (Err(_), Ok(fb)) if fb == "32" || fb == "64" => (defaultbits.clone(), fb), - (Err(_), Ok(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS, must be 32 or 64"), + (Some(_), Some(_)) => panic!("Do not set both RUST_LIBC_UNSTABLE_GNU_TIME_BITS and RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), + (None, None) => (defaultbits.clone(), defaultbits.clone()), + (Some(tb), None) if tb == "64" => (tb.clone(), tb.clone()), + (Some(tb), None) if tb == "32" => (tb, defaultbits.clone()), + (Some(_), None) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_TIME_BITS, must be 32 or 64"), + (None, Some(fb)) if fb == "32" || fb == "64" => (defaultbits.clone(), fb), + (None, Some(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS, must be 32 or 64"), }; let valid_bits = ["32", "64"]; assert!( @@ -287,7 +284,7 @@ fn emcc_version_code() -> Option { /// environment, in `(minor, patch)` form. Currently the only major version supported by Rust /// is 7. fn vxworks_version_code() -> Option<(u32, u32)> { - let version = env::var("WIND_RELEASE_ID").ok()?; + let version = env_value("WIND_RELEASE_ID")?; let mut pieces = version.trim().split(['.']); @@ -305,12 +302,21 @@ fn set_cfg(cfg: &str) { println!("cargo:rustc-cfg={cfg}"); } -/// Return true if the env is set to a value other than `0`. +/// Return true if the env is set to a value other than `0`. Sets `rerun-if-changed`. fn env_flag(key: &str) -> bool { + match env_value(key) { + Some(x) if x == "0" => false, + None => false, + Some(_) => true, + } +} + +/// Return the value if set. Sets `rerun-if-changed`. +fn env_value(key: &str) -> Option { + println!("cargo:rerun-if-env-changed={key}"); match env::var(key) { - Ok(x) if x == "0" => false, - Err(VarError::NotPresent) => false, - Err(VarError::NotUnicode(_)) => panic!("non-unicode var for `{key}`"), - Ok(_) => true, + Ok(v) => Some(v), + Err(VarError::NotPresent) => None, + Err(VarError::NotUnicode(_)) => panic!("non-unicode env value `{key}`"), } } diff --git a/ci/run.sh b/ci/run.sh index 96e5750945df..8044f117aec1 100755 --- a/ci/run.sh +++ b/ci/run.sh @@ -13,6 +13,8 @@ export RUSTFLAGS="${EXTRA_RUSTFLAGS:-} ${RUSTFLAGS:-}" echo "RUSTFLAGS: '$RUSTFLAGS'" +export CC_ENABLE_DEBUG_OUTPUT=1 + # For logging uname -a diff --git a/libc-test/build.rs b/libc-test/build.rs index 4d699411c001..f45d88ef32d9 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1,6 +1,7 @@ #![deny(warnings)] #![allow(clippy::match_like_matches_macro)] +use std::env::VarError; use std::fs::File; use std::io::{ BufRead, @@ -2295,7 +2296,7 @@ fn test_freebsd(target: &str) { assert!(target.contains("freebsd")); let mut cfg = ctest_cfg(); - let freebsd_ver = if let Ok(version) = env::var("RUST_LIBC_UNSTABLE_FREEBSD_VERSION") { + let freebsd_ver = if let Some(version) = env_value("RUST_LIBC_UNSTABLE_FREEBSD_VERSION") { let vers = version.parse().unwrap(); println!("cargo:warning=setting FreeBSD version to {vers}"); Some(vers) @@ -3224,8 +3225,8 @@ fn test_neutrino(target: &str) { let mut cfg = ctest_cfg(); if target.ends_with("_iosock") { - let qnx_target_val = env::var("QNX_TARGET") - .unwrap_or_else(|_| "QNX_TARGET_not_set_please_source_qnxsdp".into()); + let qnx_target_val = env_value("QNX_TARGET") + .unwrap_or_else(|| "QNX_TARGET_not_set_please_source_qnxsdp".into()); cfg.include(qnx_target_val + "/usr/include/io-sock"); headers!( @@ -3469,8 +3470,9 @@ fn test_neutrino(target: &str) { } fn which_vxworks() -> Option<(u32, u32)> { - let version = env::var("WIND_RELEASE_ID").ok()?; // When in VxWorks setup, WIND_RELEASE_ID is - // always set as the version of the release. + // When in VxWorks setup, WIND_RELEASE_ID is + // always set as the version of the release. + let version = env_value("WIND_RELEASE_ID")?; let mut pieces = version.trim().split(['.']); @@ -3627,16 +3629,16 @@ fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) { { let defaultbits = "32".to_string(); let (timebits, filebits) = match ( - env::var("RUST_LIBC_UNSTABLE_GNU_TIME_BITS"), - env::var("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), + env_value("RUST_LIBC_UNSTABLE_GNU_TIME_BITS"), + env_value("RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), ) { - (Ok(_), Ok(_)) => panic!("Do not set both RUST_LIBC_UNSTABLE_GNU_TIME_BITS and RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), - (Err(_), Err(_)) => (defaultbits.clone(), defaultbits.clone()), - (Ok(tb), Err(_)) if tb == "64" => (tb.clone(), tb.clone()), - (Ok(tb), Err(_)) if tb == "32" => (tb, defaultbits.clone()), - (Ok(_), Err(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_TIME_BITS, must be 32 or 64"), - (Err(_), Ok(fb)) if fb == "32" || fb == "64" => (defaultbits.clone(), fb), - (Err(_), Ok(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS, must be 32 or 64"), + (Some(_), Some(_)) => panic!("Do not set both RUST_LIBC_UNSTABLE_GNU_TIME_BITS and RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS"), + (None, None) => (defaultbits.clone(), defaultbits.clone()), + (Some(tb), None) if tb == "64" => (tb.clone(), tb.clone()), + (Some(tb), None) if tb == "32" => (tb, defaultbits.clone()), + (Some(_), None) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_TIME_BITS, must be 32 or 64"), + (None, Some(fb)) if fb == "32" || fb == "64" => (defaultbits.clone(), fb), + (None, Some(_)) => panic!("Invalid value for RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS, must be 32 or 64"), }; let valid_bits = ["32", "64"]; assert!( @@ -3648,12 +3650,12 @@ fn config_gnu_bits(target: &str, cfg: &mut ctest::TestGenerator) { "RUST_LIBC_UNSTABLE_GNU_FILE_OFFSET_BITS must be 64 or unset if RUST_LIBC_UNSTABLE_GNU_TIME_BITS is 64" ); if timebits == "64" { - cfg.define("_TIME_BITS", Some("64")); + // cfg.define("_TIME_BITS", Some("64")); cfg.cfg("linux_time_bits64", None); cfg.cfg("gnu_time_bits64", None); } if filebits == "64" { - cfg.define("_FILE_OFFSET_BITS", Some("64")); + // cfg.define("_FILE_OFFSET_BITS", Some("64")); cfg.cfg("gnu_file_offset_bits64", None); } } @@ -3692,7 +3694,7 @@ fn test_linux(target: &str) { let uclibc = target.contains("uclibc"); let mips = target.contains("mips"); - let musl_v1_2_3 = env::var("RUST_LIBC_UNSTABLE_MUSL_V1_2_3").is_ok(); + let musl_v1_2_3 = env_flag("RUST_LIBC_UNSTABLE_MUSL_V1_2_3"); if musl_v1_2_3 { assert!(musl); } @@ -5607,3 +5609,22 @@ fn try_command_output(cmd: &str, args: &[&str]) -> Option { .unwrap_or_else(|e| panic!("command {cmd} returned non-UTF-8 output: {e}")); Some(res) } + +/// Return true if the env is set to a value other than `0`. Sets `rerun-if-changed`. +fn env_flag(key: &str) -> bool { + match env_value(key) { + Some(x) if x == "0" => false, + None => false, + Some(_) => true, + } +} + +/// Return the value if set. Sets `rerun-if-changed`. +fn env_value(key: &str) -> Option { + println!("cargo:rerun-if-env-changed={key}"); + match env::var(key) { + Ok(v) => Some(v), + Err(VarError::NotPresent) => None, + Err(VarError::NotUnicode(_)) => panic!("non-unicode env value `{key}`"), + } +}