Wine Source build on native wchar_t 4 bytes

Eric Pouech eric.pouech at orange.fr
Wed May 4 07:01:28 CDT 2022


Le 04/05/2022 à 11:10, Mahin Pandya a écrit :
>
> Hi Eric,
>
> Here is what we are trying to do:
>
> - do you want that all places where WCHAR is used (meaning utf16) is 
> replaced by utf32 encoding?
>
> Yes, all usage would be utf-32
>
> - do you want applications compiled in current WCHAR=2 bytes 
> (including native windows applications) and applications with your 
> WCHAR=4 bytes run in the same wine instance?
>
> This would be WCHAR=4 bytes only. Native Windows Applications do not 
> need to be supported.
>
> - cross compiling or simply compiling ?
>
> No cross-compilation. Currently planning to compile/build under Linux 
> only.
>
> and perhaps to start with, why is current utf16 encoding not sufficient?
>
> We are trying to build Windows application using Wine Lib as native 
> application (i.e. winelib https://wiki.winehq.org/Winelib 
> <https://wiki.winehq.org/Winelib> / 
> https://wiki.winehq.org/Winelib_User%27s_Guide 
> <https://wiki.winehq.org/Winelib_User%27s_Guide> rather than wine to 
> run Windows binaries). So that we can use other glibc functionality as 
> well that use and expect native wchar_t sizes.
>
Hi Mahin,

as you may have noted (that's surely the case as you were looking for 
recompiling Wine with WCHAR=glibc.wchar_t), mixing headers, structures 
and APIs (with same name) between the windows and the unix environment 
might be tricky (to say the least)

also the stack needed by both realms can be slightly different 
(exception unwinding in one example, there are others)


moreover, depending on what your windows app does, and what the glibc 
(and perhaps other Unix ELF shared lib do), one of the safest option 
would be to:

- compile your windows app as a PE file (either on Windows , or cross 
compiling under Linux) ; from using Winelib, it will reduce the errors 
in portability

- isolate all you glibc calls into a dedicated DLL ; this DLL should use 
the unixlib infrastructure: it allows to create a DLL, visible and 
callable as any other DLL from your main .exe (or other DLLs if needed), 
but that DLL can have specific portions calling into ELF libraries 
(glibc being one of them)

from your need, the DLL entry points would be utf16 (it's living in 
Windows world), but inside the DLL the transformation to or from utf32 
(depending on what the flow of data is concerned)

this will clearly separate the two realms, and provide with limited 
effort the connection between the two

see examples of such constructs in dlls/winepulse.drv, or nsysproxy.sys 
(there are others)

there are some (slight) restrictions here:

- if you intent to have 32 and 64 bit builds or wow64 use, then there 
are a couple of more things to do

- calling back from the ELF part into the PE part is rather complex, so 
the idea is more like wrapping a call into an ELF library from the PE side


HTH
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.winehq.org/pipermail/wine-devel/attachments/20220504/21c467b0/attachment.htm>


More information about the wine-devel mailing list