From 39faad283d48b28becb25b223b6562897a08e10c Mon Sep 17 00:00:00 2001 From: messense Date: Wed, 18 Sep 2024 22:43:33 +0800 Subject: [PATCH] Filter out `-lmsvcrt` for Windows gnu targets (#274) * Replace `-lmsvcrt` with `-lmsvcrt-os` for Windows gnu targets * Remove `-lmsvcrt` * Skip windows gnu on zig 0.13 --- .github/workflows/CI.yml | 4 +++- src/zig.rs | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/.github/workflows/CI.yml b/.github/workflows/CI.yml index 588338e..70a06a1 100644 --- a/.github/workflows/CI.yml +++ b/.github/workflows/CI.yml @@ -192,6 +192,8 @@ 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 + # We are having trouble building with zig 0.13 + if: ${{ matrix.zig == '0.10.1' }} 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 @@ -202,7 +204,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.10.1' }} 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 diff --git a/src/zig.rs b/src/zig.rs index 92c93e4..81eb36b 100644 --- a/src/zig.rs +++ b/src/zig.rs @@ -135,6 +135,8 @@ impl Zig { // https://github.com/rust-lang/rust/blob/f0bc76ac41a0a832c9ee621e31aaf1f515d3d6a5/compiler/rustc_target/src/spec/i686_pc_windows_gnu.rs#L16 // zig doesn't support --disable-auto-image-base, --dynamicbase and --large-address-aware return None; + } else if arg == "-lmsvcrt" { + return None; } } else if arg == "-Wl,--no-undefined-version" { // https://github.com/rust-lang/rust/blob/542ed2bf72b232b245ece058fc11aebb1ca507d7/compiler/rustc_codegen_ssa/src/back/linker.rs#L723