danoon2 / Boxedwine

Emulator that can run 32-bit Windows programs/games on multiple platforms via Wine
GNU General Public License v2.0
803 stars 64 forks source link

Haiku port #14

Open diversys opened 3 years ago

diversys commented 3 years ago

Hi there! I saw your comment here https://github.com/SerenityOS/serenity/issues/6637#issue-867001447 and decided to try your instructions on Haiku and with the help from @threedeyes we (mostly him) managed to actually run it! :) Some screenshots:

image

image

image

image

image

image

image

Would you be interested in accepting Haiku patches? Here's is a small patch just in case https://pastebin.com/raw/Afp2bw8z. Sorry for not sending a PR at this time. Thanks!

danoon2 commented 3 years ago

@diversys I see that you had to modify Poco. Is libcurl available on Haiku? I only use Poco for networking code, but it seems like for portability I should consider something more like libcurl.

diversys commented 3 years ago

Yes, libcurl is available: https://depot.haiku-os.org/curl. Networking in wine doesn't work yet, though.

danoon2 commented 3 years ago

@diversys Sorry, I didn't understand what you meant by networking doesn't work. Does that mean if moved Boxedwine over to using libcurl instead of Poco that it wouldn't be able to download the zip files that I see working in your screen shots?

diversys commented 3 years ago

Ah, sorry for confusion :) When wine starts it tries to install mono and gecko but fails to do that.

Haiku doesn't have if_arp.h so we had to comment that out (in the patch) maybe that's why it doesn't work? If that's the case then moving over to using libcurl will fix that.

danoon2 commented 3 years ago

I really need to find a permanently way to disable those popups for mono and gecko. Currently they are not supported by Boxedwine. I guess I've just been a little too optimistic that someday I will get to supporting them. Wine is the one asking for it be installed, not Boxedwine. My networking code from within Boxedwine is pretty spotty, if you're lucky NetSurf might actually load a page. The Poco/libCurl code is only used for downloading demos and file systems from the UI, not for apps/games running in Boxedwine.

diversys commented 3 years ago

Aha, thanks! Things are clearer now.

Gcenx commented 3 years ago

I really need to find a permanently way to disable those popups for mono and gecko. Currently they are not supported by Boxedwine. I guess I've just been a little too optimistic that someday I will get to supporting them. Wine is the one asking for it be installed, not Boxedwine. My networking code from within Boxedwine is pretty spotty, if you're lucky NetSurf might actually load a page. The Poco/libCurl code is only used for downloading demos and file systems from the UI, not for apps/games running in Boxedwine.

You can disable gecko/mono install by setting the following export.

export WINEDLLOVERRIDES="mscoree,mshtml="

This will cause issues, it would be more ideal to at least get wine-gecko to install. The msi installer could be downloaded and placed into $prefix/share/wine/gecko/wine-gecko-2.47.1-x86.msi the example is for wine-5.0

danoon2 commented 3 years ago

You can disable gecko/mono install by setting the following export.

Thanks. My goal would be eventually to run mono and gekko. For the first several years of this project, my CPU emulation was too slow for anything but older games and apps. Now that CPU emulation is getting faster, maybe 25% of the host computer for the x64 build, I will be able to start focusing on more advanced games and app, like ones that would require mono.

Gcenx commented 3 years ago

Thanks. My goal would be eventually to run mono and gekko. For the first several years of this project, my CPU emulation was too slow for anything but older games and apps. Now that CPU emulation is getting faster, maybe 25% of the host computer for the x64 build, I will be able to start focusing on more advanced games and app, like ones that would require mono.

You can mostly ignore wine-mono until 6.1.1 as you usually end up needing to installing native .Net.

But wine-gecko is more of a hard requirement ether via the msi installers or via the shared installs (shared version is recommended when available)

I’ve quickly tested the project (on macOS not Haiku) and yes I’d agree it’s about 25% currently.

threedeyes commented 3 years ago

I have compiled both versions of the emulator for Haiku - 32 and 64 bit. But unfortunately, when starting the application from the 64-bit version of Boxedwine UI, everything freezes at the stage of initializing the emulator.

screenshot35

The 32 bit version works fine, but slowly.

danoon2 commented 3 years ago

I guess that means Haiku is Posix compatible since that builds. The x64 build using the binary translator only works well on Windows. I have been working on it for Mac, Linux and the Raspberry Pi, which all share the same Posix signal handler, https://github.com/danoon2/Boxedwine/blob/master/platform/linux/platformThreads-x64.cpp. Those 3 platforms will all run very simple apps, like WineMine, but for apps that are more likely to have an actual exception happen, they all have problems. Does WineMine work for you?

threedeyes commented 3 years ago

I think the problem is in the differences in the haiku memory map. Hanging occurs when searching for a free block of memory for reserving 4GB and 32GB blocks.

danoon2 commented 3 years ago

That makes sense, the raspberry pi also has that same issue. Windows is OK with allocating a ton of virtual memory, but other system are not. You can set this to false in ksystem.cpp

ifdef BOXEDWINE_BINARY_TRANSLATOR

bool KSystem::useLargeAddressSpace = true;

endif

When it is true, every emulated process will allocate 40GB of reserved address space, when it is false, then that number will be closer to 4GB.

threedeyes commented 3 years ago

I did as you suggested: bool KSystem :: useLargeAddressSpace = false; The memory block reservation was successful, but the emulator window did not appear. If i look to the emulator process with the debugger, i can see that the event loop is running. screenshot43

danoon2 commented 3 years ago

Looking at the debugger, it looks like it didn't get very far, thread 3790 is probably the thread that is trying to do the binary translation and execute wine. 3785 is the main thread and all it does it pump the sdl messages. By the time a simple app is launched, there should be several threads going. If you have time I would be curious about the stack for the "pthread func". But it looks like I will just have to finish getting x64 running well on Linux then we can try again.

waddlesplash commented 3 years ago

Windows is OK with allocating a ton of virtual memory, but other system are not. You can set this to false in ksystem.cpp

Haiku should be fine with it, too, so long as you use MAP_NORESERVE to indicate that you are OK with SIGSEGV if pages cannot be allocated. Otherwise mmap will fail with ENOMEM (unless you are running on a system that actually has >40GB of memory :-p)