-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MonoAPI] Split type and function headers, add MONO_API_FUNCTION macro #65446
Conversation
@joncham @vargaz Want to get your feedback before I do @joncham I think this will work for Unity-Technologies#4 |
a1a4f2f
to
d848201
Compare
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 |
@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
e1c2e33
Compare
@joncham, just so I'm clear, you'd do something like this, right? extern "C" {
#define MONO_API_FUNCTION(ret,name,args) typedef ret (__cdecl * name##_type) args;
#include <mono/metadata/details/object-functions.h>
#undef MONO_API_FUNCTION
#define MONO_API_FUNCTION(ret,name,args) static name##_type name;
#include <mono/metadata/details/object-functions.h>
#undef MONO_API_FUNCTION
static void
init_functions()
{
HMODULE hModule = ...
#define MONO_API_FUNCTION(ret,name,args) name = (name ##_type)GetProcAddress(hModule, #name );
#include <mono/metadata/details/object-functions.h>
#undef MONO_API_FUNCTION
} |
Correct. |
* | ||
* Private unstable APIs. | ||
* | ||
* WARNING: The declarations and behavior of functions in this header are NOT STABLE and can be modified or removed at |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: it would be nice to retain this warning in mono-private-unstable-types.h and mono-private-unstable-functions.h too.
src/native/public/monoapi.cmake
Outdated
install(TARGETS monoapi_mini PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mono-2.0/mono/jit) | ||
install(DIRECTORY mono/utils/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mono-2.0/mono/utils) | ||
install(DIRECTORY mono/metadata/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mono-2.0/mono/metadata) | ||
install(DIRECTORY mono/jit/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mono-2.0/mono/jit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 anddetails/
.h files andinstall
them 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes that sounds good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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)
.
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
7e5fe2c
Compare
/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_API MONO_RT_EXTERNAL_ONLY returnType, 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: #define MONO_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 |
I ended up redefining |
"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_FUNCTION
in order to make it easier tore-used the definitions for embedding the runtime in late-binding scenarios
Contributes to #64456