-
Notifications
You must be signed in to change notification settings - Fork 132
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
Support building sdks that can build self-contained / ReadyToRun / NativeAOT applications without using pre-builts from nuget.org #1215
Comments
Runtime packs are similar to targeting packs, so IMO they should be included in e.g.
A note about this from #1202, to put it in context: the runtime pack has limitations on what it supports, due to glibc compatibility and portable vs. non-portable builds. An SCD publish for I believe the SDK and perhaps Core-SDK repos will need to add support for this. The SDK currently locates targeting packs with The definition of The apphost pack resolver uses |
It makes sense to make it work similar to the apphost package. Can we set a target milestone for this? I can probably implement this based on these references. |
Adding @dsplaisted |
@dsplaisted @marcpopMSFT @MichaelSimons @dseefeld this issue is popping up as part of the s390x support because without it, users cannot create self-contained deployments. Single-file publish is not possible either, but that is not a feature with the mono runtime (yet). Can we look at including the runtime package in all source-built SDKs for .NET 7? |
The current .NET 6 SDK already checks for runtime packs in the
This likely still needs a bit of tweaking to use an appropriate condition when to do it. Also, it currently installs only the As a drawback, this approach significantly increases the size of the SDK installation on disk. This is annoying in particular as most of the files installed as part of the target runtime pack are in fact already present in the SDK on-disk installation, under the |
We can only build (rid-specific) packs for the target rid. |
I'm not sure I understand what you mean here. This is not about building those packs (they have to have been built previously), this is just about the installer build packaging them up for distribution as tarball. For example, in the current source-build, we build the runtime twice, and that generates two separate App.Host packages, and both of them get packaged up by the installer. Similarly, those two runtime builds already also generate two App.Runtime packages, so the installer could package both of those as well, if we think that would be useful. |
If you're on Fedora 34, you can claim you're building the host or runtime for The latter is meant to work across a range of distros. Microsoft builds it and publishes it for others to consume on nuget.org.
What is the difference between the packages? Is one using the target rid (like If that is the difference, the latter isn't really portable, because it will in some ways depend on Fedora 34. It's a package that pretends to be the portable rid for the sake of source-build. It is not meant for the user. |
Due to the size of the runtime packs, it might be a good idea to have them separate and optional. Or maybe it would be a good idea to be able to create source built NuGet packages and have them be acquired via NuGet in the same way the non source-built ones are. |
.NET 7 will add support for NativeAOT. We'd like a source-build SDK to be able to build self-contained NativeAOT applications. This issue was already tracking adding support for self-contained, and I've added NativeAOT in the title too. We can split it up when that makes sense. |
I've summarized what I believe to be the current state of play and the agreed-upon solution for NativeAOT in 7.0 in dotnet/runtime#76206. Please check this out and let me know if you have any concerns. |
Hi folks, Some updates, and (I think) some good news. While thinking this over I eventually came up with an idea that I think would let .props and .targets files be imported from packs in the However, while I was writing up a design for this idea, I looked more at how the three packages (Microsoft.DotNet.ILCompiler, Microsoft.NET.ILLink.Tasks, and runtime.<rid>.Microsoft.DotNet.ILCompiler) needed for NativeAOT are used. It turns out that the runtime one, which is the large one, doesn't have any .props and .targets in it and is already downloaded as a PackageDownload. So I think that package could be placed in the packs folder, and slight modifications to The other two packages are way smaller, so I think including them as .nupkg files in the As for fallback folders, I had forgotten about them, but was remembering the lessons we learned from them. I believe fallback folders aren't supported (at least not well) anymore. I believe we stopped using fallback folders around .NET Core 3, partly because we switched to framework references and package downloads, but also because fallback folders didn't work with features NuGet was adding such as package signing and hash validation. |
I've started to implement the design proposed by @dsplaisted. After patching the That reference comes from the {
"runtimes": {
"fedora.39-x64": {
"#import": [],
"Microsoft.DotNet.ILCompiler": {
"runtime.fedora.39-x64.Microsoft.DotNet.ILCompiler": "[9.0.0-preview.5.24272.2, )"
}
}, We need the {
"runtimes": {
"fedora.39-x64": {
"#import": [],
"Microsoft.DotNet.ILCompiler": { }
}, @dsplaisted @baronfel @ViktorHofer do you have a suggestion how/where to do this? |
Interesting. I imagine that reference in the runtime.json file is there to support explicitly referencing the I don't know where the |
Yes, explicit reference of Microsoft.DotNet.ILCompiler package is expected to add the RID-specific Microsoft.DotNet.ILCompiler package. runtime.json in Microsoft.DotNet.ILCompiler package on nuget.org has entries for all portable RIDs supported by native AOT to make that work. |
I assume this means we can not just remove the This package is built from the runtime repo: https://github.com/dotnet/runtime/tree/main/src/installer/pkg/projects/Microsoft.DotNet.ILCompiler. The source-built rid gets added here: https://github.com/dotnet/runtime/blob/03bc51f54dac5b8c7ba94ef798dfc93bfbbe6ef9/src/installer/pkg/projects/Microsoft.DotNet.ILCompiler/ILCompilerRIDs.props#L18. I don't know how this goes further into generating |
The runtime.json feature is undocumented and got added in the .NET Core 1.x days to support including RID specific packages. The ILCompiler package is one of the remaining ones that use runtime.json and our plan is to eventually get rid off them all and replace them with alternative solutions (i.e. the Known* items in the SDK for anything in-built). dotnet/runtime#49137 is also related. Mentioning that as I think changing the ILCompiler package and make it use the common SDK infrastructure (framework references / known* items) would make things way easier here and wouldn't require changing the SDK task. |
I think the effect of removing the file entirely would be the same as removing the element you are suggesting. The only thing that runtime.json file does is add the RID-specific package reference. If you remove that element, then that should be the same as removing the entire file (except possibly for projects that are targeting other RuntimeIdentifiers). I don't know if things will work if you remove the reference. I'm not sure how the ILCompiler tasks locate the assets in the RID-specific ILCompiler package. As a first step though I'd suggest trying out removing the runtime.json entirely and seeing what happens. |
Yes, this works.
Removing the reference (as in #1215 (comment)) also works.
I interpreted #1215 (comment) as: when there is an explicit reference to the I think you are suggesting we drop @jkotas are there cases where that won't work? |
Is explicit reference of Microsoft.DotNet.ILCompiler package going to pick RID-specific Microsoft.DotNet.ILCompiler of the same version? The explicit references of Microsoft.DotNet.ILCompiler are used e.g. here: https://github.com/dotnet/runtime/blob/main/src/coreclr/nativeaot/docs/compiling.md#using-daily-builds |
I don't think so. We'd break this scenario by removing |
How can we update/patch the |
@jkotas would it be ok if we'd remove |
It is probably ok. It is a paper-cut behavior difference (not the first one) between the Microsoft build and the Linux distro build. We need to be watching for these paper-cut behavior differences and do something about them in case they show up on the radar. Here is my understanding of how the different configurations are going to work:
Is my understanding correct? Also, have you considered installing the native AOT compilers as separate distro package (e.g. |
This is a good overview, and it matches with how I expect it to behave.
Yes, we'll put this in a separate package to reduce the default SDK size. I like the idea of making this package install the native toolchain through dependencies. It will be up to the package maintainer to actually implement this. We'll extend https://learn.microsoft.com/en-us/dotnet/core/distribution-packaging with these guidelines. |
This all sounds reasonable to me, but I want to make sure we have a long-term design in place that's specified and maintained. Do we have a doc that explains exactly what This area has been difficult to understand in the past. |
These are the PRs that implement #1215 (comment):
I verified that with these changes the resulting source-built SDK can be used to publish native-aot apps, and that it works as an SDK to build the vmr. There is still some work to be done, esp on the sdk PR. I hope we can get these into the preview that the Once these changes are in the vmr, we may look to do some optimizations that reduce the size of the ILCompiler pack. |
@baronfel @dsplaisted @jkotas @MichaelSimons @ViktorHofer friendly reminder these PRs are still open, and this is something we'd really like to be in preview6. cc @omajid |
We still need to add tests, and update https://learn.microsoft.com/en-us/dotnet/core/distribution-packaging. |
@tmds - Is testing the last piece here? Is that still something you are planning to contribute? |
Yes. I forgot about this. I'll look into it. |
Thanks to the reference packs, a source-build sdk can now build .NET Core applications that can be considered themselves source-buildable.
This doesn't apply to self-contained applications, and ReadyToRun applications. These require downloading a
Microsoft.NETCore.App.Runtime.<rid>
package from nuget.org. (This includes framework dependent ReadyToRun, probably because it uses the package to aquirecrossgen
.)This issue is for building and including the Runtime package with the sdk. This makes it possible for the maintainer to apply patches during source-build, and the applications built this way using the sdk can be considered source-buildable.
cc @dagood @nguerrera @omajid
The text was updated successfully, but these errors were encountered: