-
Notifications
You must be signed in to change notification settings - Fork 564
Split up and add headerFilters to windows.def #3483
Comments
Well, sure win32 API is a mess.
What shoud be included in |
For the short-term solution, include anything that is satisified with the existing linker flags:
That way we shouldn't break anyone who is using this. I'm not familiar enough with Windows native stuff to figure out a programatic way to determine this. I've worked out a few libraries by hand:
|
I have even Shorter-term solution: seems that your sentence that "links to platform libraries that are not needed by all users, adding unnecessary bloat to their Windows binaries." is wrong, unused libs are eliminated from final binary, at least on MinGW. So I did grep for missed libs, and found (here on each line are missed lib and one function from it):
|
Did PR: #3502 |
Thanks. I've since partially worked around this for The trick was redeclaring everything with a different prefix, and having a mapping file which pointed to things in I think it's a good idea to put all these Windows headers in their own namespace -- some names are on other platforms (like WinSCard!) and there are subtle differences to trip over. I don't feel good about including all Win32 API headers from |
And who will test if it works? It should, if not, and someone finds a bug - this issue tracker is exactly for that. |
I'm building Kotlin bindings for the PC/SC API (aka
winscard
) that are multiplatform (I plan to release this library as open sourceedit: this is now released). I've got this working for JNA (on JVM), Linux and macOS; but have many difficulties trying to get this working right on Windows Native, and the reason is windows.def.At present, windows.def includes
windows.h
, and tries to link against a basket of different libraries:kotlin-native/platformLibs/src/platform/mingw/windows.def
Line 6 in e21ab4f
Unfortunately,
windows.h
includes pretty much every Windows platform API header, and there have been noheaderFilters
set forwindows.def
.As a result:
Any Windows library needs to be added to this file to be usable (example patch), even when transitively included in
windows.h
, or hacks like Dwmapi.dll is not linked #3135 need to be added.The generated bindings don't have complete coverage on
noStringConversion
-- any function call which passes a multistring won't work properly (eg:SCardListReaders
).Anyone who tries to add their own platform definition that includes something from
windows.h
will have Kotlin Multiplatform tools silently drop those declarations. This is incredibly frustrating to debug.This links to platform libraries that are not needed by all users, adding unnecessary bloat to their Windows binaries.
What I think is needed to solve this:
Short-term: Add explicit
headerFilters
to exclude everything that gets transitively included fromwindows.h
. That way, at least developers can provide their own bindings to Windows APIs.Long-term: Split up Windows platform libraries, much like the macOS platform bindings already do; so you'd have
dwmapi.def
,comctl32.def
,winscard.def
, etc. which map intoplatform.windows.dwmapi.*
,platform.windows.comctl32.*
andplatform.windows.winscard.*
respectively.The text was updated successfully, but these errors were encountered: