SwiftWinRT icon indicating copy to clipboard operation
SwiftWinRT copied to clipboard

Too big

Open ericsink opened this issue 2 years ago • 3 comments

The generator has an ugly config setting where I can declare which methods I want to call, and it outputs only those methods plus anything they require. Currently, the config is setup to include everything needed by the 3 samples here, and not much else.

The reason why is because if I generate the entire WinRT API surface, swift build cannot cope with it because of the size.

One problem is that the resulting library exceeds the Windows limit of 65535 exported symbols.

Another issue is that if I break things up into one file per namespace, the resulting swiftc invocation exceeds the 32KB limit for a command line, and if I put everything in one file, the build takes a lot longer. Like, hours.

Currently, the input to the generator is the Windows.winmd file found in the UnionMetadata directory of the Windows SDK.

It is challenging to find a clean way to break things up into pieces. Constraining things by namespace reveals circular dependencies.

The Rust/WinRT project uses #ifdefs (actually "features", the Rust equivalent of same) to constrain the build.

ericsink avatar May 17 '22 21:05 ericsink

I'm in the process of tooling my way out of the "it's too big" problem for Rust because if you think the WinRT API surface is big you should see the Win32 metadata. 😄

https://github.com/microsoft/windows-rs/tree/master/crates/libs/metadata/default

Obviously, the trick is building islands without circular references...

kennykerr avatar May 24 '22 03:05 kennykerr

Ha. Yeah, the Win32 metadata would make things a lot bigger, wouldn't it?

I've got code that calculates a full dependency graph, determining what types are needed for every method signature. I use that in various ways to try to keep things from getting Too Big.

But I keep thinking I could use the dep graph to write some kind of algorithm to automatically find that optimally small set of "islands without circular references". :-)

ericsink avatar May 24 '22 14:05 ericsink

@kennykerr - interesting. That is definitely going to be important I think - I am actually more interested in using the Win32 metadata rather than just the WinRT metadata. I am hoping that I can use some analysis of the usage to create the island so that it does not need to be a logical island but rather a practical island that is use driven.

compnerd avatar Jun 19 '22 19:06 compnerd