Skip to content
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

[build] Move Mono API headers under src/native/public #64569

Merged
merged 12 commits into from
Feb 15, 2022

Conversation

lambdageek
Copy link
Member

Contributes to #64456

  1. Separate the public API headers from the mono implementation
  2. Provide a foundation for refactoring the headers (as outlined in [MonoAPI] embedding API testing and API headers quality of life improvements #64456) to be more useful for late binding scenarios

@ghost ghost assigned lambdageek Jan 31, 2022
@lambdageek lambdageek force-pushed the move-mono-include branch 5 times, most recently from db5d7c3 to 432bf4b Compare February 1, 2022 03:43
@lambdageek
Copy link
Member Author

/azp run runtime-extra-platforms

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@lambdageek
Copy link
Member Author

/cc @jkotas

@@ -848,6 +848,9 @@ endif()
### End of OS specific checks

include_directories("${CLR_SRC_NATIVE_DIR}")

add_subdirectory("${CLR_SRC_NATIVE_DIR}/include/mono-2.0" mono-2.0)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need the version number in the path? What does the version number mean?

We version the whole runtime together. I think trying to support multiple versions in the same repo would be very complex.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to match the layout that the existing runtime pack uses for the headers.

The mono API is always going to be "2.0" as long as its API/ABI compatible.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm trying to match the layout that the existing runtime pack uses for the headers.

Where is the existing runtime pack?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://nuget.info/packages/Microsoft.NETCore.App.Runtime.Mono.iossimulator-x64/6.0.1

The headers are in runtimes/[RID]/native/include/mono-2.0/...

The code that places them there is:

<RuntimeFiles Condition="'$(TargetsMobile)' == 'true'"
Include="@(MonoIncludeFiles)"
ExcludeFromDataFiles="true">
<TargetPath>runtimes/$(RuntimeIdentifier)/native/include/%(RecursiveDir)</TargetPath>
</RuntimeFiles>

(this is also matching the layout that the old mono/mono packages use - include/mono-2.0/mono/{utils,metadata,jit}/...)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be better to just name them include/metadata etc. and add the extra dirs in the runtime pack creation code.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps there are still too many mono names. Runtime pack includes Mono in name, then you have monoapi and mono under it.

Copy link
Member Author

@lambdageek lambdageek Feb 12, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure how much flexibility I have with the names.

In the runtime, we typically have includes like #include <mono/metadata/object.h> so at least one level of mono/ has to be in the repo. In embedding code, the mono-2.0/mono/metadata/object.h directory layout is pretty well established and embedders also typically write #include <mono/metadata/object.h>.

So if I move these headers, in the repo, they need to go some place like src/native/XYZ and beneath that it seems like we must have mono/metadata/object.h.

We could do something likesrc/native/include/mono/metadata/object.h but I don't think that conveys the idea that these headers are not an internal implementation detail of the runtime, but are part of the public API.

What about src/native/public/mono/metadata/object.h? or even src/public/mono/metadata/object.h ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have number of other public headers. For example, nethost.h and hostfxr.h (https://docs.microsoft.com/en-us/dotnet/core/tutorials/netcore-hosting).

If the idea is that all public headers that are designed to be included from outside the repo should live in a central place separate from their implementation, we should think about the directory structure for all of these.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the idea is that all public headers that are designed to be included from outside the repo should live in a central place separate from their implementation, we should think about the directory structure for all of these.

Yea an implementation-independent home for nethost.h and hostfxr.h would be great. (And would make it a bit easier for the mobile hosts to implement the same APIs)

I'm not sure what kind of directory layout would be best. src/native seems more natural than a new toplevel folder under src/ since these are native APIs. But on the other hand src/native is getting crowded.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally, I like src/native/public (e.g. src/native/public/mono/metadata/object.h) that you have proposed above.

@jkotas
Copy link
Member

jkotas commented Feb 1, 2022

@joncham Are you going to be able to build on this for what you are trying to do in Unity-Technologies#4 or do you think you will end up with a separate set?

@lambdageek
Copy link
Member Author

@joncham Are you going to be able to build on this for what you are trying to do in Unity-Technologies#4 or do you think you will end up with a separate set?

One of the goals of this is to make it easier to refactor the public headers into the MonoTypes.h/MonoFunctions.h sort of layout that Unity have in that PR.

I was thinking that e.g. mono/metadata/object.h would become a roll-up header that includes mono/metadata/details/object-types.h and mono/metadata/details/object-functions.h, etc. The Unity MonoFunctions.h can then just include all the details/*-functions.h headers, while existing code that uses the mono/metadata/*.h headers will keep doing what it does today.

@joncham
Copy link
Contributor

joncham commented Feb 2, 2022

I think the overall goals of #64456 make sense and would aid my efforts. The changes mentioned there and openness to supporting late bound (dlopen/dlsym) style clients would be helpful.

@lambdageek lambdageek force-pushed the move-mono-include branch 2 times, most recently from eec7a5c to 90eddd3 Compare February 7, 2022 14:27
@lambdageek lambdageek changed the title [build] Move Mono API headers to src/native/include/mono-2.0 [build] Move Mono API headers to src/native/monoapi Feb 7, 2022
@lambdageek
Copy link
Member Author

@marek-safar FYI

Comment on lines 324 to 325
install(FILES ${mini_public_headers}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/mono-2.0/mono/jit)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we still need to install JIT public headers from here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, that's dead code. Removed it. Thanks!

@lambdageek lambdageek changed the title [build] Move Mono API headers to src/native/monoapi [build] Move Mono API headers under src/native/public Feb 14, 2022
@lambdageek
Copy link
Member Author

lambdageek commented Feb 14, 2022

Moved things around one more time. Made a public APIs directory in src/native/public with the mono headers directly under public (ie src/native/public/mono/metadata/object.h etc). This just changes the repo layout, the runtime pack layout is still the same (headers under runtimes/[RID]/native/include/mono-2.0 in the nuget)

@lambdageek lambdageek merged commit a85f77a into dotnet:main Feb 15, 2022
@ghost ghost locked as resolved and limited conversation to collaborators Mar 17, 2022
@lambdageek lambdageek deleted the move-mono-include branch March 19, 2022 16:44
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants