ptitSeb / box64

Box64 - Linux Userspace x86_64 Emulator with a twist, targeted at ARM64 Linux devices
https://box86.org
MIT License
3.82k stars 274 forks source link

Java / JVM Support #232

Open jenswet opened 2 years ago

jenswet commented 2 years ago

There are multiple issues open regarding Java support: #112, #71, #193

I just experienced the same issue with another Java GTK app and found them searching the logs. The problem seems to be related to this part of the log always:

Error: Global Symbol collector_func_load not found, cannot apply R_X86_64_GLOB_DAT @0x7fa35040a8 ((nil)) in jre/lib/amd64/server/libjvm.so
Warning: Weak Symbol collector_func_load not found, cannot apply R_X86_64_JUMP_SLOT @0x7fa3504908 (0x22068e)

Is it planned to support Java applications at a later time?

I tried to use it to emulate x86/x64 apps on my Ubuntu ARM VM on Apple M1. That might be an interesting use case for other apps too, because qemu is very slow and box might be a lot faster.

ptitSeb commented 2 years ago

Yes, I want to add support for Java apps, but no timeframe for now.

Out of curriosity, what do you use to run the Ubuntu ARM VM on the M1?

jenswet commented 2 years ago

Hi,

Thanks for the quick reply!

I use Parallels Desktop because I have the license anyway for Windows 11. I also tried UTM and Ubuntu x64 but it's painfully slow.

I don't know how the emulation of x86/x64 apps technically works in Windows 11, but if box might get about the same performance on Linux that would be awesome.

ptitSeb commented 2 years ago

Ah, Parallels, ok (it's out of beta?). Nothing is free on apple ecosystem, I really don't like it.

jenswet commented 2 years ago

Yes it's out of beta. There are also good free options. UTM is free and works well with qemu for arm-based VMs too. But I get your point. 😄

artdeell commented 2 years ago

By the way, why run Java apps under Box anyway? Java was intended to be cross-platfotm, so most apps without native libraries will work fine, and for those with natives, replacement libraries for ARM(64) could be found.

jenswet commented 2 years ago

I know. In my case I'd like to use a commercial Eclipse for C++ based IDE / testing solution that is only available for x64. It uses lots of native libraries and I didn't find a way to install it into an arm-based Eclipse version. I need it for work unfortunately.

The same will be the case for a lot of embedded development tools probably.

Kabouik commented 2 years ago

I faced the same issue trying tu run the game Urtuk on a Debian LXC container running on an ARM phone. I was quite excited when I saw that a window did open when using box64 ./urtuk, but unfortunately the window stays black, likely due to this "Global symbol" issue:

user@debian-sid ~/D/Urtuk  $ box64 ./urtuk
Dynarec for ARM64, with extension: ASIMD AES CRC32 PMULL PageSize:4096
Box64 with Dynarec v0.1.7 fc3b931 built on Feb 24 2022 01:44:43
Using default BOX64_LD_LIBRARY_PATH: ./:lib/:lib64/:x86_64/:bin64/:libs64/
Using default BOX64_PATH: ./:bin/
Counted 67 Env var
Looking for ./urtuk
Using native(wrapped) libdl.so.2
Using emulated /usr/lib/x86_64-linux-gnu/libstdc++.so.6
Using native(wrapped) libpthread.so.0
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux-x86-64.so.2
Using native(wrapped) librt.so.1
Using native(wrapped) libm.so.6
Using emulated /usr/lib/x86_64-linux-gnu/libgcc_s.so.1
Using emulated jre/lib/amd64/server/libjvm.so
Error: Global Symbol collector_func_load not found, cannot apply R_X86_64_GLOB_DAT @0x791a189888 ((nil)) in jre/lib/amd64/server/libjvm.so
Using emulated /home/user/Desktop/Urtuk/jre/lib/amd64/libverify.so
Using emulated /home/user/Desktop/Urtuk/jre/lib/amd64/libjava.so
OpenJDK 64-Bit Server VM warning: Can't detect initial thread stack location - find_vma failed
Using emulated /home/user/Desktop/Urtuk/jre/lib/amd64/libzip.so
Using emulated /tmp/libgdxuser/3db1ff57/libgdx64.so
Using emulated /home/user/Desktop/Urtuk/jre/lib/amd64/libawt.so
Using emulated /home/user/Desktop/Urtuk/jre/lib/amd64/libawt_xawt.so
Using native(wrapped) libXext.so.6
Using native(wrapped) libX11.so.6
Using native(wrapped) libxcb.so.1
Using native(wrapped) libXau.so.6
Using native(wrapped) libXdmcp.so.6
Using native(wrapped) libXrender.so.1
Using native(wrapped) libXtst.so.6
Using native(wrapped) libXi.so.6
Using native(wrapped) libXinerama.so.1
Using emulated /home/user/Desktop/Urtuk/jre/lib/amd64/libfontmanager.so
Using native(wrapped) libfreetype.so.6
Using emulated /home/user/Desktop/Urtuk/jre/lib/amd64/libjawt.so
Using emulated /tmp/libgdxuser/31ce78a2/liblwjgl64.so
Using native(wrapped) libXcursor.so.1
Using native(wrapped) libXrandr.so.2
Using native(wrapped) libXxf86vm.so.1
Using emulated /tmp/libgdxuser/31ce78a2/libopenal64.so
Using native(wrapped) libpulse.so.0
Using native(wrapped) libGL.so.1
0.00:Warning: global settings file does not exist.
0.68:Error while loading global-progress.bin from disk: 
com.badlogic.gdx.utils.GdxRuntimeException: File not found: global-progress.bin (Local)
^Cfish: Job 1, 'box64 ./urtuk' has stopped

Screenshot_20220307_001

soywiz commented 2 years ago

+1 My use case is running java/gradle compiler in Ubuntu arm64 via Parallels Desktop on a M1 Max. I'm doing a crossplatform game engine and I need to be able to build on linuxX64 and test executables, but running a full VM is too slow to be reasonable option. BTW in my case not gradle, is working but built native game executables are not working either. In the case of the executables it seems that it is because I'm using libX11 dynamically with dlsym etc. I can provide screenshots/logs or help if required.

And BTW, thanks for your awesome project it is a huge work!

ptitSeb commented 1 year ago

The Error with the "collector_func_load" symbol is not really an error. I have hidden it now. You should try again with latest version. I have more java stuffs running on my side. If you have instability, try to use BOX64_DYNAREC_STRONGMEM=1 (or maybe 2), it might help with heavy multi-thread programs.

rcoppy commented 1 year ago

Hello, @ptitSeb ! I hope it's okay to post here--I can otherwise open a separate issue.

I am trying to run commercial software written in Java that comes packaged with AMD64 native libraries. Like some other users in this thread, I'm running inside of an ARM64 Linux VM installed on an M1 mac. (Specifically, I'm using the UTM virtual machine.) I've increased the max RAM allowed for the VM from 4GB to 6GB.

