From acc4c12103da98330e9f77f27e33881f33f5ef4d Mon Sep 17 00:00:00 2001 From: messense Date: Thu, 1 Feb 2024 13:55:17 +0800 Subject: [PATCH 01/25] Update CI.yml --- .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 af9b6ca..d1cc451 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -73,7 +73,7 @@ jobs: i686-pc-windows-gnu - name: Test bindgen # skip on MSRV - if: matrix.toolchain != '1.67.0' + if: matrix.toolchain != '1.70.0' shell: bash run: | set -e From 570248ef06467dd5f2e3d36dc2c848487c015cbb Mon Sep 17 00:00:00 2001 From: messense Date: Thu, 1 Feb 2024 14:59:16 +0800 Subject: [PATCH 02/25] Update CI.yml --- .github/workflows/CI.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index d1cc451..9b3a971 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -72,8 +72,6 @@ jobs: x86_64-pc-windows-gnu \ i686-pc-windows-gnu - name: Test bindgen - # skip on MSRV - if: matrix.toolchain != '1.70.0' shell: bash run: | set -e From faea1720e9d2b2d27035aece58ba1f4718a985fb Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 10:29:03 +0800 Subject: [PATCH 03/25] Bump mozilla-actions/sccache-action from 0.0.3 to 0.0.4 (#220) Bumps [mozilla-actions/sccache-action](https://github.com/mozilla-actions/sccache-action) from 0.0.3 to 0.0.4. - [Release notes](https://github.com/mozilla-actions/sccache-action/releases) - [Commits](https://github.com/mozilla-actions/sccache-action/compare/v0.0.3...v0.0.4) --- updated-dependencies: - dependency-name: mozilla-actions/sccache-action dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .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 9b3a971..0dd3c19 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -46,7 +46,7 @@ jobs: steps: - uses: actions/checkout@v4 - name: setup sccache - uses: mozilla-actions/sccache-action@v0.0.3 + uses: mozilla-actions/sccache-action@v0.0.4 with: version: "v0.4.0" - uses: dtolnay/rust-toolchain@master From 871605b68ba6074b24943ec9bdf2b32dea5590c0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 5 Feb 2024 10:29:11 +0800 Subject: [PATCH 04/25] Bump peter-evans/dockerhub-description from 3 to 4 (#219) Bumps [peter-evans/dockerhub-description](https://github.com/peter-evans/dockerhub-description) from 3 to 4. - [Release notes](https://github.com/peter-evans/dockerhub-description/releases) - [Commits](https://github.com/peter-evans/dockerhub-description/compare/v3...v4) --- updated-dependencies: - dependency-name: peter-evans/dockerhub-description dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- .github/workflows/Release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index bd21b7f..71f6fbd 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -200,7 +200,7 @@ jobs: cache-to: type=gha,mode=max - name: Docker Hub Description if: github.event_name != 'pull_request' - uses: peter-evans/dockerhub-description@v3 + uses: peter-evans/dockerhub-description@v4 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_TOKEN }} From 0f3b6cac05e4664913406b41bd2b3d675bfcc2c5 Mon Sep 17 00:00:00 2001 From: messense Date: Tue, 6 Feb 2024 11:49:36 +0800 Subject: [PATCH 05/25] Upgrade Rust to 1.75.0 in Dockerfile Closes #225 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 9585770..1c5e65f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG RUST_VERSION=1.73.0 +ARG RUST_VERSION=1.75.0 FROM rust:$RUST_VERSION as builder From 2cffe392317049b0b3a48387e26d4bfe481b53a8 Mon Sep 17 00:00:00 2001 From: Chawye Hsu Date: Tue, 20 Feb 2024 18:25:23 +0800 Subject: [PATCH 06/25] chore(ci): generate checksum for windows release (#227) --- .github/workflows/Release.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 71f6fbd..5cdb1ba 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -87,13 +87,15 @@ jobs: run: | cd target/${{ matrix.platform.target }}/release 7z a cargo-zigbuild-${{ github.ref_name }}.windows-${{ matrix.platform.arch }}.zip cargo-zigbuild.exe + $sha256 = (Get-FileHash cargo-zigbuild-${{ github.ref_name }}.windows-${{ matrix.platform.arch }}.zip -Algorithm SHA256).Hash.ToLower() + "$sha256 cargo-zigbuild-${{ github.ref_name }}.windows-${{ matrix.platform.arch }}.zip" | Out-File cargo-zigbuild-${{ github.ref_name }}.windows-${{ matrix.platform.arch }}.zip.sha256 cd - - name: Upload binary to GitHub Release if: "startsWith(github.ref, 'refs/tags/')" uses: softprops/action-gh-release@v1 with: files: | - target/${{ matrix.platform.target }}/release/cargo-zigbuild-*.zip + target/${{ matrix.platform.target }}/release/cargo-zigbuild-*.zip* prerelease: ${{ contains(github.ref, 'alpha') || contains(github.ref, 'beta') }} generate_release_notes: true From bb7612b0238af246bf9b72894395bca712f1b47b Mon Sep 17 00:00:00 2001 From: messense Date: Fri, 1 Mar 2024 16:35:50 +0800 Subject: [PATCH 07/25] Use download/upload-artifact@v4 in Release.yml --- .github/workflows/Release.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 5cdb1ba..56dda2f 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -24,12 +24,12 @@ jobs: args: --release --out dist --strip --universal2 sccache: 'true' - name: Upload wheels - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: wheels + name: wheels-macos-universal2 path: dist - name: Upload binary artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: apple-darwin-bin path: target/release/cargo-zigbuild @@ -72,12 +72,12 @@ jobs: args: --release --out dist --strip sccache: 'true' - name: Upload wheels - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: wheels + name: wheels-${{ matrix.platform.arch }} path: dist - name: Upload binary artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: windows-${{ matrix.platform.arch }}-bin path: target/${{ matrix.platform.target }}/release/cargo-zigbuild.exe @@ -125,12 +125,12 @@ jobs: args: --release -o dist --strip sccache: 'true' - name: Upload wheels - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: wheels + name: wheels-${{ matrix.platform.target }} path: dist - name: Upload binary artifacts - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: name: ${{ matrix.platform.target }}-bin path: target/${{ matrix.platform.target }}/release/cargo-zigbuild @@ -214,9 +214,10 @@ jobs: if: "startsWith(github.ref, 'refs/tags/')" needs: [ macos, windows, linux ] steps: - - uses: actions/download-artifact@v3 + - uses: actions/download-artifact@v4 with: - name: wheels + pattern: wheels-* + merge-multiple: true - name: Publish to PyPI env: MATURIN_PYPI_TOKEN: ${{ secrets.PYPI_PASSWORD }} From c84ba5d4e434e11ca0c49f665860b275a9de3e6e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Mar 2024 09:39:34 +0800 Subject: [PATCH 08/25] Bump mio from 0.8.6 to 0.8.11 in /tests/hello-tls (#229) Bumps [mio](https://github.com/tokio-rs/mio) from 0.8.6 to 0.8.11. - [Release notes](https://github.com/tokio-rs/mio/releases) - [Changelog](https://github.com/tokio-rs/mio/blob/master/CHANGELOG.md) - [Commits](https://github.com/tokio-rs/mio/compare/v0.8.6...v0.8.11) --- updated-dependencies: - dependency-name: mio dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- tests/hello-tls/Cargo.lock | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/hello-tls/Cargo.lock b/tests/hello-tls/Cargo.lock index 8382a19..11d037c 100644 --- a/tests/hello-tls/Cargo.lock +++ b/tests/hello-tls/Cargo.lock @@ -368,9 +368,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.141" +version = "0.2.153" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" +checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" [[package]] name = "linux-raw-sys" @@ -395,14 +395,14 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mio" -version = "0.8.6" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", "wasi", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] From ca7f11de0929e1e0d9a7fa30864d39a5c480d64f Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 5 Mar 2024 09:39:46 +0800 Subject: [PATCH 09/25] Bump mio from 0.8.6 to 0.8.11 in /tests/hello-rustls (#228) Bumps [mio](https://github.com/tokio-rs/mio) from 0.8.6 to 0.8.11. - [Release notes](https://github.com/tokio-rs/mio/releases) - [Changelog](https://github.com/tokio-rs/mio/blob/master/CHANGELOG.md) - [Commits](https://github.com/tokio-rs/mio/compare/v0.8.6...v0.8.11) --- updated-dependencies: - dependency-name: mio dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- tests/hello-rustls/Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/hello-rustls/Cargo.lock b/tests/hello-rustls/Cargo.lock index 4d11509..6cbfe20 100644 --- a/tests/hello-rustls/Cargo.lock +++ b/tests/hello-rustls/Cargo.lock @@ -368,14 +368,14 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" [[package]] name = "mio" -version = "0.8.6" +version = "0.8.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +checksum = "a4a650543ca06a924e8b371db273b2756685faae30f8487da1b56505a8f78b0c" dependencies = [ "libc", "log", "wasi", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] From ea991378fa24b9e914daa4b4be511265af9247b7 Mon Sep 17 00:00:00 2001 From: Brennan Kinney <5098581+polarathene@users.noreply.github.com> Date: Tue, 12 Mar 2024 01:57:09 +1300 Subject: [PATCH 10/25] docs: Add caveats for glibc version targeting feature (#232) --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index 74c40d7..223728e 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,16 @@ to compile for glibc 2.17 with the `aarch64-unknown-linux-gnu` target: cargo zigbuild --target aarch64-unknown-linux-gnu.2.17 ``` +> [!NOTE] +> There are [various caveats](https://github.com/rust-cross/cargo-zigbuild/issues/231#issuecomment-1983434802) with the glibc version targeting feature: +> - If you do not provide a `--target`, Zig is not used and the command effectively runs a regular `cargo build`. +> - If you specify an invalid glibc version, `cargo zigbuild` will not relay the warning emitted from `zig cc` about the fallback version selected. +> - This feature does not necessarily match the behaviour of dynamically linking to a specific version of glibc on the build host. +> - Version 2.32 can be specified, but runs on a host with only 2.31 available when it should instead abort with an error. +> - Meanwhile specifying 2.33 will correctly be detected as incompatible when run on a host with glibc 2.31. +> - Certain `RUSTFLAGS` like `-C linker` opt-out of using Zig, while `-L path/to/files` will have Zig ignore `-C target-feature=+crt-static`. +> - `-C target-feature=+crt-static` for statically linking to a glibc version is **not supported** (_upstream `zig cc` lacks support_) + ### macOS universal2 target `cargo zigbuild` supports a special `universal2-apple-darwin` target for building macOS universal2 binaries/libraries on Rust 1.64.0 and later. From d54aa9c48ed15c3fef5a3ea7293754f7ad7b17e0 Mon Sep 17 00:00:00 2001 From: messense Date: Fri, 15 Mar 2024 11:32:04 +0800 Subject: [PATCH 11/25] Update Rust to 1.76 in Dockerfile --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 1c5e65f..b4c3ae7 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG RUST_VERSION=1.75.0 +ARG RUST_VERSION=1.76.0 FROM rust:$RUST_VERSION as builder From e152d9d65aa2e9c14796eb159271325df2e9a1ec Mon Sep 17 00:00:00 2001 From: Chris Pick Date: Sun, 17 Mar 2024 09:24:48 -0400 Subject: [PATCH 12/25] Add `cargo-zigbuild doc` support (#235) Closes: https://github.com/rust-cross/cargo-zigbuild/issues/233 Co-authored-by: Chris Pick --- src/bin/cargo-zigbuild.rs | 8 +++- src/doc.rs | 87 +++++++++++++++++++++++++++++++++++++++ src/lib.rs | 2 + 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 src/doc.rs diff --git a/src/bin/cargo-zigbuild.rs b/src/bin/cargo-zigbuild.rs index 7e4ee02..774951f 100644 --- a/src/bin/cargo-zigbuild.rs +++ b/src/bin/cargo-zigbuild.rs @@ -3,7 +3,7 @@ use std::ffi::OsString; use std::path::PathBuf; use std::process::Command; -use cargo_zigbuild::{Build, Check, Clippy, Install, Run, Rustc, Test, Zig}; +use cargo_zigbuild::{Build, Check, Clippy, Doc, Install, Run, Rustc, Test, Zig}; use clap::Parser; #[allow(clippy::large_enum_variant)] @@ -21,6 +21,8 @@ pub enum Opt { Clippy(Clippy), #[command(name = "check", aliases = &["c"])] Check(Check), + #[command(name = "doc")] + Doc(Doc), #[command(name = "install")] Install(Install), #[command(name = "rustc")] @@ -59,6 +61,10 @@ fn main() -> anyhow::Result<()> { check.enable_zig_ar = true; check.execute()? } + Opt::Doc(mut doc) => { + doc.enable_zig_ar = true; + doc.execute()? + } Opt::Install(mut install) => { install.enable_zig_ar = true; install.execute()? diff --git a/src/doc.rs b/src/doc.rs new file mode 100644 index 0000000..2c61601 --- /dev/null +++ b/src/doc.rs @@ -0,0 +1,87 @@ +use std::ops::{Deref, DerefMut}; +use std::path::PathBuf; +use std::process::{self, Command}; + +use anyhow::{Context, Result}; +use clap::Parser; + +use crate::Zig; + +#[derive(Clone, Debug, Default, Parser)] +#[command( + display_order = 1, + after_help = "Run `cargo help doc` for more detailed information." +)] +pub struct Doc { + #[command(flatten)] + pub cargo: cargo_options::Doc, + + /// Disable zig linker + #[arg(skip)] + pub disable_zig_linker: bool, + + /// Enable zig ar + #[arg(skip)] + pub enable_zig_ar: bool, +} + +impl Doc { + /// Create a new doc from manifest path + #[allow(clippy::field_reassign_with_default)] + pub fn new(manifest_path: Option) -> Self { + let mut build = Self::default(); + build.manifest_path = manifest_path; + build + } + + /// Execute `cargo doc` command + pub fn execute(&self) -> Result<()> { + let mut run = self.build_command()?; + + let mut child = run.spawn().context("Failed to run cargo doc")?; + let status = child.wait().expect("Failed to wait on cargo doc process"); + if !status.success() { + process::exit(status.code().unwrap_or(1)); + } + Ok(()) + } + + /// Generate cargo subcommand + pub fn build_command(&self) -> Result { + let mut build = self.cargo.command(); + if !self.disable_zig_linker { + Zig::apply_command_env( + self.manifest_path.as_deref(), + self.release, + &self.cargo.common, + &mut build, + self.enable_zig_ar, + )?; + } + + Ok(build) + } +} + +impl Deref for Doc { + type Target = cargo_options::Doc; + + fn deref(&self) -> &Self::Target { + &self.cargo + } +} + +impl DerefMut for Doc { + fn deref_mut(&mut self) -> &mut Self::Target { + &mut self.cargo + } +} + +impl From for Doc { + fn from(cargo: cargo_options::Doc) -> Self { + Self { + cargo, + ..Default::default() + } + } +} diff --git a/src/lib.rs b/src/lib.rs index 72f1a88..3b2f59a 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,6 +1,7 @@ mod build; mod check; mod clippy; +mod doc; mod install; pub mod linux; pub mod macos; @@ -12,6 +13,7 @@ pub mod zig; pub use crate::clippy::Clippy; pub use build::Build; pub use check::Check; +pub use doc::Doc; pub use install::Install; pub use run::Run; pub use rustc::Rustc; From ae83cba39e208a8e7ac02e4823b135bda490525f Mon Sep 17 00:00:00 2001 From: messense Date: Sun, 17 Mar 2024 21:25:47 +0800 Subject: [PATCH 13/25] Update cargo-options to 0.7.3 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 4edc045..bd1e01e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -85,9 +85,9 @@ dependencies = [ [[package]] name = "cargo-options" -version = "0.7.2" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cad71bf996c8e5b9d28ef3472d7ee41f277edf4e38cd597f51ad0438d05d76ea" +checksum = "5de1d802cf9491e4b54941d70e45badf2f7f141d2683e4b13089af62e1027358" dependencies = [ "anstyle", "clap", diff --git a/Cargo.toml b/Cargo.toml index 28ba431..d8d7fad 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ rust-version = "1.70" [dependencies] anyhow = "1.0.53" -cargo-options = "0.7.2" +cargo-options = "0.7.3" cargo_metadata = "0.18.0" clap = { version = "4.3.0", features = ["derive", "env", "wrap_help", "unstable-styles"] } dirs = "5.0.0" From cf34c1dd492e98d49f94756f3bd59c5bda8be05f Mon Sep 17 00:00:00 2001 From: messense Date: Wed, 20 Mar 2024 19:36:12 +0800 Subject: [PATCH 14/25] Disable sccache for now --- .github/workflows/CI.yml | 4 ++-- .github/workflows/Release.yml | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 0dd3c19..7c1a1c5 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -41,8 +41,8 @@ jobs: zig: master env: RUST_BACKTRACE: "1" - SCCACHE_GHA_ENABLED: "true" - RUSTC_WRAPPER: "sccache" + # SCCACHE_GHA_ENABLED: "true" + # RUSTC_WRAPPER: "sccache" steps: - uses: actions/checkout@v4 - name: setup sccache diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index 56dda2f..efef6fc 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -22,7 +22,7 @@ jobs: uses: PyO3/maturin-action@v1 with: args: --release --out dist --strip --universal2 - sccache: 'true' + # sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -70,7 +70,7 @@ jobs: with: target: ${{ matrix.platform.target }} args: --release --out dist --strip - sccache: 'true' + # sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v4 with: @@ -123,7 +123,7 @@ jobs: manylinux: auto container: off args: --release -o dist --strip - sccache: 'true' + # sccache: 'true' - name: Upload wheels uses: actions/upload-artifact@v4 with: From 3701a408775003cf07e94d3d78b941f14a5464de Mon Sep 17 00:00:00 2001 From: messense Date: Sun, 24 Mar 2024 16:16:55 +0800 Subject: [PATCH 15/25] Filter out unsupport `-melf_i386` linker arg for i686 musl target --- src/zig.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/zig.rs b/src/zig.rs index 9fc867d..4503583 100644 --- a/src/zig.rs +++ b/src/zig.rs @@ -138,6 +138,9 @@ impl Zig { // Avoids duplicated symbols with both zig musl libc and the libc crate if arg.ends_with(".o") && arg.contains("self-contained") && arg.contains("crt") { return None; + } else if arg == "-Wl,-melf_i386" { + // unsupported linker arg: -melf_i386 + return None; } if rustc_ver.major == 1 && rustc_ver.minor < 59 From 9457dabdd3da3f1a3a708a5d9e6c39d0044a47cc Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 1 Apr 2024 19:04:52 +0800 Subject: [PATCH 16/25] Bump softprops/action-gh-release from 1 to 2 (#236) --- .github/workflows/Release.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/Release.yml b/.github/workflows/Release.yml index efef6fc..f965cbc 100644 --- a/.github/workflows/Release.yml +++ b/.github/workflows/Release.yml @@ -43,7 +43,7 @@ jobs: cd - - name: Upload binary to GitHub Release if: "startsWith(github.ref, 'refs/tags/')" - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: files: | target/release/cargo-zigbuild*.tar.gz* @@ -92,7 +92,7 @@ jobs: cd - - name: Upload binary to GitHub Release if: "startsWith(github.ref, 'refs/tags/')" - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: files: | target/${{ matrix.platform.target }}/release/cargo-zigbuild-*.zip* @@ -144,7 +144,7 @@ jobs: cd - - name: Upload binary to GitHub Release if: "startsWith(github.ref, 'refs/tags/')" - uses: softprops/action-gh-release@v1 + uses: softprops/action-gh-release@v2 with: files: | target/${{ matrix.platform.target }}/release/cargo-zigbuild*.tar.gz* From c8165c56a95624fddf5bbe7459a3847ca9d3b7ed Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 6 Apr 2024 00:27:52 +0800 Subject: [PATCH 17/25] Bump h2 from 0.3.24 to 0.3.26 in /tests/hello-rustls (#238) --- tests/hello-rustls/Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/hello-rustls/Cargo.lock b/tests/hello-rustls/Cargo.lock index 6cbfe20..d833c1e 100644 --- a/tests/hello-rustls/Cargo.lock +++ b/tests/hello-rustls/Cargo.lock @@ -157,9 +157,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.24" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", From 402ddac9e6a186e986d6478d9bca8c379d80faaa Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 6 Apr 2024 00:28:09 +0800 Subject: [PATCH 18/25] Bump h2 from 0.3.24 to 0.3.26 in /tests/hello-tls (#237) --- tests/hello-tls/Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/hello-tls/Cargo.lock b/tests/hello-tls/Cargo.lock index 11d037c..d2f76fd 100644 --- a/tests/hello-tls/Cargo.lock +++ b/tests/hello-tls/Cargo.lock @@ -182,9 +182,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.24" +version = "0.3.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2c4422095b67ee78da96fbb51a4cc413b3b25883c7717ff7ca1ab31022c9c9" +checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" dependencies = [ "bytes", "fnv", From f1a5e6ad07599877338638016fce5059206fe6a5 Mon Sep 17 00:00:00 2001 From: Wenxuan Date: Tue, 16 Apr 2024 14:27:08 +0800 Subject: [PATCH 19/25] Avoid touching wrapper files when content is unchanged (#242) Signed-off-by: Wish --- src/zig.rs | 58 +++++++++++++++++++++++++++++++++++++++--------------- 1 file changed, 42 insertions(+), 16 deletions(-) diff --git a/src/zig.rs b/src/zig.rs index 4503583..b6b73d0 100644 --- a/src/zig.rs +++ b/src/zig.rs @@ -561,7 +561,9 @@ impl Zig { fn collect_per_language_options(program: &Path, ext: &str) -> Result { // We can't use `-x c` or `-x c++` because pre-0.11 Zig doesn't handle them let empty_file_path = cache_dir().join(format!(".intentionally-empty-file.{ext}")); - fs::write(&empty_file_path, "")?; + if !empty_file_path.exists() { + fs::write(&empty_file_path, "")?; + } let output = Command::new(program) .arg("-E") @@ -821,7 +823,8 @@ impl Zig { .join("sysdeps") .join("arm") .join("arm-features.h"); - if !arm_features_h.is_file() { + let existing_content = fs::read_to_string(&arm_features_h).unwrap_or_default(); + if existing_content != ARM_FEATURES_H { fs::write(arm_features_h, ARM_FEATURES_H)?; } } @@ -889,7 +892,10 @@ set(CMAKE_RANLIB {ranlib})"#, zig_wrapper.ar.to_slash_lossy() )); } - fs::write(&toolchain_file, content)?; + let existing_content = fs::read_to_string(&toolchain_file).unwrap_or_default(); + if existing_content != content { + fs::write(&toolchain_file, content)?; + } Ok(toolchain_file) } @@ -964,7 +970,7 @@ pub struct ZigWrapper { /// /// We create different files for different args because otherwise cargo might skip recompiling even /// if the linker target changed -#[allow(clippy::blocks_in_if_conditions)] +#[allow(clippy::blocks_in_conditions)] pub fn prepare_zig_linker(target: &str) -> Result { let (rust_target, abi_suffix) = target.split_once('.').unwrap_or((target, "")); let abi_suffix = if abi_suffix.is_empty() { @@ -1102,9 +1108,15 @@ pub fn prepare_zig_linker(target: &str) -> Result { let zig_version = Zig::zig_version()?; if zig_version.major == 0 && zig_version.minor < 11 { let fcntl_map = zig_linker_dir.join("fcntl.map"); - fs::write(&fcntl_map, FCNTL_MAP)?; + let existing_content = fs::read_to_string(&fcntl_map).unwrap_or_default(); + if existing_content != FCNTL_MAP { + fs::write(&fcntl_map, FCNTL_MAP)?; + } let fcntl_h = zig_linker_dir.join("fcntl.h"); - fs::write(&fcntl_h, FCNTL_H)?; + let existing_content = fs::read_to_string(&fcntl_h).unwrap_or_default(); + if existing_content != FCNTL_H { + fs::write(&fcntl_h, FCNTL_H)?; + } write!( cc_args, @@ -1195,32 +1207,41 @@ fn symlink_wrapper(target: &Path) -> Result<()> { /// Write a zig cc wrapper batch script for unix #[cfg(target_family = "unix")] fn write_linker_wrapper(path: &Path, command: &str, args: &str) -> Result<()> { - let mut custom_linker_file = OpenOptions::new() - .create(true) - .write(true) - .truncate(true) - .mode(0o700) - .open(path)?; + let mut buf = Vec::::new(); let current_exe = if let Ok(exe) = env::var("CARGO_BIN_EXE_cargo-zigbuild") { PathBuf::from(exe) } else { env::current_exe()? }; - writeln!(&mut custom_linker_file, "#!/bin/sh")?; + writeln!(&mut buf, "#!/bin/sh")?; writeln!( - &mut custom_linker_file, + &mut buf, "exec \"{}\" zig {} -- {} \"$@\"", current_exe.display(), command, args )?; + + // Try not to write the file again if it's already the same. + // This is more friendly for cache systems like ccache, which by default + // uses mtime to determine if a recompilation is needed. + let existing_content = fs::read(path).unwrap_or_default(); + if existing_content != buf { + OpenOptions::new() + .create(true) + .write(true) + .truncate(true) + .mode(0o700) + .open(path)? + .write_all(&buf)?; + } Ok(()) } /// Write a zig cc wrapper batch script for windows #[cfg(not(target_family = "unix"))] fn write_linker_wrapper(path: &Path, command: &str, args: &str) -> Result<()> { - let mut custom_linker_file = fs::File::create(path)?; + let mut buf = Vec::::new(); let current_exe = if let Ok(exe) = env::var("CARGO_BIN_EXE_cargo-zigbuild") { PathBuf::from(exe) } else { @@ -1232,12 +1253,17 @@ fn write_linker_wrapper(path: &Path, command: &str, args: &str) -> Result<()> { current_exe.display().to_string() }; writeln!( - &mut custom_linker_file, + &mut buf, "{} zig {} -- {} %*", adjust_canonicalization(current_exe), command, args )?; + + let existing_content = fs::read(path).unwrap_or_default(); + if existing_content != buf { + fs::write(path, buf)?; + } Ok(()) } From 8a76c1dbb0c6c704af599652d99545fde2ba6719 Mon Sep 17 00:00:00 2001 From: messense Date: Tue, 16 Apr 2024 20:32:32 +0800 Subject: [PATCH 20/25] Update cargo-options to 0.7.4 --- Cargo.lock | 4 ++-- Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bd1e01e..e1d71a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -85,9 +85,9 @@ dependencies = [ [[package]] name = "cargo-options" -version = "0.7.3" +version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de1d802cf9491e4b54941d70e45badf2f7f141d2683e4b13089af62e1027358" +checksum = "f3540247c0a37a76eb324acc238dc617786ea22c43b95da560c82a8f2714321f" dependencies = [ "anstyle", "clap", diff --git a/Cargo.toml b/Cargo.toml index d8d7fad..22cc955 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -13,7 +13,7 @@ rust-version = "1.70" [dependencies] anyhow = "1.0.53" -cargo-options = "0.7.3" +cargo-options = "0.7.4" cargo_metadata = "0.18.0" clap = { version = "4.3.0", features = ["derive", "env", "wrap_help", "unstable-styles"] } dirs = "5.0.0" From 5e3810de9ab4afdd7c5c48d44466dcaabf81ea49 Mon Sep 17 00:00:00 2001 From: messense Date: Mon, 22 Apr 2024 20:51:32 +0800 Subject: [PATCH 21/25] Test zig 0.12.0 on CI --- .github/workflows/CI.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 7c1a1c5..e661835 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -33,8 +33,7 @@ jobs: matrix: os: [ubuntu-latest, macos-13, windows-latest] toolchain: [1.70.0, stable, nightly] - # Ideally we should also test against 0.9.0, but it is too unusable to test from CI - zig: [0.10.1, 0.11.0, master] + zig: [0.10.1, 0.11.0, 0.12.0, master] exclude: # Only test MSRV with zig stable version - toolchain: 1.70.0 From 0a8271a03bbabff62d7b55dded30e9c0b8f0edad Mon Sep 17 00:00:00 2001 From: messense Date: Tue, 23 Apr 2024 20:23:46 +0800 Subject: [PATCH 22/25] -D_LIBCPP_PSTL_CPU_BACKEND_SERIAL --- src/zig.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/zig.rs b/src/zig.rs index b6b73d0..d4e2336 100644 --- a/src/zig.rs +++ b/src/zig.rs @@ -721,6 +721,7 @@ impl Zig { args.push("-D_LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS".to_owned()); args.push("-D_LIBCXXABI_DISABLE_VISIBILITY_ANNOTATIONS".to_owned()); args.push("-D_LIBCPP_HAS_NO_VENDOR_AVAILABILITY_ANNOTATIONS".to_owned()); + args.push("-D_LIBCPP_PSTL_CPU_BACKEND_SERIAL".to_owned()); args.push("-D_LIBCPP_ABI_VERSION=1".to_owned()); args.push("-D_LIBCPP_ABI_NAMESPACE=__1".to_owned()); if let Some(ver) = c_opts.glibc_minor_ver { From 3608cdcfde5b81ede2973fd969aea4c6d32b58f3 Mon Sep 17 00:00:00 2001 From: messense Date: Tue, 23 Apr 2024 20:49:40 +0800 Subject: [PATCH 23/25] Skip Windows gnu tests on zig 0.12.0 --- .github/workflows/CI.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index e661835..ef89b27 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -155,6 +155,7 @@ jobs: cargo run zigbuild --target aarch64-unknown-linux-musl cargo run zigbuild --target aarch64-unknown-linux-musl --manifest-path tests/hello-rustls/Cargo.toml - name: Windows - Test gnu build + if: matrix.zig != '0.12.0' run: | cargo run zigbuild --target x86_64-pc-windows-gnu cargo run zigbuild --target x86_64-pc-windows-gnu --manifest-path tests/hello-windows/Cargo.toml @@ -165,7 +166,7 @@ jobs: run: | cargo run zigbuild --target aarch64-unknown-linux-gnu --manifest-path tests/hello-rustls/Cargo.toml --features curl - name: Windows - Test run - if: matrix.os == 'windows-latest' + if: ${{ matrix.os == 'windows-latest' && matrix.zig != '0.12.0' }} run: | ./target/x86_64-pc-windows-gnu/debug/cargo-zigbuild.exe zigbuild --help ./tests/hello-windows/target/x86_64-pc-windows-gnu/debug/hello-windows.exe From abca06124f7a0c91a84badce6df82ae98f7d0fd9 Mon Sep 17 00:00:00 2001 From: messense Date: Tue, 23 Apr 2024 20:50:30 +0800 Subject: [PATCH 24/25] Drop zig 0.11.0 tests on CI --- .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 ef89b27..20378d8 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -33,7 +33,7 @@ jobs: matrix: os: [ubuntu-latest, macos-13, windows-latest] toolchain: [1.70.0, stable, nightly] - zig: [0.10.1, 0.11.0, 0.12.0, master] + zig: [0.10.1, 0.12.0, master] exclude: # Only test MSRV with zig stable version - toolchain: 1.70.0 From 6f7e1336c9cd13cf1b3704f93c40fcf84caaed6b Mon Sep 17 00:00:00 2001 From: messense Date: Wed, 24 Apr 2024 19:05:08 +0800 Subject: [PATCH 25/25] Bump version to 0.18.4 --- Cargo.lock | 2 +- Cargo.toml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index e1d71a7..5d073be 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -104,7 +104,7 @@ dependencies = [ [[package]] name = "cargo-zigbuild" -version = "0.18.3" +version = "0.18.4" dependencies = [ "anyhow", "cargo-options", diff --git a/Cargo.toml b/Cargo.toml index 22cc955..0ca8933 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-zigbuild" -version = "0.18.3" +version = "0.18.4" edition = "2021" description = "Compile Cargo project with zig as linker" license = "MIT"