Uh oh!
There was an error while loading. Please reload this page.
[MonoAPI] Split type and function headers, add MONO_API_FUNCTION macro - #65446
Conversation
lambdageek
commented
Feb 16, 2022
@joncham@vargaz Want to get your feedback before I do @joncham I think this will work for Unity-Technologies#4 |
Uh oh!
There was an error while loading. Please reload this page.
a1a4f2f to
d848201Comparelambdageek
commented
Feb 18, 2022
This one is ready for review, @vargaz Went ahead and changed the metadata and jit headers too. Also renamed the jit header directory - this will eliminate the difference between how to include |
joncham
commented
Feb 18, 2022
@lambdageek one thing I just hit in my integration is calling convention. On 32-bit windows CoreCLR is built specifying STDCALL as the calling convention. This required me to decorate all my exported Mono functions with __cdecl. I think the current macro approach will let me do same, just FYI. |
c422065 to
e1c2e33Comparelambdageek
commented
Feb 22, 2022
@joncham, just so I'm clear, you'd do something like this, right? extern"C" {
#defineMONO_API_FUNCTION(ret,name,args) typedefret (__cdecl * name##_type) args;
#include<mono/metadata/details/object-functions.h>
#undef MONO_API_FUNCTION
#defineMONO_API_FUNCTION(ret,name,args) static name##_type name;
#include<mono/metadata/details/object-functions.h>
#undef MONO_API_FUNCTION
staticvoidinit_functions()
{
HMODULE hModule = ...
#defineMONO_API_FUNCTION(ret,name,args) name = (name ##_type)GetProcAddress(hModule, #name );
#include<mono/metadata/details/object-functions.h>
#undef MONO_API_FUNCTION
} |
joncham
commented
Feb 22, 2022
Correct. |
There was a problem hiding this comment.
nit: it would be nice to retain this warning in mono-private-unstable-types.h and mono-private-unstable-functions.h too.
There was a problem hiding this comment.
this will inadvertently install other files we put into these directories, e.g. README.md, right?
could we instead split jit_public_headers_base etc. into the normal and details/ .h files and install them separately here?
There was a problem hiding this comment.
this will inadvertently install other files we put into these directories, e.g. README.md, right? could we instead split
jit_public_headers_baseetc. into the normal anddetails/.h files andinstallthem separately here?
Yea I think so. I would just use install(FILES) then, I think, right? I don't really know what i'm doing with cmake install rules.
There was a problem hiding this comment.
We normally don't use install(DIRECTORY, @lambdageek. Elsewhere, we explicitly capture all the needed files in a variable, then use: install(FILES ${that_var} DESTINATION path/to/some/dir).
akoeplinger
commented
Feb 22, 2022
We should also update the CODEOWNERS file. |
The idea is that the function header can be included multiple times with different definitions of MONO_API_FUNCTION in order to make it easier to re-used the definitions for embedding the runtime in late-binding scenarios
install(TARGETS) flattens subdirectories (so all the details/ headers ended up in the respective parent directory)
One complication here is that the directory is called "jit" outside the runtime, but "mini", inside.
To match how embedders see the tree. Update the runtime to include <mono/jit/jit.h> instead of <mono/mini/jit.h>. No change in public API
not other stray files to the include dir
cb38c23 to
7e5fe2cComparelambdageek
commented
Feb 23, 2022
/azp run runtime-extra-platforms |
|
Azure Pipelines successfully started running 1 pipeline(s). |
This was already duplicated before the header reorganization, e.g. here https://github.com/dotnet/runtime/blob/b9a55b4f52243325359ced26e3d4b31ccacdc381/src/native/public/mono/metadata/class.h#L279-L282
I'm going to Instead of defining functions like this: MONO_API_FUNCTION(MONO_APIMONO_RT_EXTERNAL_ONLYreturnType, mono_function_name, (MonoObject*arg1, MonoObject*arg2))I'm going to pull the MONO_API_FUNCTION(MONO_RT_EXTERNAL_ONLY, returnType, mono_function_name, (MonoObject*arg1, MonoObject*arg2))where we define the macro as: #defineMONO_API_FUNCTION(modifiers, ret, name, args) MONO_API modifiers ret name args;The issue is that I'm less sure about the FYI /cc @joncham |
lambdageek
commented
Feb 23, 2022
I ended up redefining |
lambdageek
commented
Feb 23, 2022
"CoreCLR Product Build windows arm64 " (checked and release) build failures are #65624 (comment) |
The idea is that the function header can be included multiple times with
different definitions of
MONO_API_FUNCTIONin order to make it easier tore-used the definitions for embedding the runtime in late-binding scenarios
Contributes to #64456