Wine Source build on native wchar_t 4 bytes

Mahin Pandya mahin.pandya at actian.com
Thu May 12 08:12:47 CDT 2022


Hi Eric, All

We have followed wchar_t with 4 bytes option and after a struggle able to build Wine lib. However when try to run any application e.g. notepad.exe it is failing with stack overflow, tried debugging with relay option gives some information about failures:
Debug Output:

0024: close_handle() = 0
0024: close_handle( handle=0010 )
0024: close_handle() = 0
0024: close_handle( handle=0008 )
0024: close_handle() = 0
0024: resume_thread( handle=0018 )
002c: *wakeup* signaled=258
0024: resume_thread() = 0 { count=1 }
0024: close_handle( handle=0018 )
0024: close_handle() = 0
0024: select( flags=2, cookie=7ffd7230d0dc, timeout=+299.9999962, size=12, prev_apc=0000, result={}, data={WAIT,handles={0004,0014}}, contexts={} )
0024: select() = PENDING { call={APC_NONE}, apc_handle=0000, signaled=0, contexts={} }
271747.275:0028:002c:trace:unwind:dwarf_virtual_unwind function 170048dc4 base 0x170048c30 cie 0x1700a25c8 len 14 id 0 version 1 aug 'zR' code_align 1 data_align -8 retaddr %rip
271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c30: DW_CFA_def_cfa %rsp, 8
271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c30: DW_CFA_offset %rip, -8
271747.275:0028:002c:trace:unwind:dwarf_virtual_unwind fde 0x1700ac6ec len 54 personality (nil) lsda (nil) code 170048c30-1700490d0
271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c30: DW_CFA_advance_loc 1
271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c31: DW_CFA_def_cfa_offset 16
271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c31: DW_CFA_offset %rbp, -16
271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c31: DW_CFA_advance_loc 1
271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c32: DW_CFA_def_cfa_offset 24
271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c32: DW_CFA_offset %rdi, -24
271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c32: DW_CFA_advance_loc 4
271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c36: DW_CFA_def_cfa_offset 32
271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c36: DW_CFA_offset %rsi, -32
271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c36: DW_CFA_advance_loc 1
271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c37: DW_CFA_def_cfa_offset 40
271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c37: DW_CFA_offset %rbx, -40

The execute_cfa_instructions calls goes in loop and finally stack exhausted. The strange things is data_align -8. I am not aware of dwarf_virtual_unwind. May be this error is due to side effect of build issue ?
Any pointers/suggestion are welcome.

Thanks Eric for your suggestion, will try another option if above won’t work.

regards,
Mahin

From: Eric Pouech <eric.pouech at orange.fr>
Sent: Wednesday, May 4, 2022 2:01 PM
To: Mahin Pandya <mahin.pandya at actian.com>; wine-devel at winehq.org
Subject: Re: Wine Source build on native wchar_t 4 bytes

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_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/20220512/3fe0c1ff/attachment.htm>


More information about the wine-devel mailing list