Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate cargo-xwin for cross compiling to Windows MSVC targets #919

Merged
merged 4 commits into from
May 16, 2022

Conversation

messense
Copy link
Member

Closes #830

@netlify
Copy link

netlify bot commented May 15, 2022

Deploy Preview for maturin-guide canceled.

Name Link
🔨 Latest commit 69246ff
🔍 Latest deploy log https://app.netlify.com/sites/maturin-guide/deploys/6281b7922d47a800091a285e

@messense
Copy link
Member Author

cc @ravenexp

@messense
Copy link
Member Author

messense commented May 15, 2022

Continuing from rust-cross/cargo-zigbuild#36 (comment).

I think zig dlltool is same as llvm-dlltool and they are not compatible with mingw64's dlltool, thus use zig dlltool for windows gnu targets isn't possible? @ravenexp

@ravenexp
Copy link
Contributor

It depends on what linker zig cc uses for its MinGW targets. I think Zig always links with lld, which uses the Windows import library format, same as LINK.EXE. MinGW-format import libraries are only suitable when x86_64-w64-mingw32-gcc is used as the linker.

@messense messense marked this pull request as ready for review May 15, 2022 10:05
@ravenexp
Copy link
Contributor

ravenexp commented May 15, 2022

It depends on what linker zig cc uses for its MinGW targets. I think Zig always links with lld, which uses the Windows import library format, same as LINK.EXE.

I checked this directly just to be sure, and zig cc indeed uses lld-link when compiling for -target x86_64-windows-gnu:

$ zig cc -v -target x86_64-windows-gnu test.c

--skip--
lld-link -ERRORLIMIT:0 -NOLOGO -STACK:16777216 -MACHINE:X64 -OUT:/x/.cache/zig/o/d5879460d6961e986517a114b13aaef2/a.exe -IMPLIB:/x/.cache/zig/o/d5879460d6961e986517a114b13aaef2/test.lib`

This means dlltool from MinGW binutils can not be used with cargo zigbuild and maturin --zig.

Using zig dlltool with zig cc is indeed the only correct option.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Better support for cross compiling to Windows
2 participants