Repository: rust-cross/cargo-zigbuild (language: python)

Issue:
An error occured when I try to build for `x86_64-pc-windows-gnu` platform with Mac M1
An error occured when I try to build for `x86_64-pc-windows-gnu` platform with Mac M1.

The error,
```
warning: unsupported linker arg: /var/folders/z1/tj3rwht518jgd4f89573gph40000gn/T/rustcaeAJFU/list.def
          error(link): DLL import library for -lsynchronization not found
          error: DllImportLibraryNotFound
```


Discussion / hints:
zig doesn't ship import library for `synchronization`, you should report it to [zig](https://github.com/ziglang/zig/issues) instead.

```bash
$ cat hello.c
#include <stdio.h>

int main(void) {
  printf("hello");
  return 0;
}

$ zig cc hello.c -o hello -target x86_64-windows-gnu -lsynchronization
LLD Link... error(link): DLL import library for -lsynchronization not found
error: DllImportLibraryNotFound
```

Fix patch:
diff --git a/src/zig.rs b/src/zig.rs
index af6cf6e..a32f885 100644
--- a/src/zig.rs
+++ b/src/zig.rs
@@ -526,6 +526,16 @@ impl Zig {
                         fs::write(arm_features_h, ARM_FEATURES_H)?;
                     }
                 }
+            } else if target.contains("windows-gnu") {
+                if let Ok(lib_dir) = Zig::lib_dir() {
+                    let lib_common = lib_dir.join("libc").join("mingw").join("lib-common");
+                    let synchronization_def = lib_common.join("synchronization.def");
+                    if !synchronization_def.is_file() {
+                        let api_ms_win_core_synch_l1_2_0_def =
+                            lib_common.join("api-ms-win-core-synch-l1-2-0.def");
+                        fs::copy(api_ms_win_core_synch_l1_2_0_def, synchronization_def)?;
+                    }
+                }
             }
         }
         Ok(())


Test patch:
diff --git a/tests/hello-windows/Cargo.lock b/tests/hello-windows/Cargo.lock
index dc78adb..d31b852 100644
--- a/tests/hello-windows/Cargo.lock
+++ b/tests/hello-windows/Cargo.lock
@@ -34,9 +34,18 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
 
 [[package]]
 name = "windows-sys"
-version = "0.42.0"
+version = "0.45.0"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7"
+checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0"
+dependencies = [
+ "windows-targets",
+]
+
+[[package]]
+name = "windows-targets"
+version = "0.42.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071"
 dependencies = [
  "windows_aarch64_gnullvm",
  "windows_aarch64_msvc",
@@ -49,42 +58,42 @@ dependencies = [
 
 [[package]]
 name = "windows_aarch64_gnullvm"
-version = "0.42.1"
+version = "0.42.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "8c9864e83243fdec7fc9c5444389dcbbfd258f745e7853198f365e3c4968a608"
+checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8"
 
 [[package]]
 name = "windows_aarch64_msvc"
-version = "0.42.1"
+version = "0.42.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "4c8b1b673ffc16c47a9ff48570a9d85e25d265735c503681332589af6253c6c7"
+checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43"
 
 [[package]]
 name = "windows_i686_gnu"
-version = "0.42.1"
+version = "0.42.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "de3887528ad530ba7bdbb1faa8275ec7a1155a45ffa57c37993960277145d640"
+checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f"
 
 [[package]]
 name = "windows_i686_msvc"
-version = "0.42.1"
+version = "0.42.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "bf4d1122317eddd6ff351aa852118a2418ad4214e6613a50e0191f7004372605"
+checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060"
 
 [[package]]
 name = "windows_x86_64_gnu"
-version = "0.42.1"
+version = "0.42.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "c1040f221285e17ebccbc2591ffdc2d44ee1f9186324dd3e84e99ac68d699c45"
+checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36"
 
 [[package]]
 name = "windows_x86_64_gnullvm"
-version = "0.42.1"
+version = "0.42.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "628bfdf232daa22b0d64fdb62b09fcc36bb01f05a3939e20ab73aaf9470d0463"
+checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3"
 
 [[package]]
 name = "windows_x86_64_msvc"
-version = "0.42.1"
+version = "0.42.2"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "447660ad36a13288b1db4d4248e857b510e8c3a225c822ba4fb748c0aafecffd"
+checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0"
diff --git a/tests/hello-windows/Cargo.toml b/tests/hello-windows/Cargo.toml
index 394c168..61e69bc 100644
--- a/tests/hello-windows/Cargo.toml
+++ b/tests/hello-windows/Cargo.toml
@@ -7,4 +7,4 @@ edition = "2018"
 
 [dependencies]
 winapi = { version = "0.3.9", features = ["sysinfoapi"] }
-windows-sys = { version = "0.42.0", features = ["Win32_System_SystemInformation"] }
+windows-sys = { version = "0.45.0", features = ["Win32_System_SystemInformation"] }
diff --git a/tests/hello-windows/build.rs b/tests/hello-windows/build.rs
new file mode 100644
index 0000000..81aa7f3
--- /dev/null
+++ b/tests/hello-windows/build.rs
@@ -0,0 +1,3 @@
+fn main() {
+    println!("cargo:rustc-link-lib=synchronization");
+}