dotnet / runtimelab

This repo is for experimentation and exploring new ideas that may or may not make it into the main dotnet/runtime repo.
MIT License
1.4k stars 197 forks source link

[NativeAOT] Suggestion: docker image for building with NativeAOT #1437

Open dellamonica opened 3 years ago

dellamonica commented 3 years ago

In case the team is taking suggestions.

My experience with the native AOT compiler so far has been a bit brittle (I know that it is an experiment, but I also know it has enormous potential and I'm sure it will become something official in the near future).

Perhaps one way to address this is to provide a docker image that contains everything that the compiler needs pre-installed, plus a few command line utilities to run it on any supported dotnet project type (it would also be great if we could cross-compile using such an image). This would also be helpful if someone wants to run a CI pipeline to generate native executables.

hez2010 commented 3 years ago

You only need to install clang in the official dotnet/sdk image.

dellamonica commented 3 years ago

@hez2010, I needed to install some additional packages as well. And, unfortunately, cross compilation is yet unsupported (https://github.com/dotnet/corert/issues/5458). That was to me one of the main appeals of having a container image for NativeAOT.

For what is worth, this is the trivial Dockerfile I created:

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS base
RUN apt-get update && apt-get install -y clang git libcurl4-openssl-dev zlib1g-dev libkrb5-dev
# TODO: setup hello world sample clone and test compilation.
ENTRYPOINT ["/bin/bash"]
hez2010 commented 3 years ago

cross system compilation is not supported yet, but cross arch compilation within the same system is supported.

dellamonica commented 3 years ago

If cross-system compilation is realistically unlikely to be implemented, perhaps what could be done instead is a proper implementation of a custom GitHub action to produce NativeAOT binaries on a GH CI pipeline (one could do similarly for Azure). In principle it should be feasible to produce binaries for Windows and Linux (maybe macOS as well, although I personally don't need it).