melonDS-emu / melonDS

DS emulator, sorta
https://melonds.kuribo64.net
GNU General Public License v3.0
3.21k stars 530 forks source link

Add Build for Windows on ARM #1588

Open fzhwenzhou opened 1 year ago

fzhwenzhou commented 1 year ago

I have just got a laptop whose CPU is Snapdragon 8cx Gen 3. There is no native build for ARM64, so I tried to compile it with MSYS2, clangarm64 branch. Surprisingly, it succeeded, and the executable ran fairly well, and even better than my old Intel laptop. I just replaced "mingw-w64-x86_64" in the installation instruction with "mingw-w64-clang-aarch64", and the dynamic version can be built.

The static version cannot be built because the repository of MSYS2 is lack of "qt5-static". There is nearly no bug except opengl didn't work. Despite this, the effect of software emulation is great. As far as I'm concerned, it's well enough to be put on the Github Release page.

Thank you for reading such a long issue.

Adamillo commented 1 year ago

Try using the jit and see if that works for the aarch64 build as well

fzhwenzhou commented 1 year ago

Try using the jit and see if that works for the aarch64 build as well

You mean the option in "Emu settings" and "CPU emulation"? After I enabled this option, the games ran fairly well and even faster (at least I felt).

Adamillo commented 1 year ago

Ah, I see. So the aarch64 jit is included when building on ARM Windows, cool

nadiaholmquist commented 1 year ago

Oh neat to see someone actually wanting to use it on Windows on ARM! About a month ago I added the small bits here and there needed to get it working but left it at that for now due to a lack of proper testing.

The reason for no builds or instructions is that none of us can properly test it, I was using Windows 11 on ARM in a VM on my MacBook when I was getting it working, but that has no GPU acceleration hence the probably broken OpenGL which I couldn't try. Also the lack of packages for static builds is a problem, as that seems to be the preferred method for Windows users, and the final nail in the coffin is that Microsoft doesn't offer ARM VMs of their own OS on GitHub Actions, so we can't run automatic builds.

Proper full support for Windows on ARM with builds and all would be great but right now I don't think we can really do it well, sorry :(

fzhwenzhou commented 1 year ago

A possible solution to lacking of static libraries is that pack all the executables and DLLs into one exe. Builing an installer or MSI is also an option.

As for testing, at least I have my WoA laptop. If needed, I can contribute.

nadiaholmquist commented 1 year ago

Providing an MSI installer for the dynamically-linked builds is something I have been wanting to do, but haven't got around to because CPack is...complicated.

In terms of testing, if you can figure out why OpenGL doesn't work that would be neat.

fzhwenzhou commented 1 year ago

I wonder if I can enable logging, so I can debug in a more convenient way. Otherwise I have to analyze the memory dump

RayyanAnsari commented 1 year ago

you can use -DCMAKE_BUILD_TYPE=Debug and lldb

Wunkolo commented 1 year ago

There is nearly no bug except opengl didn't work

Use this

The static version cannot be built because the repository of MSYS2 is lack of "qt5-static".

There's a PR for build instructions tracking this as well. Static builds wont be possible until they have qt5-static available.

https://github.com/melonDS-emu/melonDS/pull/1576

I also have a branch here where I am trying to add a github-action for Windows-on-Arm builds but there are a lot of upstream dependency issues such as the qt5-static one.

fzhwenzhou commented 1 year ago

Thank you! The OpenGL indeed works! It seems that we can add the workaround into the executable or installer in the future (such as judging the system type and execute Add-AppxPackage command to install the dependents).

On MSYS2 website:

Not all packages in the repo have native builds yet, let us know if any you need are missing.

Maybe we can ask the MSYS2 maintainers to add qt5-static package, although it might not realize in the short term.

Icesito68 commented 1 year ago

Hi, I'm quite interested in compiling a version for arm, and I was wondering if I could help you, it turns out that we have a port of windows 11 arm for certain mobile devices (snapdragon 845 and 855) that obviously use this architecture, so if I Could you inform me how to contribute I would be delighted

fzhwenzhou commented 1 year ago

