Closed GlennFolker closed 1 year ago
I'm on a x86_64 Windows 10 machine trying to cross-compile my project to i686-pc-windows-gnu, but I get compile errors about unsupported linker args:
i686-pc-windows-gnu
cargo new my_crate cd my_crate cargo zigbuild --target i686-pc-windows-gnu Compiling my_crate v0.1.0 (C:\Users\Glenn\my_crate) error: linking with `C:\Users\Glenn\AppData\Local\cargo-zigbuild\0.16.2\zigcc-i686-pc-windows-gnu.bat` failed: exit code: 1 | = note: "cmd" "/c" "C:\\Users\\Glenn\\AppData\\Local\\cargo-zigbuild\\0.16.2\\zigcc-i686-pc-windows-gnu.bat" "-fno-use-linker-plugin" "-Wl,--dynamicbase" "-Wl,--disable-auto-image-base" "-Wl,--large-address-aware" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\rsbegin.o" "C:\\Users\\Glenn\\AppData\\Local\\Temp\\rustcDxHFJE\\symbols.o" "C:\\Users\\Glenn\\my_crate\\target\\i686-pc-windows-gnu\\debug\\deps\\my_crate-9004880e2a79c5c4.23lyyn0sndxnhybz.rcgu.o" "C:\\Users\\Glenn\\my_crate\\target\\i686-pc-windows-gnu\\debug\\deps\\my_crate-9004880e2a79c5c4.2nz5un9808a2dnge.rcgu.o" "C:\\Users\\Glenn\\my_crate\\target\\i686-pc-windows-gnu\\debug\\deps\\my_crate-9004880e2a79c5c4.2vq162wxuck5t53z.rcgu.o" "C:\\Users\\Glenn\\my_crate\\target\\i686-pc-windows-gnu\\debug\\deps\\my_crate-9004880e2a79c5c4.3xxntam8vkgyxcie.rcgu.o" "C:\\Users\\Glenn\\my_crate\\target\\i686-pc-windows-gnu\\debug\\deps\\my_crate-9004880e2a79c5c4.4tpb0d7omiqeb91y.rcgu.o" "C:\\Users\\Glenn\\my_crate\\target\\i686-pc-windows-gnu\\debug\\deps\\my_crate-9004880e2a79c5c4.55yr7govwo7idip.rcgu.o" "C:\\Users\\Glenn\\my_crate\\target\\i686-pc-windows-gnu\\debug\\deps\\my_crate-9004880e2a79c5c4.56jm7u0zmuzr2gq5.rcgu.o" "-L" "C:\\Users\\Glenn\\my_crate\\target\\i686-pc-windows-gnu\\debug\\deps" "-L" "C:\\Users\\Glenn\\my_crate\\target\\debug\\deps" "-L" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib" "-Wl,-Bstatic" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libstd-d88d969107e34835.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libpanic_unwind-7aea2d1ea53846da.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libobject-af1b81a8c2bced70.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libmemchr-a52acfeeeefbd002.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libaddr2line-259ae2238b7d7222.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libgimli-7c39f9becff746f3.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\librustc_demangle-39a14a0f9e5e3818.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libstd_detect-2f23f88d8eeb7c82.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libhashbrown-b09f7cfe8cde02a9.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libminiz_oxide-adf995cf93b93e9a.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libadler-f53887c1cc202bae.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\librustc_std_workspace_alloc-2b99a7c985d9ef87.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libunwind-7c7024dd15865d7d.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libcfg_if-a01d1a776286560f.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\liblibc-dd91bcb0fea09a87.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\liballoc-f271d1841ad4086c.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\librustc_std_workspace_core-5e6258b1c24f2e94.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libcore-e8cbede5689dc631.rlib" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\libcompiler_builtins-285d1926e3c40c9c.rlib" "-Wl,-Bdynamic" "-lkernel32" "-ladvapi32" "-luserenv" "-lkernel32" "-lws2_32" "-lbcrypt" "-lgcc_eh" "-l:libpthread.a" "-lmsvcrt" "-lmingwex" "-lmingw32" "-lgcc" "-lmsvcrt" "-luser32" "-lkernel32" "-Wl,--nxcompat" "-L" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib" "-o" "C:\\Users\\Glenn\\my_crate\\target\\i686-pc-windows-gnu\\debug\\deps\\my_crate-9004880e2a79c5c4.exe" "-Wl,--gc-sections" "-no-pie" "-nodefaultlibs" "C:\\Users\\Glenn\\.rustup\\toolchains\\nightly-x86_64-pc-windows-gnu\\lib\\rustlib\\i686-pc-windows-gnu\\lib\\rsend.o" = note: error: unsupported linker arg: --large-address-aware
Looking at the zigcc-i686-pc-windows-gnu.bat file that seems to be generated by cargo-zigbuild:
zigcc-i686-pc-windows-gnu.bat
cargo-zigbuild
C:\Users\Glenn\.cargo\bin\cargo-zigbuild.exe zig cc -- -target i386-windows-gnu -g %*
Looks like not only that the script doesn't filter out unsupported arguments, it also provides incorrect target triplet:
> zig cc hi.c -o hi.exe -target i386-windows-gnu error: UnknownArchitecture
The correct triplet should be x86-windows-gnu:
x86-windows-gnu
> zig cc hi.c -o hi.exe -target x86-windows-gnu > hi Hello, world!
Possibly relevant information:
> zig version 0.11.0-dev.1812+26196be34 > zig cc --version clang version 15.0.7 (https://github.com/ziglang/zig-bootstrap a836b63c1ae8e734a0f94cc4031610adfb4bedf7) Target: x86_64-unknown-windows-gnu Thread model: posix InstalledDir: C:/Users/Glenn > cargo-zigbuild --version cargo-zigbuild 0.16.2 > rustc --version rustc 1.69.0-nightly (34e6673a0 2023-02-25)
It seems that this only occurs in Zig 0.11.0; I installed Zig 0.10.1 (the version I found in the CI) and everything works fine. It's still an issue though.
I'm on a x86_64 Windows 10 machine trying to cross-compile my project to
i686-pc-windows-gnu
, but I get compile errors about unsupported linker args:Looking at the
zigcc-i686-pc-windows-gnu.bat
file that seems to be generated bycargo-zigbuild
:Looks like not only that the script doesn't filter out unsupported arguments, it also provides incorrect target triplet:
The correct triplet should be
x86-windows-gnu
:Possibly relevant information: