TheLastRar / CLR-DEV9

A Dev9 Plugin for PCSX2 Written in C#
49 stars 9 forks source link

Compile from Linux for Linux? #5

Open Fothsid opened 6 years ago

TheLastRar commented 6 years ago

You should be able to build the main plugin on linux using monodevelop (normal build), or vscode (.Net core build only), you may have issues with dllexport not being able to run its postbuild commands, you can ignore that if you only plan to use the build on Linux.

however, unlike windows a wrapper/loader is needed to load the plugin under Linux. Building this is a bit more complicated, MS build is setup to connect to a remote linux machine via SSH and build the project using G++ along with a command to auto install the plugin where PCSX2 installed on my linux machine

I'm was having difficulty getting a wrapper to work as well as well as the plugin does on windows, attempting to use both CoreCLR or Mono to perform the task.

The current state of the two different wrappers are as follows; A CoreCLR based wrapper (for the Core build of the plugin)

A Mono based (for the normal build of the plugin, may work with the Core build)

Fothsid commented 6 years ago

Wow. Thanks for the reply. I can compile C++ part myself, but with which libraries I should link?

TheLastRar commented 6 years ago

CoreCLR based wrapper (CLR_DEV9_LINUX)

Mono based (CLR_DEV9_LINUX_MONO)

Fothsid commented 6 years ago

Can't compile main plugin... https://pastebin.com/L611WLRD

TheLastRar commented 6 years ago

In MonoDevelop (assuming that is what you are using), right click on the PSE folder and add the file "CLR_PSE_DummyExport.cs"

Fothsid commented 6 years ago

Compiled with mono, but seems like something gone wrong

[wx] /usr/lib32/pcsx2/libclrdev9.so: undefined symbol: mono_domain_set_config Path: /usr/lib32/pcsx2/libclrdev9.so File is not a valid dynamic library. Some kinda plugin failure: /usr/lib32/pcsx2/libclrdev9.so

Fothsid commented 6 years ago

nevermind, i just compiled with the old version of mono. anyways, now when I trying to open plugin selection window, pcsx2 crashes

TheLastRar commented 6 years ago

I forgot to mention that you need to include the mono headers located in /usr/include/mono-2.0 That is probably the cause of the error.

Fothsid commented 6 years ago

I included exactly these headers. I have runtime error.

Fothsid commented 6 years ago

Well, now it's not crashing, but just displays empty PCSX2 plugin selection window and it just hangs.

TheLastRar commented 6 years ago

What arguments are you using to build?, I can compare with what msbuild uses and see if there is something amis.

Fothsid commented 6 years ago

I created a simple CMakeLists.txt file, and builded everything using "cmake .. && make" CMakeLists.txt

Fothsid commented 6 years ago

Maybe it's because I manually installed 32 bit version of mono in /usr/lib32/ ...

Fothsid commented 6 years ago

I'm compiling CoreCLR for x86 right now, will try CoreCLR method.

TheLastRar commented 6 years ago

what method did you use to manually installed the 32 bit version of mono?

Fothsid commented 6 years ago
  1. '-m32' flag in linker and compiler
  2. because of this flag, linker automatically pickups required libraries from /usr/lib32, instead of /usr/lib. (at least on my system) (and also compiles everything for x86 arch)
  3. I copied libmono-2.0 binary from the debian package of the testing branch(i386 arch) to /usr/lib32
  4. that's all.
TheLastRar commented 6 years ago

Did you also copy the libmonosgen-2.0 binaries? those are required by libmono-2.0

Fothsid commented 6 years ago

Yes, I copied all dependencies, including libmonosgen-2.0

TheLastRar commented 6 years ago

Apologies, I had misread one of your comments and thought you where still having the undefined symbol.

Building with the CMake file produces a working build on my x86 VM, It probably is having issues with the manual install of mono for some reason.

edit: as an aside, you can use pass -rpath when linking to specify where to look for libraries at runtime, this is searched before usr/lib or usr/lib32

TheLastRar commented 6 years ago

Also, does anything get printed into the emulog file when PCSX2 crashes?

Fothsid commented 6 years ago

No, it just hangs until I kill process.

TheLastRar commented 6 years ago

Not even "Init Mono Runtime"?

Fothsid commented 6 years ago

Yes. Nothing in the console/logs

TheLastRar commented 6 years ago

That suggests that either it hangs before the wrapper starts loading, or the constructor method is being skipped for some reason...

Fothsid commented 6 years ago

