From fecdad02f348537c02e4e3d32a2314b1355ac7db Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Fri, 18 Sep 2026 11:56:56 +0100 Subject: [PATCH 01/10] fix: address minimal versions --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 6f46ab2..f327b97 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ set = [] cfg-if = "1" [target.'cfg(any(unix, target_os = "redox"))'.dependencies] -libc = "0.2" +libc = "0.2.12" [target.'cfg(target_os = "windows")'.dependencies] windows-link = "0.100" From 2875c8241cd843b3c0283b6afbdd03d65dd5792b Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Fri, 18 Sep 2026 11:45:56 +0100 Subject: [PATCH 02/10] Revert "Upgrade windows-bindgen to 0.100" This reverts commit 709c083b3d322482435fe52df04abfb9e4f262e4. --- Cargo.lock | 66 +++++++++++++++++++++++++---------------- Cargo.toml | 4 +-- src/lib.rs | 1 - src/windows/bindings.rs | 10 ++++++- tests/bindings.txt | 6 ++++ tests/codegen.rs | 16 ++++------ 6 files changed, 62 insertions(+), 41 deletions(-) create mode 100644 tests/bindings.txt diff --git a/Cargo.lock b/Cargo.lock index 7dcb661..598dad2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -92,7 +92,7 @@ dependencies = [ "similar-asserts", "version-sync", "windows-bindgen", - "windows-link 0.100.0", + "windows-link", ] [[package]] @@ -244,6 +244,12 @@ dependencies = [ "hashbrown", ] +[[package]] +name = "itoa" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" + [[package]] name = "libc" version = "0.2.189" @@ -326,6 +332,12 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +[[package]] +name = "ryu" +version = "1.0.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" + [[package]] name = "semver" version = "1.0.26" @@ -352,6 +364,18 @@ dependencies = [ "syn", ] +[[package]] +name = "serde_json" +version = "1.0.140" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373" +dependencies = [ + "itoa", + "memchr", + "ryu", + "serde", +] + [[package]] name = "serde_spanned" version = "0.6.8" @@ -517,47 +541,37 @@ dependencies = [ [[package]] name = "windows-bindgen" -version = "0.100.0" +version = "0.66.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6bb7c22ca81c6dc1554fd328c12697b4b0ad5c45081df2c3c9a3f89cc467da2" +checksum = "81b7ec123a4eadd44d1f44f76804316b477b2537abed9a2ab950b3c54afa1fcf" dependencies = [ - "proc-macro2", - "quote", - "windows-default", - "windows-metadata", + "serde", + "serde_json", + "windows-threading", ] -[[package]] -name = "windows-default" -version = "0.100.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4882bb065b03115aa8891d44d076bbe843d286d8bfd0b55caaa4b049141a712" - [[package]] name = "windows-link" version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5" -[[package]] -name = "windows-link" -version = "0.100.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b39de7c7fe78858b0144c50c3fc000bab3be17d5e9b85b1053871693c7f7415" - -[[package]] -name = "windows-metadata" -version = "0.100.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d3a758dc1da4ae61aa7f93afbb505d564c72dd6431e513ed581377857896a72" - [[package]] name = "windows-sys" version = "0.61.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc" dependencies = [ - "windows-link 0.2.1", + "windows-link", +] + +[[package]] +name = "windows-threading" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3949bd5b99cafdf1c7ca86b43ca564028dfe27d66958f2470940f73d86d75b37" +dependencies = [ + "windows-link", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index f327b97..5b22ac3 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,12 +22,12 @@ cfg-if = "1" libc = "0.2.12" [target.'cfg(target_os = "windows")'.dependencies] -windows-link = "0.100" +windows-link = "0.2" [dev-dependencies] similar-asserts = { version = "2.0.0" } version-sync = "0.9" -windows-bindgen = "0.100" +windows-bindgen = "0.66" [package.metadata.docs.rs] features = ["set"] diff --git a/src/lib.rs b/src/lib.rs index cec7838..7ac652e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -61,7 +61,6 @@ cfg_if! { mod nix; use crate::nix as sys; } else if #[cfg(target_os = "windows")] { - #[allow(dead_code, nonstandard_style, non_upper_case_globals, clippy::upper_case_acronyms)] mod windows; use crate::windows as sys; } else { diff --git a/src/windows/bindings.rs b/src/windows/bindings.rs index 4b8da22..058e5c5 100644 --- a/src/windows/bindings.rs +++ b/src/windows/bindings.rs @@ -1,7 +1,15 @@ +#![allow( + non_snake_case, + non_upper_case_globals, + non_camel_case_types, + dead_code, + clippy::all +)] + windows_link::link!("kernel32.dll" "system" fn GetComputerNameExW(nametype : COMPUTER_NAME_FORMAT, lpbuffer : PWSTR, nsize : *mut u32) -> BOOL); windows_link::link!("kernel32.dll" "system" fn SetComputerNameExW(nametype : COMPUTER_NAME_FORMAT, lpbuffer : PCWSTR) -> BOOL); pub type BOOL = i32; pub type COMPUTER_NAME_FORMAT = i32; -pub const ComputerNamePhysicalDnsHostname: COMPUTER_NAME_FORMAT = 5; +pub const ComputerNamePhysicalDnsHostname: COMPUTER_NAME_FORMAT = 5i32; pub type PCWSTR = *const u16; pub type PWSTR = *mut u16; diff --git a/tests/bindings.txt b/tests/bindings.txt new file mode 100644 index 0000000..cfaf66f --- /dev/null +++ b/tests/bindings.txt @@ -0,0 +1,6 @@ +--out src/windows/bindings.rs +--flat --sys --no-comment +--filter + ComputerNamePhysicalDnsHostname + GetComputerNameExW + SetComputerNameExW diff --git a/tests/codegen.rs b/tests/codegen.rs index e0ec8c7..c1a35a6 100644 --- a/tests/codegen.rs +++ b/tests/codegen.rs @@ -1,28 +1,22 @@ use std::fs; use std::process::Command; -use windows_bindgen::Bindgen; +use windows_bindgen::bindgen; #[test] fn gen_bindings() { let output = "src/windows/bindings.rs"; let existing = fs::read_to_string(output).unwrap(); - Bindgen::new() - .filter("ComputerNamePhysicalDnsHostname") - .filter("GetComputerNameExW") - .filter("SetComputerNameExW") - .output("src/windows/bindings.rs") - .flat() - .sys() - .dead_code() - .write(); - + bindgen(["--no-deps", "--etc", "tests/bindings.txt"]).unwrap(); let out = Command::new("rustfmt") .arg("--edition=2021") .arg(output) .output() .unwrap(); + + dbg!(String::from_utf8(out.stdout).unwrap()); + dbg!(String::from_utf8(out.stderr).unwrap()); assert!(out.status.success()); // Check the output is the same as before. From 739ffb2b739eb3cd9992baebdee77b63a76fba3d Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Fri, 18 Sep 2026 11:46:44 +0100 Subject: [PATCH 03/10] Revert "Bump MSRV to 1.85 (for windows-bindgen)" This reverts commit 80883f785caf3713095e044121cd7919d3df59a9. --- .github/workflows/ci.yml | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3364e78..ef395c3 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -276,6 +276,6 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@master with: - toolchain: 1.85 + toolchain: 1.74 - name: Check MSRV run: cargo check --locked --lib --all-features diff --git a/Cargo.toml b/Cargo.toml index 5b22ac3..b2867e9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/djc/hostname" readme = "README.md" license = "MIT" edition = "2021" -rust-version = "1.85" +rust-version = "1.74" [features] default = [] From d9cf169e30a6fd97a87cebaebef862c694b88a33 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Fri, 18 Sep 2026 12:45:15 +0100 Subject: [PATCH 04/10] fix: reduce MSRV to 1.71 --- .github/workflows/ci.yml | 2 +- Cargo.toml | 2 +- README.md | 4 ++-- src/nix.rs | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ef395c3..1e82b34 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -276,6 +276,6 @@ jobs: - name: Install Rust toolchain uses: dtolnay/rust-toolchain@master with: - toolchain: 1.74 + toolchain: 1.71 - name: Check MSRV run: cargo check --locked --lib --all-features diff --git a/Cargo.toml b/Cargo.toml index b2867e9..e3e3e55 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,7 +8,7 @@ repository = "https://github.com/djc/hostname" readme = "README.md" license = "MIT" edition = "2021" -rust-version = "1.74" +rust-version = "1.71" [features] default = [] diff --git a/README.md b/README.md index 308bd5c..0126547 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Latest Version](https://img.shields.io/crates/v/hostname.svg)](https://crates.io/crates/hostname) [![Latest Version](https://docs.rs/hostname/badge.svg)](https://docs.rs/hostname) [![Build Status](https://github.com/djc/hostname/actions/workflows/ci.yml/badge.svg)](https://github.com/djc/hostname/actions) -![Minimum rustc Version](https://img.shields.io/badge/rustc-1.74+-green.svg) +![Minimum rustc Version](https://img.shields.io/badge/rustc-1.71+-green.svg) ![MIT Licensed](https://img.shields.io/badge/license-MIT-blue.svg) ![crates.io](https://img.shields.io/crates/d/hostname) @@ -17,7 +17,7 @@ ## Rust version requirements -Since version `0.4.0` this crate requires Rust version `1.74` or greater. +Since version `0.4.3` this crate requires Rust version `1.71` or greater. This version is explicitly tested in CI and may be bumped in any major or minor release as needed.\ diff --git a/src/nix.rs b/src/nix.rs index 0737ee0..bfb212a 100644 --- a/src/nix.rs +++ b/src/nix.rs @@ -69,7 +69,7 @@ pub fn set(hostname: &OsStr) -> io::Result<()> { #[allow(clippy::unnecessary_cast)] // Cast is needed for the `libc::c_int` type if hostname.len() > hostname_len_t::MAX as usize { - return Err(io::Error::other("hostname too long")); + return Err(io::Error::new(io::ErrorKind::Other, "hostname too long")); } let size = hostname.len() as hostname_len_t; From 6790974df15fe9f10049a09eafccbb164c43fa9c Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Thu, 17 Sep 2026 01:49:08 +0100 Subject: [PATCH 05/10] fix: add AIX target support --- Cargo.toml | 2 +- src/nix.rs | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index e3e3e55..b72f6fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,7 @@ set = [] cfg-if = "1" [target.'cfg(any(unix, target_os = "redox"))'.dependencies] -libc = "0.2.12" +libc = "0.2.140" [target.'cfg(target_os = "windows")'.dependencies] windows-link = "0.2" diff --git a/src/nix.rs b/src/nix.rs index bfb212a..f31f999 100644 --- a/src/nix.rs +++ b/src/nix.rs @@ -45,6 +45,7 @@ fn wrap_buffer(mut bytes: Vec) -> OsString { #[cfg(feature = "set")] pub fn set(hostname: &OsStr) -> io::Result<()> { #[cfg(not(any( + target_os = "aix", target_os = "dragonfly", target_os = "freebsd", target_os = "ios", @@ -56,6 +57,7 @@ pub fn set(hostname: &OsStr) -> io::Result<()> { type hostname_len_t = libc::size_t; #[cfg(any( + target_os = "aix", target_os = "dragonfly", target_os = "freebsd", target_os = "ios", From 0252ec34e03effd4e43a4ae0cbdafde69c225b42 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Fri, 18 Sep 2026 15:28:29 +0100 Subject: [PATCH 06/10] ci: add Tier 3 job --- .github/workflows/ci.yml | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1e82b34..59c823a 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -261,6 +261,29 @@ jobs: run: | cross build --locked --target=${{ matrix.target }} + tier3: + # Matches Rust "Tier 3" platform support + # For as much as possible, but where `cross` is needed for cross-compilation + # + # See https://doc.rust-lang.org/rustc/platform-support.html#tier-3 + name: Tier 3 + needs: tier1 + runs-on: ubuntu-latest + strategy: + matrix: + target: + - powerpc64-ibm-aix + steps: + - uses: actions/checkout@v7 + - name: Install Rust toolchain + uses: dtolnay/rust-toolchain@nightly + - uses: taiki-e/install-action@v2.87.11 + with: + tool: cross + - name: Run build + run: | + cross build -Zbuild-std --locked --all-features --target=${{ matrix.target }} + msrv: name: MSRV strategy: From ce39cbb7c2ea6aed455965d506a405d5c8d34315 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Thu, 17 Sep 2026 02:32:59 +0100 Subject: [PATCH 07/10] fix: add Apple target support ```sh RUSTC_BOOTSTRAP=1 cargo clippy -q -Zbuild-std \ --workspace --all-targets --all-features \ --target aarch64-apple-ios \ --target aarch64-apple-ios-macabi \ --target aarch64-apple-ios-sim \ --target aarch64-apple-tvos \ --target aarch64-apple-tvos-sim \ --target aarch64-apple-visionos \ --target aarch64-apple-visionos-sim \ --target aarch64-apple-watchos \ --target aarch64-apple-watchos-sim \ --target x86_64-apple-ios \ --target x86_64-apple-ios-macabi ``` --- src/nix.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/nix.rs b/src/nix.rs index f31f999..568d8f6 100644 --- a/src/nix.rs +++ b/src/nix.rs @@ -45,11 +45,10 @@ fn wrap_buffer(mut bytes: Vec) -> OsString { #[cfg(feature = "set")] pub fn set(hostname: &OsStr) -> io::Result<()> { #[cfg(not(any( + target_vendor = "apple", target_os = "aix", target_os = "dragonfly", target_os = "freebsd", - target_os = "ios", - target_os = "macos", target_os = "solaris", target_os = "illumos" )))] @@ -57,11 +56,10 @@ pub fn set(hostname: &OsStr) -> io::Result<()> { type hostname_len_t = libc::size_t; #[cfg(any( + target_vendor = "apple", target_os = "aix", target_os = "dragonfly", target_os = "freebsd", - target_os = "ios", - target_os = "macos", target_os = "solaris", target_os = "illumos" ))] From e8a8e5caa036850cc6f5524db6c5cda7819a7fe1 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Fri, 18 Sep 2026 15:10:37 +0100 Subject: [PATCH 08/10] ci: refactor MSRV job --- .github/workflows/ci.yml | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 59c823a..aac56d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -286,19 +286,31 @@ jobs: msrv: name: MSRV - strategy: - matrix: - include: - - os: ubuntu-latest - - os: macos-latest - - os: windows-latest - - runs-on: ${{ matrix.os }} + runs-on: ubuntu-latest + env: + # Matches Tier 1 job targets + TARGETS: | + aarch64-unknown-linux-gnu + i686-unknown-linux-gnu + x86_64-unknown-linux-gnu + i686-pc-windows-gnu + i686-pc-windows-msvc + x86_64-pc-windows-gnu + x86_64-pc-windows-msvc + x86_64-apple-darwin steps: - uses: actions/checkout@v7 - - name: Install Rust toolchain - uses: dtolnay/rust-toolchain@master + - uses: taiki-e/install-action@v2.87.11 with: - toolchain: 1.71 + tool: | + cargo-hack + cargo-minimal-versions + fallback: none - name: Check MSRV - run: cargo check --locked --lib --all-features + run: | + cargo minimal-versions check \ + --workspace \ + --feature-powerset \ + --ignore-private \ + --rust-version \ + $(printf '%s\n' "$TARGETS" | xargs -n1 printf -- '--target %s ') From 63459f411f890585b9b5fad28245890d8eb18893 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Fri, 18 Sep 2026 16:03:48 +0100 Subject: [PATCH 09/10] ci: update job dependencies to require msrv instead of tier1 Ensure we are not blocked on macos runner availability --- .github/workflows/ci.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index aac56d8..5436775 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,7 +90,7 @@ jobs: # # See https://doc.rust-lang.org/nightly/rustc/platform-support.html#tier-2-with-host-tools name: Tier 2 (with Host Tools) - needs: tier1 + needs: msrv runs-on: ${{ matrix.os }} strategy: matrix: @@ -138,7 +138,7 @@ jobs: # # See https://doc.rust-lang.org/nightly/rustc/platform-support.html#tier-2-with-host-tools name: Tier 2 (with Host Tools, via Cross) - needs: tier1 + needs: msrv runs-on: ubuntu-latest strategy: matrix: @@ -165,7 +165,7 @@ jobs: # # See https://doc.rust-lang.org/nightly/rustc/platform-support.html#tier-2-with-host-tools name: Tier 2 (without Host Tools) - needs: tier1 + needs: msrv runs-on: ${{ matrix.os }} strategy: matrix: @@ -241,7 +241,7 @@ jobs: # # See https://doc.rust-lang.org/nightly/rustc/platform-support.html#tier-2-with-host-tools name: Tier 2 (without Host Tools) - needs: tier1 + needs: msrv runs-on: ${{ matrix.os }} strategy: matrix: @@ -267,7 +267,7 @@ jobs: # # See https://doc.rust-lang.org/rustc/platform-support.html#tier-3 name: Tier 3 - needs: tier1 + needs: msrv runs-on: ubuntu-latest strategy: matrix: From 79b3e480f43a286cf493e45471e43546ab534f6b Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Fri, 18 Sep 2026 16:05:36 +0100 Subject: [PATCH 10/10] ci: update macos runner capitalization --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5436775..2d50641 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: matrix: os: - ubuntu-latest - - macOS-latest + - macos-latest - windows-latest steps: - uses: actions/checkout@v7