<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
span.EmailStyle20
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="purple" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi Eric, All<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">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:<o:p></o:p></p>
<p class="MsoNormal">Debug Output:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">0024: close_handle() = 0<o:p></o:p></p>
<p class="MsoNormal">0024: close_handle( handle=0010 )<o:p></o:p></p>
<p class="MsoNormal">0024: close_handle() = 0<o:p></o:p></p>
<p class="MsoNormal">0024: close_handle( handle=0008 )<o:p></o:p></p>
<p class="MsoNormal">0024: close_handle() = 0<o:p></o:p></p>
<p class="MsoNormal">0024: resume_thread( handle=0018 )<o:p></o:p></p>
<p class="MsoNormal">002c: *wakeup* signaled=258<o:p></o:p></p>
<p class="MsoNormal">0024: resume_thread() = 0 { count=1 }<o:p></o:p></p>
<p class="MsoNormal">0024: close_handle( handle=0018 )<o:p></o:p></p>
<p class="MsoNormal">0024: close_handle() = 0<o:p></o:p></p>
<p class="MsoNormal">0024: select( flags=2, cookie=7ffd7230d0dc, timeout=+299.9999962, size=12, prev_apc=0000, result={}, data={WAIT,handles={0004,0014}}, contexts={} )<o:p></o:p></p>
<p class="MsoNormal">0024: select() = PENDING { call={APC_NONE}, apc_handle=0000, signaled=0, contexts={} }<o:p></o:p></p>
<p class="MsoNormal"><b>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<span style="color:red"> data_align -8
</span>retaddr %rip<o:p></o:p></b></p>
<p class="MsoNormal">271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c30: DW_CFA_def_cfa %rsp, 8<o:p></o:p></p>
<p class="MsoNormal">271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c30: DW_CFA_offset %rip, -8<o:p></o:p></p>
<p class="MsoNormal">271747.275:0028:002c:trace:unwind:dwarf_virtual_unwind fde 0x1700ac6ec len 54 personality (nil) lsda (nil) code 170048c30-1700490d0<o:p></o:p></p>
<p class="MsoNormal">271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c30: DW_CFA_advance_loc 1<o:p></o:p></p>
<p class="MsoNormal">271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c31: DW_CFA_def_cfa_offset 16<o:p></o:p></p>
<p class="MsoNormal">271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c31: DW_CFA_offset %rbp, -16<o:p></o:p></p>
<p class="MsoNormal">271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c31: DW_CFA_advance_loc 1<o:p></o:p></p>
<p class="MsoNormal">271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c32: DW_CFA_def_cfa_offset 24<o:p></o:p></p>
<p class="MsoNormal">271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c32: DW_CFA_offset %rdi, -24<o:p></o:p></p>
<p class="MsoNormal">271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c32: DW_CFA_advance_loc 4<o:p></o:p></p>
<p class="MsoNormal">271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c36: DW_CFA_def_cfa_offset 32<o:p></o:p></p>
<p class="MsoNormal">271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c36: DW_CFA_offset %rsi, -32<o:p></o:p></p>
<p class="MsoNormal">271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c36: DW_CFA_advance_loc 1<o:p></o:p></p>
<p class="MsoNormal">271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c37: DW_CFA_def_cfa_offset 40<o:p></o:p></p>
<p class="MsoNormal">271747.275:0028:002c:trace:unwind:execute_cfa_instructions 170048c37: DW_CFA_offset %rbx, -40<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The execute_cfa_instructions calls goes in loop and finally stack exhausted. The strange things is
<span style="color:red">data_align -8. </span>I am not aware of dwarf_virtual_unwind. May be this error is due to side effect of build issue ?<o:p></o:p></p>
<p class="MsoNormal">Any pointers/suggestion are welcome.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks Eric for your suggestion, will try another option if above won’t work.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">regards,<o:p></o:p></p>
<p class="MsoNormal">Mahin<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> Eric Pouech <eric.pouech@orange.fr> <br>
<b>Sent:</b> Wednesday, May 4, 2022 2:01 PM<br>
<b>To:</b> Mahin Pandya <mahin.pandya@actian.com>; wine-devel@winehq.org<br>
<b>Subject:</b> Re: Wine Source build on native wchar_t 4 bytes<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal">Le 04/05/2022 à 11:10, Mahin Pandya a écrit :<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal">Hi Eric, <o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">Here is what we are trying to do:<o:p></o:p></p>
<p class="MsoNormal"> <o:p></o:p></p>
<p class="MsoNormal">- do you want that all places where WCHAR is used (meaning utf16) is replaced by utf32 encoding?<o:p></o:p></p>
<p class="MsoNormal"><span style="color:#385723">Yes, all usage would be utf-32</span><o:p></o:p></p>
<p class="MsoNormal">- 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?<o:p></o:p></p>
<p class="MsoNormal"><span style="color:#385723">This would be WCHAR=4 bytes only. Native Windows Applications do not need to be supported.</span><o:p></o:p></p>
<p class="MsoNormal">- cross compiling or simply compiling ?<o:p></o:p></p>
<p class="MsoNormal"><span style="color:#385723">No cross-compilation. Currently planning to compile/build under Linux only.</span><o:p></o:p></p>
<p class="MsoNormal">and perhaps to start with, why is current utf16 encoding not sufficient?<o:p></o:p></p>
<p class="MsoNormal"><span style="color:#385723">We are trying to build Windows application using Wine Lib as native application (i.e. winelib
</span><a href="https://wiki.winehq.org/Winelib"><span style="color:#385723">https://wiki.winehq.org/Winelib</span></a><span style="color:#385723"> /
</span><a href="https://wiki.winehq.org/Winelib_User%27s_Guide"><span style="color:#385723">https://wiki.winehq.org/Winelib_User%27s_Guide</span></a><span style="color:#385723"> 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.</span><o:p></o:p></p>
</blockquote>
<p>Hi Mahin, <o:p></o:p></p>
<p>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)<o:p></o:p></p>
<p>also the stack needed by both realms can be slightly different (exception unwinding in one example, there are others)<o:p></o:p></p>
<p><o:p> </o:p></p>
<p>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:<o:p></o:p></p>
<p>- 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<o:p></o:p></p>
<p>- 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)<o:p></o:p></p>
<p>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)<o:p></o:p></p>
<p>this will clearly separate the two realms, and provide with limited effort the connection between the two<o:p></o:p></p>
<p>see examples of such constructs in dlls/winepulse.drv, or nsysproxy.sys (there are others)<o:p></o:p></p>
<p>there are some (slight) restrictions here:<o:p></o:p></p>
<p>- if you intent to have 32 and 64 bit builds or wow64 use, then there are a couple of more things to do<o:p></o:p></p>
<p>- 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<o:p></o:p></p>
<p><o:p> </o:p></p>
<p>HTH<o:p></o:p></p>
</div>
</body>
</html>