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
Reducing the size of the import library crates #1964
Comments
Yeah, that will work as long as nothing CRT specific lands in import libs.
One of LLVM devs (Martin Storsjö) has WIP patch for LLVM to generate legacy import lib format (the one used by Binutils and ancient MSVC versions) but it has collected some dust. I wanted to rebase it but couldn't find time and motivation. |
This is a known issue, fix is coming via upstream win32metadata microsoft/win32metadata#1023. |
So my intention was to keep the binutils and LLVM worlds explicitly separate and use only the tools native to those worlds. LLVM does not provide any guarantees (that I could find) that its compatibility of bintools artifacts is something it cares about and vice versa. So this usage of LLVM tooling to generate artifacts for various non-LLVM-native targets (on a "welp, it should work" basis) concerns me about the possible increase in crate fragility. I'm also concerned that tooling for msvc may outpace LLVM and our reliance on LLVM hobble us in the future. Q: Do you think my worries are unwarranted?
Sounds good.
Q: Are you referring to the need to fire up separate 32-bit and 64-bit environments for lib generation?
Suspect this requires LLVM, which touches on my worries above.
Suspect this requires LLVM, which touches on my worries above. |
@dpaoliello has made tremendous progress on |
I'd also like to hear from @mati865 who added the new gnu targets. |
Ah I see @mati865 is already on this issue. Never mind. 😊 |
What's the consensus on #1961 and the remaining issues here? Do folks want to merge these targets or leave them alone until |
If somebody can confirm there are no CRT specific differences (in other words: they do not pull other import libraries from SDK/mingw-w64 during creation) between import libraries of these two targets then I wouldn't mind if they were merged into one. |
As long as by merge we mean using the much smaller llvm libs. 😁 |
So at this point, here is what I have in private branches:
I don't think any of these differences above matter when linking the import libraries. Ultimately, I think even with raw-dylib on the way to stabilization, it is not going to be desirable to rely on it unconditionally because of the impact on the minimum supported rust version, so I think it would be desirable to still reduce the overall size of the import library crates. The *_gnu ones were reduced in size in #1968 and could be reduced a little further with a dlltool command line tweak. The *_gnullvm ones could be used to replace the *_msvc ones. All of them could actually be generated at build time from ~1000 slocs + a list of dlls/symbols that should be in the ballpark of 500K uncompressed. |
Oh, forgot to mention in the list of differences: LLVM sets all the ordinal/hints to 0. |
I refreshed the commits mentioned in #1964 (comment) with rebased versions on top of current master, but they will obviously need another refresh after next metadata update. Anyways, thoughts, @riverar, @kennykerr? |
Sounds good to me. I'm hoping to get another Win32 metadata update in the next day or two and would like to then publish another release of the |
I was also thinking of adding an umbrella |
And just keep in mind that I need @riverar to sign off or direct as needed as he's been driving the non-msvc lib support. I think there are still some concerns about non-standard tooling etc. |
Lets go for it @glandium. 👍 Happy to help test along the way. Start with the first three non-WIP branches perhaps? |
Anything left to do here? |
Closing for now. Feel free to keep the conversation going if there's more to discuss. |
(This issue is focused on import libraries, but I'll also open issues about other size aspects for in the coming days.)
Vendoring crates with large amounts of data is costly. More so when semver incompatible versions are released often and different crates in the ecosystem use different versions.
The first and most obvious issue is that the version for the import libraries should be separate from that of the other crates. There hasn't been changes to the
crates/targets/*/lib
files since 0.36.0, yet, there have been 0.37.0, 0.38.0, 0.39.0 since then. Even if there had been changes, semver compatible versions would have been fine. I would suggest decoupling the versions and to publish 0.36.2, 0.37.1 and 0.38.1 "dummy" versions that depend on 0.39.0.The second issue is the multiplication of crates for new targets, when they are not strictly necessary (especially in the context of what's coming below). This is addressed in #1961.
A third issue is that depending on the tooling used, the import library size can vary (for instance, if I run the tool_gnu crate right now, I somewhat end up with smaller import libraries). Relatedly, even if the same size is produced, the content is different because of timestamps within the libraries.
The remaining issue is that of the size of the import libraries themselves.
My proposed plan of action is the following (I have working patches for those, although they need some cleanup and proper commit messages):
raw-dylib
support is doing already.It's possible to make the LLVM variants something like <100K lighter (IIRC), but that makes MSVC not work with them, so I don't think it's worth bothering having separate crates for that small of a difference.
BTW, while digging in the import libs, I found that the opposite problem of #1447 exists for libraries like windows.data.pdf (all libraries with a period in their name). Fixing it ends up being easier after the work above.
Further down the road, I'm planning to submit code to LLVM to produce MINGw-style import libraries (i.e. not using the short import form), incidentally, it should produce files about ~3MB smaller each if my math is right. (This will also allow rustc's raw-dylib support to stop requiring MINGw binutils).
Eventually, I assume the goal would be for windows/windows-sys to use raw-dylib, removing the need for the import library crates entirely, but the crates will still be desirable to have around for compatibility with older (now current) versions of the rust compiler for some while. I think at that point it would be desirable to replace those crates with code that generates the import libraries on demand when the compiler version is older than the one that stabilizes raw-dylibs (which seems it might be 1.65.0?). I have some sketch code that produces MINGw-style objects already, producing the full import libraries would not be much more effort code-wise, and would be fast.
The text was updated successfully, but these errors were encountered: