ziglang / zig

General-purpose programming language and toolchain for maintaining robust, optimal, and reusable software.
https://ziglang.org
MIT License
34.79k stars 2.54k forks source link

zig windres #9564

Open Akuli opened 3 years ago

Akuli commented 3 years ago

It would be really nice if zig exposed zig windres in addition to zig cc. This was previously mentioned in https://github.com/ziglang/zig/issues/7917#issuecomment-808087114

For context, I have now spent a couple days trying to get a very small C program to compile on Windows, and I have ran into all kinds of weird problems. It would be awesome to just download a small self-contained thing and use it.

jagt commented 2 years ago

I took a look at zig ar integration. It basically integrates llvm llvm-ar.cpp as src/zig_llvm-ar.cpp with a few changes.

When it comes to windress which is llvm-rc tool in llvm code base. It involves multiple files and tablegen.

The options I can think of:

  1. Integrate all files under llvm-rc into zig/src. It still need tablegen for building, so we'll choose between integrate tablegen or integrate a preprocessed code copy.
  2. Same as above but put everything under zig/deps.

I'm not sure how zig_llvm-ar.cpp is upgraded when updating to newer LLVM releases. We'll need to do the same thing to windres.

andrewrk commented 1 year ago

This must be implemented in Zig rather than by adding an additional dependency on LLVM/Clang.

akavel commented 1 year ago

Is this a duplicate of #3702? Or are those two issues in any way different?

squeek502 commented 1 year ago

Is this a duplicate of https://github.com/ziglang/zig/issues/3702? Or are those two issues in any way different?

This is not a duplicate, though it does depend on #3702.

https://github.com/ziglang/zig/pull/17069 will address #3702 but it will not close this since it doesn't add a zig cc-like command. It shouldn't be too hard to add one once it's merged, though.

squeek502 commented 1 year ago

Note: this was added as zig rc rather than zig windres since it's drop-in compatible with rc.exe, not windres.

alexrp commented 6 months ago

Note: this was added as zig rc rather than zig windres since it's drop-in compatible with rc.exe, not windres.

Then shouldn't this be reopened? This issue's ask seems to be for a windres-compatible interface, while #3702 seems more general.

The lack of a windres-compatible interface means that it's still quite awkward to integrate Zig into Linux -> Windows C/C++ cross-compilation where resource files are involved. Most build systems seem to expect windres, not rc, in that scenario.

alexrp commented 2 weeks ago

Per Zulip discussion (this message in particular), reopening this to track adding partial / best-effort windres compatibility. It won't be 100%, but I believe CLI compatibility + COFF support should help with the CMake + MinGW use case.