ptitSeb / box86

Box86 - Linux Userspace x86 Emulator with a twist, targeted at ARM Linux devices
https://box86.org
MIT License
3.31k stars 227 forks source link

Enter the gungeon fails to start (weak symbol, symbol not found, unimplemented opcode) #34

Closed ITotalJustice closed 3 years ago

ITotalJustice commented 5 years ago

Device: raspberry pi 4 (4gb) OS: Raspbian (32bit) Game: Enter the Gungeon

BOX86_LD_LIBRARY_PATH=/usr/i686-linux-gnu/lib/ box86 EtG.x86
BOX86_LD_LIBRARY_PATH: /usr/i686-linux-gnu/lib/
Using default BOX86_PATH: ./:bin/
Counted 49 Env var
Looking for EtG.x86
Using native(wrapped) libdl.so.2
Using native(wrapped) libpthread.so.0
Using native(wrapped) librt.so.1
Using emulated /usr/i686-linux-gnu/lib/libstdc++.so.6
Using native(wrapped) libm.so.6
Using native(wrapped) libc.so.6
Using native(wrapped) ld-linux.so.2
Using emulated /usr/i686-linux-gnu/lib/libgcc_s.so.1
Error: Weak Symbol _ZGTtnaj not found, cannot apply R_386_JMP_SLOT @0xb6b6f198 (0x6b676)
Error: Weak Symbol _ZGTtdlPv not found, cannot apply R_386_JMP_SLOT @0xb6b6f474 (0x6c1e6)
Error: Symbol pthread_mutexattr_setprotocol not found, cannot apply R_386_JMP_SLOT @0x9ef504c (0x8058306)
Error: Symbol sigreturn not found, cannot apply R_386_JMP_SLOT @0x9ef5200 (0x80589d6)
Error: Symbol mincore not found, cannot apply R_386_JMP_SLOT @0x9ef52b0 (0x8058c96)
Error: Symbol setcontext not found, cannot apply R_386_JMP_SLOT @0x9ef5454 (0x8059326)
Error: Symbol __logf_finite not found, cannot apply R_386_JMP_SLOT @0x9ef55bc (0x80598c6)
Using native(wrapped) libX11.so.6
Using native(wrapped) libXext.so.6
Using native(wrapped) libXcursor.so.1
Using native(wrapped) libXinerama.so.1
Using native(wrapped) libXi.so.6
Using native(wrapped) libXrandr.so.2
Using native(wrapped) libXss.so.1
Using native(wrapped) libXxf86vm.so.1
Set current directory to /home/pi/Downloads/data/noarch/game
Found path: /home/pi/Downloads/data/noarch/game/EtG.x86
Using emulated /home/pi/Downloads/data/noarch/game/EtG_Data/Mono/x86/libmono.so
Error: Global Symbol data_start not found, cannot apply R_386_GLOB_DAT @0xb440bb74 ((nil))
Error: Global Symbol __data_start not found, cannot apply R_386_GLOB_DAT @0xb440bd4c ((nil))
Mono path[0] = '/home/pi/Downloads/data/noarch/game/EtG_Data/Managed'
Mono config path = '/home/pi/Downloads/data/noarch/game/EtG_Data/Mono/etc'
Receiving unhandled NULL exception
25088|0x90866c4: Unimplemented Opcode 66 8C E1 89 48 18 8D 88
Receiving unhandled NULL exception
25088|0x90866c4: Unimplemented Opcode 66 8C E1 89 48 18 8D 88
Receiving unhandled NULL exception

The lines "25088|0x90866c4: Unimplemented Opcode 66 8C E1 89 48 18 8D 88" are repeated a few hundred times until a seg fault error.

Hopefully that's useful to you! If you need more information then i'd be happy to help.

Also I did try stardew valley but i had errors there as well, not sure if you want me to open an issue for each game that i have errors with, though so far its just been EtG and stardew. World of goo worked perfectly which was amazing!

ptitSeb commented 5 years ago

I'll work on wrapping the "libmono.so" of Unity games in Box86. That will get much better compatibility (because mono is difficult to emulate), and better speed, as all C# sharp code will run "native"... That should help EtG (I'm working on that...)

About Stardew Valley, it's an FNA games: it's a "pure" C# games with FNA (i.e. XNA on Linux) Framework. You can run it already using this method: https://magazine.odroid.com/article/playing-modern-fna-games-on-the-odroid-platform/

ITotalJustice commented 5 years ago

Great, thank you very much! I'll look forward to that!

