termux-user-repository / tur

A place for all types of Termux packages.
Other
414 stars 80 forks source link

[Package]: hangover #749

Open twaik opened 9 months ago

twaik commented 9 months ago

Name

Hangover

Source code URL

https://github.com/AndreRH/hangover

Packaging policy acknowledgement

Additional information

We have wine-stable package so it should be pretty easy to port hangover too. It has support of builtin box64, qemu and fex (dlls) so it can run x86_64 and x86 binaries even in the case if there is no box86/box64 support in termux itself.

licy183 commented 8 months ago

hangover-libqemu and hangover-libfexcore is able to be compiled but can't work. I'll mark this issue as help wanted...

twaik commented 8 months ago

What about wow64 and box64 modules? I suppose it will be possible to use box64+wow64 to run both win32 and win64 binaries, with no need to invoke box86 to run 32-bit apps (which is important for i.e. steam).

twaik commented 8 months ago

hangover-libqemu and hangover-libfexcore is able to be compiled but can't work. I'll mark this issue as help wanted...

What is a problem in these packages? Segfaults? Or maybe something else? I think we can ping hangover dev here. Maybe he will help us.

licy183 commented 8 months ago

box64 works as expected, but qemu and fex doesn't. hangover-libqemu will segfault, hangover-libfexcore and hangover-libwow64fex will not load dlls.

~ $ wine aarch64-test.exe 
Hello World
~ $ wine i686-test.exe 
0088:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0048:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0048:err:winediag:nodrv_CreateWindow L"The explorer process failed to start."
0048:err:systray:initialize_systray Could not create tray window
0088:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0088:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0088:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
005c:err:dnsapi:DllMain No libresolv support, expect problems
0024:err:environ:init_peb starting L"Z:\\data\\data\\com.termux\\files\\home\\i686-test.exe" in experimental wow64 mode
starting Box64 based box64cpu.dll
Hello World
~ $ HODLL=xtajit.dll   taskset -c 1 wine ./i686-test.exe 
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0074:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0074:err:winediag:nodrv_CreateWindow L"The explorer process failed to start."
0074:err:systray:initialize_systray Could not create tray window
0054:err:dnsapi:DllMain No libresolv support, expect problems
0024:err:environ:init_peb starting L"Z:\\data\\data\\com.termux\\files\\home\\i686-test.exe" in experimental wow64 mode
starting Qemu based xtajit.dll
0024:err:wow:attach tcg_ctx 0x0
0024:err:wow:load_64bit_module failed to load dll c0000142
Segmentation fault
~ $ HODLL=wowarmhw.dll taskset -c 1 wine ./arm-test.exe 
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0074:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0074:err:winediag:nodrv_CreateWindow L"The explorer process failed to start."
0074:err:systray:initialize_systray Could not create tray window
0054:err:dnsapi:DllMain No libresolv support, expect problems
0024:err:environ:init_peb starting L"Z:\\data\\data\\com.termux\\files\\home\\arm-test.exe" in experimental wow64 mode
starting Qemu based wowarmhw.dll
0024:err:wow:attach tcg_ctx 0x0
0024:err:wow:load_64bit_module failed to load dll c0000142
Segmentation fault
~ $ HODLL=fexcore.dll wine i686-test.exe 
0088:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0050:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0050:err:winediag:nodrv_CreateWindow L"The explorer process failed to start."
0050:err:systray:initialize_systray Could not create tray window
0088:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0088:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0088:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
005c:err:dnsapi:DllMain No libresolv support, expect problems
0024:err:environ:init_peb starting L"Z:\\data\\data\\com.termux\\files\\home\\i686-test.exe" in experimental wow64 mode
starting FEX based fexcore.dll
0024:err:wow:load_64bit_module failed to load dll c0000142
~ $ HODLL=libwow64fex.dll wine i686-test.exe 
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0064:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0064:err:winediag:nodrv_CreateWindow L"The explorer process failed to start."
0064:err:systray:initialize_systray Could not create tray window
0054:err:dnsapi:DllMain No libresolv support, expect problems
0024:err:environ:init_peb starting L"Z:\\data\\data\\com.termux\\files\\home\\i686-test.exe" in experimental wow64 mode
0024:err:wow:load_64bit_module failed to load dll c0000135
twaik commented 8 months ago

