{"id":276,"date":"2017-08-19T19:32:32","date_gmt":"2017-08-19T17:32:32","guid":{"rendered":"https:\/\/netbsd.name\/?p=276"},"modified":"2018-05-27T12:09:36","modified_gmt":"2018-05-27T10:09:36","slug":"building-wine-on-netbsd-8-0-beta-with-pkgsrc-current","status":"publish","type":"post","link":"https:\/\/netbsd.name\/?p=276","title":{"rendered":"Building Wine on NetBSD 8.0 beta with pkgsrc current"},"content":{"rendered":"<p>For personal purposes I needed to build wine on my VT310-DP board using current <a href=\"https:\/\/pkgsrc.org\">pkgsrc<\/a> package manager. I initially\u00a0 tried to build and install emulators\/wine package for this purpose as an &#8220;obvious&#8221; choice. It contains a build for wine-1.6.2. I face two compilation issues during the build. First build issue was complaining about undefined yywrap variable in tools\/wrc\/parser.yy.c file. \u00a0 I &#8220;fixed&#8221; it by commenting out \/\/#undef yywrap.<\/p>\n<pre>--- tools\/wrc\/parser.yy.c 2017-08-19 15:29:22.954733511 +0300\r\n+++ tools\/wrc\/parser.yy.c 2017-08-19 15:30:39.061280133 +0300\r\n@@ -837,7 +837,7 @@\r\n #include \"newstruc.h\"\r\n \r\n #include \"parser.tab.h\"\r\n-#undef yywrap\r\n+\/\/#undef yywrap\r\n \r\n \/* Always update the current character position within a line *\/\r\n #define YY_USER_ACTION char_number+=yyleng; wanted_id = want_id; want_id = 0;\r\n\r\n<\/pre>\n<p>Another one was server\/ptrace.c issue. There were two code blocks using dbregs.drX variables (X is a number from 0-7), for example\u00a0 context-&gt;debug.i386_regs.dr0 = dbregs.dr0. Compiler was complaining that non of drX variables were defined in the struct. From the code I realized that it was using dbreg struct. Then I checked system&#8217;s \/usr\/include\/machine\/reg.h file, dbreg struct was defined like this:<\/p>\n<pre>\/*\r\n * Debug Registers\r\n *\r\n * DR0-DR3 Debug Address Registers\r\n * DR4-DR5 Reserved\r\n * DR6 Debug Status Register\r\n * DR7 Debug Control Register\r\n *\/\r\nstruct dbreg {\r\n int dr[8];\r\n};<\/pre>\n<p>It is visible that that dbreg struct has one dr variable which is an array of int. So I replaced all the dbregs.drX lines with array indexes instead dbregs.dr[X] line. It helped and wine was build. Unfortunately running any executable was failing with an error message: &#8220;wine: failed to create the process heap&#8221;. I tried to investigate error online but it was usually pointing to some old wine bug and workaround to build a manual Linux kernel which I wasn&#8217;t sure how to apply on NetBSD. One thing that caught my eye was that NetBSD has a newer wine package called <strong>wine-devel<\/strong>. It builds wine-1.9.18. During wine-devel compilation I didn&#8217;t face parser.yy.c issue anymore but ptrace.c one was still the same. I made this modification to the file:<\/p>\n<pre>--- ptrace.c 2017-08-19 15:14:09.316982274 +0300\r\n+++ ptrace.c 2017-08-19 15:16:07.746233823 +0300\r\n@@ -675,12 +675,12 @@\r\n context-&gt;debug.i386_regs.dr6 = DBREG_DRX((&amp;dbregs), 6);\r\n context-&gt;debug.i386_regs.dr7 = DBREG_DRX((&amp;dbregs), 7);\r\n #else\r\n- context-&gt;debug.i386_regs.dr0 = dbregs.dr0;\r\n- context-&gt;debug.i386_regs.dr1 = dbregs.dr1;\r\n- context-&gt;debug.i386_regs.dr2 = dbregs.dr2;\r\n- context-&gt;debug.i386_regs.dr3 = dbregs.dr3;\r\n- context-&gt;debug.i386_regs.dr6 = dbregs.dr6;\r\n- context-&gt;debug.i386_regs.dr7 = dbregs.dr7;\r\n+ context-&gt;debug.i386_regs.dr0 = dbregs.dr[0];\r\n+ context-&gt;debug.i386_regs.dr1 = dbregs.dr[1];\r\n+ context-&gt;debug.i386_regs.dr2 = dbregs.dr[2];\r\n+ context-&gt;debug.i386_regs.dr3 = dbregs.dr[3];\r\n+ context-&gt;debug.i386_regs.dr6 = dbregs.dr[6];\r\n+ context-&gt;debug.i386_regs.dr7 = dbregs.dr[7];\r\n #endif\r\n context-&gt;flags |= SERVER_CTX_DEBUG_REGISTERS;\r\n }\r\n@@ -709,14 +709,14 @@\r\n DBREG_DRX((&amp;dbregs), 6) = context-&gt;debug.i386_regs.dr6;\r\n DBREG_DRX((&amp;dbregs), 7) = context-&gt;debug.i386_regs.dr7;\r\n #else\r\n- dbregs.dr0= context-&gt;debug.i386_regs.dr0;\r\n- dbregs.dr1 = context-&gt;debug.i386_regs.dr1;\r\n- dbregs.dr2 = context-&gt;debug.i386_regs.dr2;\r\n- dbregs.dr3 = context-&gt;debug.i386_regs.dr3;\r\n- dbregs.dr4 = 0;\r\n- dbregs.dr5 = 0;\r\n- dbregs.dr6 = context-&gt;debug.i386_regs.dr6;\r\n- dbregs.dr7 = context-&gt;debug.i386_regs.dr7;\r\n+ dbregs.dr[0] = context-&gt;debug.i386_regs.dr0;\r\n+ dbregs.dr[1] = context-&gt;debug.i386_regs.dr1;\r\n+ dbregs.dr[2] = context-&gt;debug.i386_regs.dr2;\r\n+ dbregs.dr[3] = context-&gt;debug.i386_regs.dr3;\r\n+ dbregs.dr[4] = 0;\r\n+ dbregs.dr[5] = 0;\r\n+ dbregs.dr[6] = context-&gt;debug.i386_regs.dr6;\r\n+ dbregs.dr[7] = context-&gt;debug.i386_regs.dr7;\r\n #endif\r\n if (ptrace( PTRACE_SETDBREGS, pid, (caddr_t) &amp;dbregs, 0 ) == -1) file_set_error();\r\n else if (thread-&gt;context)<\/pre>\n<p>Applying this patch fixed the build and I had a newer version of wine ready. Trying it out proved to be successful for some small Windows executable files I was planning to use. Old wine bug didn&#8217;t reoccur. So if you want to build wine on NetBSD 8.0 beta and current pkgsrc I recommend using wine-devel package and apply the patch above if build fails.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For personal purposes I needed to build wine on my VT310-DP board using current pkgsrc package manager. I initially\u00a0 tried to build and install emulators\/wine package for this purpose as an &#8220;obvious&#8221; choice. It contains a build for wine-1.6.2. I face two compilation issues during the build. First build issue was complaining about undefined yywrap &hellip; <a href=\"https:\/\/netbsd.name\/?p=276\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Building Wine on NetBSD 8.0 beta with pkgsrc current<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[14,13],"class_list":["post-276","post","type-post","status-publish","format-standard","hentry","category-netbsd","tag-pkgsrc","tag-wine"],"_links":{"self":[{"href":"https:\/\/netbsd.name\/index.php?rest_route=\/wp\/v2\/posts\/276","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/netbsd.name\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/netbsd.name\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/netbsd.name\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/netbsd.name\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=276"}],"version-history":[{"count":3,"href":"https:\/\/netbsd.name\/index.php?rest_route=\/wp\/v2\/posts\/276\/revisions"}],"predecessor-version":[{"id":301,"href":"https:\/\/netbsd.name\/index.php?rest_route=\/wp\/v2\/posts\/276\/revisions\/301"}],"wp:attachment":[{"href":"https:\/\/netbsd.name\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=276"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/netbsd.name\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=276"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/netbsd.name\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=276"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}