Hi, I'm quite interested in compiling a version for arm, and I was wondering if I could help you, it turns out that we have a port of windows 11 arm for certain mobile devices (snapdragon 845 and 855) that obviously use this architecture, so if I Could you inform me how to contribute I would be delighted

@Icesito68 I have built an installer with InnoSetup and the main branch. If you are willing to help, you could test this on your devices. Note that OpenGL only works with the plugin that @Wunkolo mentioned above installed. https://drive.google.com/file/d/1zytKI2KJ_KrSysFAUxNOVEh65Wkj_JCI/view?usp=sharing

@nadiaholmquist Also, maybe we can write a script to automate the process of building installers. By now I just copy the needed files to the program folders by hand, but we can write a batch file to do this and invoke InnoSetup to compile. If this is a possible solution, we can put this on the Release page.

nadiaholmquist commented 1 year ago

Ideally we would have building packages be part of the build system itself - CMake has this functionality through CPack, but my experience from looking at it is that it's not particularly well documented. I wanted to use it to build macOS app bundles instead of using my own custom script for it, but ran into the problem that it didn't seem flexible enough to actually let me bundle the dependencies with the BundleUtilities module.

For Windows, which sure seems to be a more common use case for CPack this might not be a problem though, and I've been meaning to give it a try as I personally think having an installer option would be good, even if it seems there's a heavy preference for "portable" builds.

Icesito68 commented 1 year ago

Perfect, thank you very much. Is there any other place where we can talk to organize it better?

fzhwenzhou commented 1 year ago

@nadiaholmquist I found it totally possible to run automatically CI build. This project llvm-mingw enables us to cross-compile from other machine. Although CI doesn't provide ARM machines, it's possible to use this cross-compiler to generate the artifacts.

As for generating the portable version, Enigma Virtual Box is a useful tool to pack all the DLLs into one exe.

ArturoGC06 commented 11 months ago

Hi, I'm quite interested in compiling a version for arm, and I was wondering if I could help you, it turns out that we have a port of windows 11 arm for certain mobile devices (snapdragon 845 and 855) that obviously use this architecture, so if I Could you inform me how to contribute I would be delighted

@Icesito68 I have built an installer with InnoSetup and the main branch. If you are willing to help, you could test this on your devices. Note that OpenGL only works with the plugin that @Wunkolo mentioned above installed. https://drive.google.com/file/d/1zytKI2KJ_KrSysFAUxNOVEh65Wkj_JCI/view?usp=sharing

@nadiaholmquist Also, maybe we can write a script to automate the process of building installers. By now I just copy the needed files to the program folders by hand, but we can write a batch file to do this and invoke InnoSetup to compile. If this is a possible solution, we can put this on the Release page.

Could you please share again that ARM64 build? The link it's down.

fzhwenzhou commented 11 months ago

Hi, I'm quite interested in compiling a version for arm, and I was wondering if I could help you, it turns out that we have a port of windows 11 arm for certain mobile devices (snapdragon 845 and 855) that obviously use this architecture, so if I Could you inform me how to contribute I would be delighted

@Icesito68 I have built an installer with InnoSetup and the main branch. If you are willing to help, you could test this on your devices. Note that OpenGL only works with the plugin that @Wunkolo mentioned above installed. https://drive.google.com/file/d/1zytKI2KJ_KrSysFAUxNOVEh65Wkj_JCI/view?usp=sharing

@nadiaholmquist Also, maybe we can write a script to automate the process of building installers. By now I just copy the needed files to the program folders by hand, but we can write a batch file to do this and invoke InnoSetup to compile. If this is a possible solution, we can put this on the Release page.

Could you please share again that ARM64 build? The link it's down.

I am sorry but I have changed my computer to Mac, and my previous computer isn't by my side. If you are curious about this, you can build yourself according to my instructions above.

ArminiusTux commented 10 months ago

Could you please share again that ARM64 build? The link it's down.

Hello there, I have found two test builds for Windows ARM64 released by @mijk84:

melonds-11062022-warm64.tar.gz

melonds-31072022-warm64.tar.gz