As for the guide for playing fna games, i did try running a few games (including starfew) with that method and sadly all but one game failed to boot. The only game that managed to boot was hammerwatch. Starwdew, towerfall, owlboy and fez all failed to boot. I can post a few of the errors if you'd like.

ptitSeb commented 5 years ago

Ah yes, post some errors here. All the game you listed worked on my side, so that's strange they didn't worked for you (and for information, Hammerwatch is the only one in your list that is not an FNA game, but a regular C# + SDL2 game).

ITotalJustice commented 5 years ago

Thank you. I posted the logs on pastebin so as not to clutter this age too much, though if you want them here i can edit them into this post :)

Also, i was unable to compile theorafile on armv7, apart from that everything else compiled fine.

bastion: https://pastebin.com/2NBRpehT

StardewValley: https://pastebin.com/QxKDZ41c

Towerfall (cmd-output): https://pastebin.com/wJyD88iX
Towerfall (error_log): https://pastebin.com/6aYt6eqf

Owlboy: https://pastebin.com/5GmcvfGX
 - Notes: Doesn't actually crash, just hangs and does nothing(?).

FEZ: https://pastebin.com/9rjimjF7

Dust An Elysian Tail: Needs Theorafile (cannot compile on armv7)
ptitSeb commented 5 years ago

So, for Bastion, there is an issue with your version of MojoShader. I'll check on my side if I can understand what is happening.

For StardewValley, it seems to crash while loading sound data. I see you have 4 GB of RAM, so I guess it's not a memory issue. Still, you can try do recode the sould (to avoid MSADPCM).

I'll check the other logs later.

ptitSeb commented 5 years ago

And TowerFall had the same mojoshader issue.

I analyzed a bit, and I think you need to rebuild mojoshader with FLIP_VIEWPORT activated. so add -DFLIP_VIEWPORT=ON to the cmake command (or use ccmake and activate that option from there). That should solve many (most?) issues you have.

ITotalJustice commented 5 years ago

The -DFLIP_VIEWPORT=ON flag was already set when i compiled originally (as it was in your guide). Tried compiling it a few more times, even changing the CMake.txt to having these options on just to make sure, still no luck.

However! i decided to try an older(?) repo at https://github.com/flibitijibibo/MojoShader. Checking the CMake.txt it seems that i can just run cmake then make, so i did, copied the .so over...and what do you know! It worked! Bastion, towerfall and owlboy all booted instantly, and setting bastion to 720p allows it run at fullspeed, absolutely amazing. I'll try and let icculus know about this.

Thanks again mate you've been extremely helpful.

EDIT: I solved stardew valley error. It was was fault, i did ln -s /usr/lib/arm-linux-gnueabihf/libopenal.so libsoft_oal.so, but i didnt check if the file was actually there. The correct name for me was libopenal.so.1. After fixing that, the game booted fine, and again its another game running fullspeed. :)

Only game that i have left in the list that still doesn't work is FEZ. It doesn't seem to give any errors when loading (that i linked in the pastebin), but it doesn't load. very strange.

Back to box86, i have tested quite a large number of games and have saved the errors for the ones that failed to boot. If you want i can upload all the logs here if that would help.

ptitSeb commented 5 years ago

Ah thanks for the info! That MojoShader github repo is certainly the one to go (as flibitjibibo is the author of FNA after all).

I try to add a comment on the article, but the comment zone is Facebook only, so no-go for me. I'll try to have it fixed.

For FEZ, maybe look in ~/FEZ there should be some debug logs.

For stardew valley, yes, that strange link to libsoft_oal... I see (I should fix the tutorial too).

For Box86 yes, if you can open a ticket per game, I think that would help me to see what stuff I have to do next. Also, did you had some success with Box86?

(also, what error do you have that prevent you from building theorafile in armv7?)

ITotalJustice commented 5 years ago

Thanks, found the logs in ~/.local/share/FEZ.