Tried CoreCLR method. `SetLog SetSetting SetLog

Initializing plugins... SetSetting Init GS Init PAD Init SPU2 Init CDVD Init USB Init FW Init DEV9 Init Plugin Init CLR Init CLR Runtime Set Dirs PCSX2 Path is /usr/bin/PCSX2 Init CLR Failed At coreclr_initialize - Status: 0x8007001f`

TheLastRar commented 6 years ago

I pushed commit to try and fix that, retry with the latest commit

Fothsid commented 6 years ago

Tried with the latest commit. PCSX2 Path is /usr/bin/PCSX2 Init CLR Failed At coreclr_initialize - Status: 0x80004005

TheLastRar commented 6 years ago

Can you rerun with an environment variable of COREHOST_TRACE=1 and post the resulting logs

Fothsid commented 6 years ago

I'll check this tomorrow, OK? (Not currently at home)

Fothsid commented 6 years ago

There is no logs in terminal or PCSX2's console. https://pastebin.com/KiDDzcdg

TheLastRar commented 6 years ago

It seems the environment variable did not do what I thought it did (It's been a while since I've worked with CoreCLR)

I forgot to mention that CoreFX is also required, you need to build the native components for x86 and the managed components to x64 (x86 build might not complete but we can still use the x64 files as it's mostly AnyCPU)

The contents of bin/runtime/netcoreapp-Linux-Debug-x64/ and bin/Linux.x86.Debug/native/ will need to be copied to the same directory that CoreCLR is (I.e. /home/air/git/ReadyBin.Debug)

You might get a file called System.Private.CoreLib.ni.dll (I don't, but I'm mentioning this anyway), remove it while keeping System.Private.CoreLib.dll

TheLastRar commented 6 years ago

Try running using the env variable PAL_DBG_CHANNELS="+all.TRACE:-FILE.ERROR:-VIRTUAL.all" and post the resulting log

Fothsid commented 6 years ago

emuLog.txt

Fothsid commented 6 years ago

I can't build even managed part of CoreFX. Can you send me your build of x86 version of CoreCLR & CoreFX?

TheLastRar commented 6 years ago

Here is the combined CoreCLR & CoreFX build I use http://www.mediafire.com/file/myd8x4e7eoz2ppn/ReadyBin.Debug.tar.gz/file

Edit: try without the env variable first

Fothsid commented 6 years ago

Well, now it crashes only when I try to start the game.

TheLastRar commented 6 years ago

Do you still get the Init CLR Failed At coreclr_initialize - Status: 0x80004005?

Fothsid commented 6 years ago

No, I don't get this anymore.

TheLastRar commented 6 years ago

What gets logged instead?

Fothsid commented 6 years ago

Without env - edit: emuLog.txt With env - emuLog.txt

Fothsid commented 6 years ago

Fully rebuiled both libraries with the latest commits - no changes, except it doesn't hang anymore when I'm trying to close PCSX2.

TheLastRar commented 6 years ago

Without env, PCSX2 dies in Opening DEV9, there is no CLR_DEV9:PluginInterface Information: 2 : Open, which suggests the crash occurred in the wrapper for some reason.

With env, PCSX2 dies before init completes, I think it gets overwhelmed by the log spam, use PAL_DBG_CHANNELS="+all.TRACE:-FILE.ERROR:-VIRTUAL.all" instead

I pushed a commit that has some extra logging, can you rerun with a build using the latest commit.

Fothsid commented 6 years ago

I used build with latest commits. Without env variable: emuLog.txt With env variable: emuLog.txt (it just hanged, had to kill process.)

TheLastRar commented 6 years ago

Is there a file called DEV9_CLR.log, if there is can you post that as well, I think emulog might be eating messages.

I also has a typo in the new env variable, It's supposed to be PAL_DBG_CHANNELS="+all.TRACE:-FILE.ERROR:-VIRTUAL.all" I've corrected it in my original comments.

Fothsid commented 6 years ago

DEV9_CLR.log

Fothsid commented 6 years ago

With PAL_DBG_CHANNELS="+all.TRACE:-FILE.ERROR:-VIRTUAL.all" it now logs this and crashes properly lol emuLog.txt

TheLastRar commented 6 years ago

The issues appears to occur in managed code. I pushed a commit that has some extra logging to, can you rerun with a build using the latest commit.

The changes I made where to CLR_DEV9_Core, so you will need to rebuild the main plugin.

Fothsid commented 6 years ago

Nothing changed.

TheLastRar commented 6 years ago

No additional information in DEV9_CLR.log?

Fothsid commented 6 years ago

Nope.