godot: Statically linked mono on Windows - external profiler doesn't work
Godot version: 3.2
OS/device including version: Windows 10
Issue description: When following steps in godotengine/godot#34382 JetBrains dotTrace or JetBrains Rider show “Unsupported Mono version” It happens only on Windows with official Godot build, however with locally compiled Godot build with dynamically liked mono profiler works fine.
JetBrains engineers think that when mono is statically linked, its exports are not inherited.
JetBrains profiler dll loaded in Godot process is looking for mono api function and fails.
auto lib_handle = LoadLibrary("godot_exe_name");
auto func = GetProcAddress(lib_handle, "some_mono_function"); // this call fails
Example of the function: MONO_API MonoProfilerHandle mono_profiler_create (MonoProfiler *prof);
This happens only on Windows because mono on Windows works differently, as mono documentations says that for windows each function should be marked for export. https://www.mono-project.com/docs/advanced/embedding/#windows-considerations
About this issue
- Original URL
- State: open
- Created 4 years ago
- Reactions: 4
- Comments: 17 (11 by maintainers)
We are working on a solid fix, it requires changes in both Godot and JetBrains mono profiler.
If you link mono dynamically, it would solve the problem. Because profiler knows the exact name of the library, which contains mono api functions and those functions are already exported. This option still seems to be safer than the new one below, which we are trying to implement.
To make it work with statically linked mono:
This is absolutely not a good place to discuss the mentioned issues. I propose we move to a new issue in https://youtrack.jetbrains.com/issues/RIDER Please create one directly from Rider with Help - Report a Bug. Thanks!
Searching mono library in a process is not a problem itself because official mono library name could be changed by Mono developers as well. The only significant problem here is inability to load mono exported functions from statically linked mono library. And as @neikeq noticed having fixed list of symbols on Godot side we should maintain it all the time. Even though adding new symbols seems uncommon we might need it to implement some new features. Thus it would be much better for us to work with dynamically linked mono.
@MrZak-dev only known workaround is to compile godot locally.