(02:31:04.611) [OpenAL] Context created
(02:31:04.612) [OpenAL] Available mono sources : 255
(02:31:04.630) [OpenAL] Sound manager initialized!
(02:31:04.643) [Version] INFORMATION : 1.10, Build Date : 9/16/2013 2:36 AM
(02:31:05.530) [Unhandled Exception] ERROR : System.TypeInitializationException: The type initializer for 'FezEngine.Tools.SettingsManager' threw an exception. ---> System.InvalidOperationException: There is an error in XML document (0,$
  at System.Xml.XmlTextReaderImpl.Throw (System.Exception e) [0x0002a] in <1de9284cbde641149ec69c3bc257115c>:0
  at System.Xml.XmlTextReaderImpl.ThrowWithoutLineInfo (System.String res) [0x00017] in <1de9284cbde641149ec69c3bc257115c>:0
  at System.Xml.XmlTextReaderImpl.ParseDocumentContent () [0x0041e] in <1de9284cbde641149ec69c3bc257115c>:0
  at System.Xml.XmlTextReaderImpl.Read () [0x00097] in <1de9284cbde641149ec69c3bc257115c>:0
  at System.Xml.XmlTextReader.Read () [0x00000] in <1de9284cbde641149ec69c3bc257115c>:0
  at System.Xml.XmlReader.MoveToContent () [0x0004b] in <1de9284cbde641149ec69c3bc257115c>:0
  at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReaderMonoGameJoystickConfig.Read5_MonoGameJoystickConfig () [0x00008] in <91b10e5da6ad4280b4fd1d77cda27128>:0
  at (wrapper managed-to-native) System.Reflection.MonoMethod.InternalInvoke(System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00044] in <d0e12f672b88444$
   --- End of inner exception stack trace ---
  at System.Xml.Serialization.XmlSerializer.Deserialize (System.Xml.XmlReader xmlReader, System.String encodingStyle, System.Xml.Serialization.XmlDeserializationEvents events) [0x00139] in <1de9284cbde641149ec69c3bc257115c>:0
  at System.Xml.Serialization.XmlSerializer.Deserialize (System.Xml.XmlReader xmlReader, System.String encodingStyle) [0x00000] in <1de9284cbde641149ec69c3bc257115c>:0
  at System.Xml.Serialization.XmlSerializer.Deserialize (System.IO.Stream stream) [0x0001c] in <1de9284cbde641149ec69c3bc257115c>:0
  at Microsoft.Xna.Framework.Input.SdlGamePad.INTERNAL_AutoConfig () [0x00154] in <6f63475ba53f4512bb376e150fe53f4e>:0
  at Microsoft.Xna.Framework.Input.SdlGamePad.GetState (Microsoft.Xna.Framework.PlayerIndex playerIndex, Microsoft.Xna.Framework.Input.GamePadDeadZone deadZoneMode) [0x00014] in <6f63475ba53f4512bb376e150fe53f4e>:0
  at Microsoft.Xna.Framework.Input.SdlGamePad.GetState (Microsoft.Xna.Framework.PlayerIndex playerIndex) [0x00000] in <6f63475ba53f4512bb376e150fe53f4e>:0
  at FezEngine.Tools.SettingsManager..cctor () [0x001b1] in <f81bffca46d14a91b21c995e806d0ec9>:0
   --- End of inner exception stack trace ---
  at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_generic_class_init(intptr)
  at FezGame.Fez..ctor () [0x0007a] in <6db7a7f217a94e8a9d722a98aa26e3cf>:0
  at FezGame.Program.MainInternal () [0x0000b] in <6db7a7f217a94e8a9d722a98aa26e3cf>:0
  at Common.Logger.Try (System.Action action) [0x00000] in <4dd2f70f0b9e47279518ac154712e6b7>:0
(02:31:05.530) [FEZ] INFORMATION : Exiting.

Sure no problem. Yes i've had a few successes! bit-runner, unepic, defcon, FTL, world of goo and human resource machine. Another game that works is retro-city-rampage, however it runs at like 5fps, which is ironic as its the least demanding game by far ;) Though a few games that you got working did not work for me such as airline-tycoon. Airline-tycoon complains that "libsmpeg2-2.0.so.0" is not found, even though those libs are in ./lib32 of the game directory, and i added that path when running box86.

As for theorafile, i get a lot of assembly errors. Looking at the make file, it has a if else checking if the system is x64, else its x86, and then adds the flags. Of course because of this i wont be able to compile on arm. I did try removing the flag to see if it would magically work anyway, and it compiled and booted a game that required it (Dust An Elysian Tail), it tries open a window / goes fullscreen but fails, game continues to run with music etc and there were no errors. Just can't see the game :)

Lastly, for games such as undertale using box86, they require libcrypto. Do I have to install the i386 lib for this? I tried looking for help installing i386 libs on the pi but i couldnt find anything, the only i386 lib in the raspbian repo was libstdc++.so.6.

ptitSeb commented 5 years ago

So, an XML error in FEZ? Strange. You used the LC_ALL="C" ? Maybe try to remove it?

for libtheora, I'll re-check on my side how I built it.

For Airline-tycoon: the libsmpef2-2.0.so.0 needed is the ARM version, not the i386 (that is in the lib32 of the game). Use file on it to be sure if you want. You need to sudo apt install it, or maybe build it, I'm unsure. Same for understale, the libcrypto is the ARM version, not the i386 one.

ITotalJustice commented 5 years ago

Tried FEZ without LC_ALL, however its the same error.

And thank you. Speaking of compiling, i tried compiling the mono fork thats now linked but i was unable to. Tried on arm and pc and had same errors. I could build the original mono non-fork fine though.

Ah thank you, and nice tip on using file. Now got undertale working as well as a few other games including 2 fantastic games: VA11HallA and Hotline Miami! Amazing stuff. Hotline miani 2 also boots but freezes on the loading screen, ill open a separate issue on that shortly.

ptitSeb commented 5 years ago

Tried FEZ without LC_ALL, however its the same error.

Strange. The log seems to be about XML Joystick configuration. I need to look a bit more. I didn't tried with any joystick on my side...

And thank you. Speaking of compiling, i tried compiling the mono fork thats now linked but i was unable to. Tried on arm and pc and had same errors. I could build the original mono non-fork fine though.

The regular libmono will not have all the Unity specific symbol and will not work. I built it on the Pandora (so arm). What kind of error do you have?

Ah thank you, and nice tip on using file. Now got undertale working as well as a few other games including 2 fantastic games: VA11HallA and Hotline Miami! Amazing stuff. Hotline miani 2 also boots but freezes on the loading screen, ill open a separate issue on that shortly.

Nice, Hotline Miami :) VA11HallA I don't know it. I'll check later. Basicaly, most (if not all) GameMaker Studio game should work (all that have "runner" binary and "assets" folder). Some may be a bit slow sometimes (like "Not A Hero" or "Risk of rain").