@AndreRH can you please help us?

AndreRH commented 8 months ago

c0000142 is a failed dll initialization c0000135 is file not found, so libwow64fex seems to not be in the prefix I'll have a closer look the next days

AndreRH commented 8 months ago

For libwow64fex you need a binary patch for the dll to be picked up by wineboot and land in the prefix: https://github.com/AndreRH/hangover/blob/7969c549161279edd3c57a558fc60540e0dafb49/.packaging/debian11/fexpe/Dockerfile#L9

licy183 commented 8 months ago

After copying libwow64fex to $HOME/.wine/drive_c/windows/system32:

~ $ HODLL=libwow64fex.dll wine i686-test.exe 
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0050:err:winediag:nodrv_CreateWindow Application tried to create a window, but no driver could be loaded.
0050:err:winediag:nodrv_CreateWindow L"The explorer process failed to start."
0050:err:systray:initialize_systray Could not create tray window
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
0084:fixme:hid:handle_IRP_MN_QUERY_ID Unhandled type 00000005
005c:err:dnsapi:DllMain No libresolv support, expect problems
0024:err:environ:init_peb starting L"Z:\\data\\data\\com.termux\\files\\home\\i686-test.exe" in experimental wow64 mode
0024:err:virtual:virtual_setup_exception stack overflow 1296 bytes addr 0x6f19c3c4 stack 0x100100af0 (0x100100000-0x100101000-0x1001ffd20)
~ $ 
twaik commented 8 months ago

@AndreRH is there any chance you can help us to make a full port of hangover code to termux? Android devices are much more popular than other ARM devices.

AndreRH commented 8 months ago

@AndreRH is there any chance you can help us to make a full port of hangover code to termux? Android devices are much more popular than other ARM devices.

For now I'd suggest to fix X11 (wine-staging package has it enabled). Having the integrated Box64 would be enough for now, I don't see a point in having multiple emulators on Termux from the beginning where it is harder to switch between them. They can be fixed later.

I also tried to build it myself, but some intermediate step failed and the documentation isn't very precise. Here's what I tried: https://github.com/AndreRH/hangover/blob/tst/.packaging/termux/Dockerfile

IntinteDAO commented 8 months ago

@AndreRH

https://github.com/termux-user-repository/tur/blob/master/tur-multilib/hangover-wine/build.sh

In short how you build, clone repository, run ./setup-environment.sh to download necessary files and ./scripts/run-docker.sh ./build-package.sh -I hangover-wine

It will build a current version of hangover-wine

You just modyfil build.sh file (and create patch files if you want to patch something), it works without any other modifications

twaik commented 8 months ago

I think this workflow can be used as a reference. I think you can skip Gather build summary, Generating build artifact and upload steps.

AndreRH commented 8 months ago

@AndreRH

https://github.com/termux-user-repository/tur/blob/master/tur-multilib/hangover-wine/build.sh

In short how you build, clone repository, run ./setup-environment.sh to download necessary files and ./scripts/run-docker.sh ./build-package.sh -I hangover-wine

It will build a current version of hangover-wine

You just modyfil build.sh file (and create patch files if you want to patch something), it works without any other modifications

That works, thanks

AndreRH commented 8 months ago

hangover-libqemu and hangover-libfexcore is able to be compiled but can't work. I'll mark this issue as help wanted...

qemu is slow and not very useful, libfexcore might be abandoned in favour of libwow64fex this year. So they aren't important.

Though in my testing libwow64fex worked perfectly in termux as expected. It just has issues with CLI applications, e.g. it doesn't print their output. So patch it as I suggested and package it, it'll work :)