A combination of: BOX64_DYNAREC_STRONGMEM=2 LD_BIND_NOW=1

Improves stability, but ultimately the program still crashes. So far as I can tell, there is an issue with the JVM's garbage collector trying to free memory it doesn't have access to.

The runtime errors I get are variable, but their log often contains something resembling the following:

Using native(wrapped) libXrandr.so.2
Using emulated /home/arcop/xilinx-install/tps/lnx64/jre11.0.11_9/lib/libsunec.so
BOX64: Warning, size difference in block between pass2 (72) & pass3 (36)!
Dump of 1 x64 opcodes:
0x10a195700: E9 FB  20 -> 16
Table64     8 -> 16

Regarding the JVM's garbage collector, there are also often these warnings:

Warning: Weak Symbol _ITM_memcpyRtWn not found, cannot apply R_X86_64_JUMP_SLOT @0xffff89469070 (0x960e0)
Warning: Weak Symbol _ITM_RU1 not found, cannot apply R_X86_64_JUMP_SLOT @0xffff89469688 (0x96d10)
Warning: Weak Symbol _ZGTtdlPv not found, cannot apply R_X86_64_JUMP_SLOT @0xffff89469b00 (0x97600)
Warning: Weak Symbol _ITM_RU8 not found, cannot apply R_X86_64_JUMP_SLOT @0xffff89469fc0 (0x97f80)
Warning: Weak Symbol _ITM_memcpyRnWt not found, cannot apply R_X86_64_JUMP_SLOT @0xffff8946a418 (0x98830)
Warning: Weak Symbol _ZGTtnam not found, cannot apply R_X86_64_JUMP_SLOT @0xffff8946ac08 (0x99810)
Warning: Weak Symbol collector_func_load not found, cannot apply R_X86_64_JUMP_SLOT @0xffff8aec8510 (0x29bc26)

This one also seems to be of importance:

Warning, resizing of TLS occured! size: 0->65536 / n_elfs: 1->1

Do you have any thoughts on how I could achieve better memory stability?

From what I've seen so far, Box64 is a really amazing tool; thanks so much for all your work on it! 🙂

rajdakin commented 3 months ago

Is this fixed now?