ITotalJustice commented 5 years ago

I’ll try compiling again and I’ll post the results. I did try git clone, autogen, make - but I had errors straight away if I remember correctly. Then tried —recursive-submodules when cloning, got a lot further compiling but still errors. I was following the build guide that’s linked at the bottom of the repo, but that was for the original mono repo, maybe the instructions / decencies are different?

And that’s awesome, thats quite a lot of games there then!

ITotalJustice commented 5 years ago

Hi, this was the error i got when compiling. it happens when getting to the section that starts with Microsoft (R) Visual C# Compiler version 2.6.0.62309 (d3f6b8e7) Copyright (C) Microsoft Corporation. All rights reserved.

Unhandled Exception:
System.TypeInitializationException: TypeInitialization_Type ---> System.TypeInitializationException: TypeInitialization_Type ---> System.Exception: Magic number is wrong: 542
  at System.TermInfoReader.ReadHeader (System.Byte[] buffer, System.Int32& position) [0x00028] in <f3f60569a5ef43cd83c9e4e663990797>:0 
  at System.TermInfoReader..ctor (System.String term, System.String filename) [0x0005f] in <f3f60569a5ef43cd83c9e4e663990797>:0 
  at System.TermInfoDriver..ctor (System.String term) [0x00055] in <f3f60569a5ef43cd83c9e4e663990797>:0 
  at System.ConsoleDriver.CreateTermInfoDriver (System.String term) [0x00000] in <f3f60569a5ef43cd83c9e4e663990797>:0 
  at System.ConsoleDriver..cctor () [0x0004d] in <f3f60569a5ef43cd83c9e4e663990797>:0 
   Exception_EndOfInnerExceptionStack
  at System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) [0x00007] in <f3f60569a5ef43cd83c9e4e663990797>:0 
  at System.Console..cctor () [0x0008e] in <f3f60569a5ef43cd83c9e4e663990797>:0 
   Exception_EndOfInnerExceptionStack
  at Mono.ILASM.Report.AssembleFile (System.String file, System.String listing, System.String target, System.String output) [0x0001f] in <4ab07cda724045ca9f6d3c4bf5b47ed9>:0 
  at Mono.ILASM.Driver+DriverMain.ProcessFile (System.String file_path) [0x00019] in <4ab07cda724045ca9f6d3c4bf5b47ed9>:0 
  at Mono.ILASM.Driver+DriverMain.Run () [0x0006e] in <4ab07cda724045ca9f6d3c4bf5b47ed9>:0 
  at Mono.ILASM.Driver.Main (System.String[] args) [0x00015] in <4ab07cda724045ca9f6d3c4bf5b47ed9>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: TypeInitialization_Type ---> System.TypeInitializationException: TypeInitialization_Type ---> System.Exception: Magic number is wrong: 542
  at System.TermInfoReader.ReadHeader (System.Byte[] buffer, System.Int32& position) [0x00028] in <f3f60569a5ef43cd83c9e4e663990797>:0 
  at System.TermInfoReader..ctor (System.String term, System.String filename) [0x0005f] in <f3f60569a5ef43cd83c9e4e663990797>:0 
  at System.TermInfoDriver..ctor (System.String term) [0x00055] in <f3f60569a5ef43cd83c9e4e663990797>:0 
  at System.ConsoleDriver.CreateTermInfoDriver (System.String term) [0x00000] in <f3f60569a5ef43cd83c9e4e663990797>:0 
  at System.ConsoleDriver..cctor () [0x0004d] in <f3f60569a5ef43cd83c9e4e663990797>:0 
   Exception_EndOfInnerExceptionStack
  at System.Console.SetupStreams (System.Text.Encoding inputEncoding, System.Text.Encoding outputEncoding) [0x00007] in <f3f60569a5ef43cd83c9e4e663990797>:0 
  at System.Console..cctor () [0x0008e] in <f3f60569a5ef43cd83c9e4e663990797>:0 
   Exception_EndOfInnerExceptionStack
  at Mono.ILASM.Report.AssembleFile (System.String file, System.String listing, System.String target, System.String output) [0x0001f] in <4ab07cda724045ca9f6d3c4bf5b47ed9>:0 
  at Mono.ILASM.Driver+DriverMain.ProcessFile (System.String file_path) [0x00019] in <4ab07cda724045ca9f6d3c4bf5b47ed9>:0 
  at Mono.ILASM.Driver+DriverMain.Run () [0x0006e] in <4ab07cda724045ca9f6d3c4bf5b47ed9>:0 
  at Mono.ILASM.Driver.Main (System.String[] args) [0x00015] in <4ab07cda724045ca9f6d3c4bf5b47ed9>:0 