Also you could bump hangover-wine to 9.0-rc4 as it landed a Termux fix: https://gitlab.winehq.org/wine/wine/-/commit/0900d919e2fd5ce12e02375cfcbfa5ab7c283515 So the comments at the end of build.sh are obsolete

knyipab commented 7 months ago

Thank all for making this awesome package on Termux! I tried to install packages with winetricks, but it seems not working for almost any installation commands. It prompts errors of regedit.exe attempt to call libunwind which is not available.

Taking winetricks wmp9 as an example, excerpt of log is shown below, with the full log available at winetricks_wmp9.log.

Using native,builtin override for following DLLs: jscript scrrun vbscript cscript.exe wscript.exe
Executing wine C:\windows\syswow64\regedit.exe C:\windows\Temp\override-dll.reg
0220:err:environ:init_peb starting L"C:\\windows\\syswow64\\regedit.exe" in experimental wow64 mode
0220:err:seh:unwind_builtin_dll libunwind not available, unable to unwind
0220:err:seh:unwind_builtin_dll libunwind not available, unable to unwind
0220:err:seh:unwind_builtin_dll libunwind not available, unable to unwind
<.... repeats so many times here ...>
0220:err:seh:unwind_builtin_dll libunwind not available, unable to unwind
0220:err:seh:unwind_builtin_dll libunwind not available, unable to unwind
0220:err:seh:unwind_builtin_dll libunwind not available, unable to unwind
0220:err:virtual:virtual_setup_exception stack overflow 2944 bytes addr 0x7fffda59b0 stack 0x100100480 (0x100100000-0x100101000-0x1001ffd20)
------------------------------------------------------
warning: Note: command wine C:\windows\syswow64
egedit.exe C:\windows\Temp\override-dll.reg returned status 1. Aborting.
------------------------------------------------------

I'm not sure if libunwind.so is really the cause of issue, but I follow the clue and found https://github.com/termux/termux-packages/issues/4307 saying that libunwind.so is not packaged in Termux repo as this lib is made available by Android NDK at /system/lib/libunwind.so. However, as I checked on my phone (Android 14, Linux 5.19.94, aarch64), there is no /system/lib/libunwind.so (there is only /system/lib/libunwindstack.so). Besides, it seems to me that many Temux packages tend to statically link $PREFIX/lib/libunwind.a instead.

Hope my information help and really grateful for a fix! Thanks a lot!

AndreRH commented 7 months ago

Thank all for making this awesome package on Termux! I tried to install packages with winetricks, but it seems not working for almost any installation commands. It prompts errors of regedit.exe attempt to call libunwind which is not available.

libunwind shouldn't be necessary anymore with hangover-wine 9.1 so updating the version should help here see also wine commit 57b8d4c01982e68f2ce538fec40ce69413f1400d

Trass3r commented 4 months ago

If someone wants to try 9.7: https://github.com/Trass3r/termux-user-repository/commit/91b34a1e625c4368226a3ac3ec6a67fb4970257a I just adapted the patches though, not sure if anything else should be changed. There are some notable changes about ARM64X: https://gitlab.winehq.org/wine/wine/-/releases/wine-9.7

Fex also works by extracting the dll from https://github.com/AndreRH/hangover/actions/runs/8767939622/artifacts/1432406871 into ~/.wine/drive_c/windows/system32

twaik commented 3 months ago

@licy183 do you think we can build hangover apk with wineandroid.drv backend instead of winepulse and winex11 using termux's build scripts and toolchain? It seems like I have an idea how to fix graphics but I am not sure I have enough energy to find out how to build apk.

licy183 commented 3 months ago

@licy183 do you think we can build hangover apk with wineandroid.drv backend instead of winepulse and winex11 using termux's build scripts and toolchain? It seems like I have an idea how to fix graphics but I am not sure I have enough energy to find out how to build apk.

Theoretically, it is possible. May also need to set rpath to $ORIGIN after a successful compilation.

twaik commented 3 months ago

Can you please try to build it?

licy183 commented 3 months ago

Can you please try to build it?

I'll try it this weekend if possible.