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

ship .idl files rather than .h files for windows SDK #18477

Open
andrewrk opened this issue Jan 7, 2024 · 9 comments
Open

ship .idl files rather than .h files for windows SDK #18477

andrewrk opened this issue Jan 7, 2024 · 9 comments
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. enhancement Solving this issue will likely involve adding new logic or components to the codebase. optimization os-windows
Milestone

Comments

@andrewrk
Copy link
Member

andrewrk commented Jan 7, 2024

This is a toolchain installation size optimization.

Many of the C header files Zig ships that come from mingw-w64 have this header:

/*** Autogenerated by WIDL 8.5 from include/xpsrassvc.idl - Do not edit ***/

If we compare total file sizes, it comes out to roughly 40 MiB reduced to 10 MiB:

[nix-shell:~/Downloads/mingw-w64/mingw-w64-headers]$ cat $(find -name "*.idl") | wc -c
10436832

[nix-shell:~/Downloads/mingw-w64/mingw-w64-headers]$ cat $(grep -RIl "Autogenerated by WIDL") | wc -c
41764448

In terms of tarball size it's roughly 2.4 MiB to 724 KB:

[nix-shell:~/Downloads/mingw-w64/mingw-w64-headers]$ cat $(find -name "*.idl") | xz | wc -c
740960

[nix-shell:~/Downloads/mingw-w64/mingw-w64-headers]$ cat $(grep -RIl "Autogenerated by WIDL") | xz | wc -c
2490188

A prerequisite for this issue would be a WIDL implementation in Zig. That could be a fun project for a contributor.

@andrewrk andrewrk added enhancement Solving this issue will likely involve adding new logic or components to the codebase. contributor friendly This issue is limited in scope and/or knowledge of Zig internals. optimization os-windows labels Jan 7, 2024
@andrewrk andrewrk added this to the 0.15.0 milestone Jan 7, 2024
andrewrk added a commit that referenced this issue Jan 8, 2024
Upstream commit dddccbc3ef50ac52bf00723fd2f68d98140aab80

Martin Storsjö suggested synchronizing with git snapshots rather than
waiting for tagged releases. Let's try this for a few releases of Zig
and see how we like it.

These headers were configured with `--with-default-msvcrt=ucrt`.

See related issue #18477.
andrewrk added a commit that referenced this issue Jan 8, 2024
Upstream commit dddccbc3ef50ac52bf00723fd2f68d98140aab80

Martin Storsjö suggested synchronizing with git snapshots rather than
waiting for tagged releases. Let's try this for a few releases of Zig
and see how we like it.

These headers were configured with `--with-default-msvcrt=ucrt`.

See related issue #18477.
andrewrk added a commit that referenced this issue Jan 8, 2024
Upstream commit dddccbc3ef50ac52bf00723fd2f68d98140aab80

Martin Storsjö suggested synchronizing with git snapshots rather than
waiting for tagged releases. Let's try this for a few releases of Zig
and see how we like it.

These headers were configured with `--with-default-msvcrt=ucrt`.

See related issue #18477.
@odecaux
Copy link

odecaux commented Jan 15, 2024

Exposing such a parser to the user would enable generating bindings to the COM and WinRT APIs.

@nektro
Copy link
Contributor

nektro commented Jan 15, 2024

is this the same IDL that's https://webidl.spec.whatwg.org ?

edit: hmm there are similarities but I think its different
https://android.googlesource.com/toolchain/mingw/+/refs/heads/main/mingw-w64-v6.x/mingw-w64-headers/include/xpsrassvc.idl

@Paul-Dempsey
Copy link

Microsoft Windows IDL: https://learn.microsoft.com/en-us/uwp/midl-3/

@andrewrk
Copy link
Member Author

Wine has an implementation you can look at. There's also one in mingw-w64 which may or may not just be the code ported from Wine.

@harrylaulau

This comment has been minimized.

bilaliscarioth pushed a commit to bilaliscarioth/zig that referenced this issue Jan 27, 2024
Upstream commit dddccbc3ef50ac52bf00723fd2f68d98140aab80

Martin Storsjö suggested synchronizing with git snapshots rather than
waiting for tagged releases. Let's try this for a few releases of Zig
and see how we like it.

These headers were configured with `--with-default-msvcrt=ucrt`.

See related issue ziglang#18477.
@xinlifoobar
Copy link

Do you suggest using the wine implementation, e.g. zig with cpp bindings, or pure zig solution? I'm interested in the latter.

@andrewrk
Copy link
Member Author

andrewrk commented Feb 9, 2024

Pure zig solution, obviously :-)

@sno2
Copy link
Contributor

sno2 commented Jul 20, 2024

Is the status of this issue changed by #16269 (comment)?

@NyuB
Copy link

NyuB commented Jan 12, 2025

I would be interested in having a look at this, could you clarify the intended outcome, what options are you considering for this widl integration ?

  • No language change:
    • translate the distributed .idl files to .h files once at first usage, which will reduce the distributed tarball size but not the installed files
  • A builtin command similar or within @cImport like @idlImport("stuff.idl"), and this could either
    • produce C header content from the IDL file on the fly then feed them to the existing @cImport mecanism
    • directly produce Zig's ast nodes from the IDL without the above indirection
  • Something else ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor friendly This issue is limited in scope and/or knowledge of Zig internals. enhancement Solving this issue will likely involve adding new logic or components to the codebase. optimization os-windows
Projects
None yet
Development

No branches or pull requests

8 participants