make[8]: *** [il.make:4: ../../../class/lib/basic/corlib.unsafe.dll.tmp] Error 1
make[7]: *** [../../../build/rules.make:211: do-all] Error 2
make[6]: *** [../build/rules.make:232: all-recursive] Error 1
make[5]: *** [build/rules.make:232: all-recursive] Error 1
make[4]: *** [Makefile:56: profile-do--basic--all] Error 2
make[3]: *** [Makefile:52: profiles-do--all] Error 2
make[2]: *** [Makefile:644: all-local] Error 2
make[2]: Leaving directory '/home/pi/mono/runtime'
make[1]: *** [Makefile:555: all-recursive] Error 1
make[1]: Leaving directory '/home/pi/mono'
make: *** [Makefile:485: all] Error 2

I did git clone --recursive-submodules https://github.com/Unity-Technologies/mono.git cd mono PREFIX=/opt/monotest ./autogen.sh --prefix=$PREFIX make -j4

ptitSeb commented 5 years ago

Ok, I'll check later on my side. It seems there is a mix of mono runtime/tools that break the build.

ITotalJustice commented 5 years ago

Tried again compiling unity-mono on arch, x64 debian and raspbian and it fails to compile sadly. Do you think the lib that you managed to compile work on the pi4? Unless it was built against pandora specific libs.

ptitSeb commented 5 years ago

Nope, it wont work on on the Pi4, the Pandora is SoftFP and HardFP on the floating point side. Anyway, eve if you compiled the lib, Unity support is far from finish, so it would not work yet.

ITotalJustice commented 5 years ago

Ah i see, thank you for explaining.

ptitSeb commented 3 years ago

Can you retry the game now, and close the ticket if it works?

ITotalJustice commented 3 years ago

Hi ptitSeb, really nice to see the huge amount of work that's been put into box86 since i've last used it 😄

I won't be able to get around to checking the games that i have opened issues for sadly, so the same goes for #42 and #39. Hopefully someone else can test

ptitSeb commented 3 years ago

image Got it to run on a Pi4, but it needed MESA_GL_VERSION_OVERRIDE=3.2

Closing ticket.

ITotalJustice commented 3 years ago

image Got it to run on a Pi4, but it needed MESA_GL_VERSION_OVERRIDE=3.2

Closing ticket.

That’s amazing! This was the main game I wanted working! Can I ask how the performance was if you don’t mind?

ptitSeb commented 3 years ago

I haven't really played, but it seemed playable. I'll try some actual game with fps counter later