Skip to content

Use zig rc compiler when building with zig as linker#47

Open
bplaat wants to merge 2 commits intoBenjaminRi:masterfrom
bplaat:zig-rc
Open

Use zig rc compiler when building with zig as linker#47
bplaat wants to merge 2 commits intoBenjaminRi:masterfrom
bplaat:zig-rc

Conversation

@bplaat
Copy link

@bplaat bplaat commented Jan 22, 2026

@BenjaminRi thanks for keeping the "winres" crate up-to-date in this fork.

This rough pr adds support for building Windows resources using Zig as a cross-compilation toolchain. This can easily be done with cargo-zigbuild:

cargo zigbuild --target x86_64-pc-windows-gnu

Zig has included a Windows resource compiler for some time now (see: https://www.ryanliptak.com/blog/zig-is-a-windows-resource-compiler/), which is handy because it removes the need to install a full MinGW64 toolchain locally. The zig rc command is intended to be fully compatible with rc.exe, so I extended the compile_with_toolkit_msvc() function to support it.

The linking is still done against the GNU MinGW C runtime, which makes the current structure a bit confusing maybe. It might make sense to split this functionality into a separate function for clarity.

Looking forward to feedback :^)

@BenjaminRi
Copy link
Owner

Hi, thank you for your contribution. That the zig toolchain can be integrated with cargo is news to me, that sounds very cool!

The linking is still done against the GNU MinGW C runtime

Is it really when you end up in compile_with_toolkit_msvc()? Because that would be the MSCV toolchain, not the GNU one, right?

I will probably need some time to read up on this and think about it. In particular, when you compile on Linux for Windows, or on Windows (MSVC or GNU) for Windows, etc. There are various combinations and if we start supporting this, it is good to broadly know what we are working with.

It would also be good to update CI to test these cases then as well, so that we don't break it once we start supporting it. But generally, I am not opposed to this at all, if it helps users of the library. What is your use-case specifically, what OS are you developing on?

@bplaat
Copy link
Author

bplaat commented Jan 26, 2026

Is it really when you end up in compile_with_toolkit_msvc()? Because that would be the MSCV toolchain, not the GNU one, right?

No zig always links against a self bundeld source version of MinGW libc. The zig rc cli interface is almost 100% compatible with rc.exe so that's the reason I use the compile_with_toolkit_msvc() code path.

It would also be good to update CI to test these cases then as well

Good point, I'll update this pr with an GitHub Action job that tests the use of the zig toolchain.

@BenjaminRi could you approve action runs for my user?

What is your use-case specifically, what OS are you developing on?

Mostly cross-compiling Windows binaries from macOS desktop and Linux CI runners.

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.

2 participants