-
Notifications
You must be signed in to change notification settings - Fork 5k
Support Alpine Linux (inadvertently to conform with libc for embedded systems) #4210
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
Comments
coreclr on embeded? This will be an interesting discussion to follow. @jasonwilliams200OK are you aware of the .NET micro-framework - http://www.netmf.com/gadgeteer/ which is open source and available on GitHub @ http://netmf.github.io/ |
Indeed. :) /cc @smaillet-ms your thoughts? |
I've been trying to get CoreCLR to build on Alpine and am stuck trying to compile libunwind. Seems that doesn't play nice with musl, specifically it doesn't have My goal is to eventually see if I can get ASP.NET vNext running on here, as Alpine is great for super lightweight Docker images (https://github.com/gliderlabs/docker-alpine) |
Running on alpine would be awesome, since the docker image is very tiny! |
Update: I have upstreamed all the local patches for Alpine Linux, one of the smallest Linux distro (~80 MBs ISO) that relies on musl-libc. It builds 99% of the CoreCLR without LLDB and event tracing (LIBLLTNG) support at the moment. PRs: dotnet/coreclr#5726, dotnet/coreclr#5727, dotnet/coreclr#5728, dotnet/coreclr#5729, dotnet/coreclr#5730, dotnet/coreclr#5731. This work is based on @benpye's original PR dotnet/coreclr#2262. |
This is definitely interesting work. It is important to point out to those who may be following from the NETMF realms that this is NOT NETMF, but rather a port of CoreCLR to this platform. The discussion here is available due to common interests and a bit of high level overlap (embedded and .NET) |
All the above mentioned PRs are merged. Result is 💯 %
As of this moment, CoreCLR (without lldbplugin) and CoreFX native both build on Alpine Linux. ⚡ Once lldb package is made available (i.e. very soon), I will rebuild CoreCLR and CoreFX native and post the test results with steps-by-step gist notes on how to build these from scratch installation here. FYI: @barthalion, @benpye, @ellismg |
Thanks to @barthalion for porting LLDB to Alpine Linux: https://pkgs.alpinelinux.org/packages?name=lldb. 🎉 ⭐ Now CoreCLR master builds on Alpine with lldbplugin (without missing anything). Running the PAL suites revealed 12 failures: https://github.com/dotnet/coreclr/issues/5872. Will run the managed test suite once PAL suite failures are sorted out. |
👍 for getting this working! |
With dotnet/coreclr#5872 closed, these are the final steps to build CoreCLR on Alpine Linux: https://gist.github.com/jasonwilliams200OK/7d6f5594d3bf697a27c9c1036d349fce and running the PAL tests. Note that CoreFX native also builds on Alpine. Now the verification (running full managed assemblies tests suite) and packaging parts are remaining. While ISO is 87MB with still lots of auxiliary stuff bundled in, the minimal Alpine is just 5MB in size (aka slimmest Linux with smallest footprints) used by docker: https://hub.docker.com/_/alpine/:/ (see description) .. the next in line is TinyCore Linux, which is 11 MB in size, but depends on glibc (i was trying to build working clang38 on it but Alpine is already 2x slimmer than TC 😉 ) .. For packaging, would be really nice to get someone from dotnet team to provide RID for Alpine Linux and APKBUILD script in dotnet/core-setup repo so we can build that project on Alpine... (we can help with APKBUILD script but please unblock us on core-setup) Reference: https://wiki.alpinelinux.org/wiki/APKBUILD_Reference cc: @jkotas, @ericstj, can Alpine get special love for dotnet core v1.0-RTM? long shot, but hopefully not impossible! 😊 |
@jasonwilliams200OK v1.0-RTM is out the door. It would be for the update that comes next. @joshfree @Petermarcu How can we get started on adding Alpine Linux to the list of the officially supported distros? |
@jkotas, yup but the distros packaging systems can still get v1.0 at any point. For example, lldb38 was released couple of months back but aports (Alpine packaging sys) got it 9 days ago. :) |
Is the key blocker right now the RID for Alpine? |
In other words, an entry here... https://github.com/dotnet/corefx/blob/master/pkg/Microsoft.NETCore.Platforms/runtime.json @jasonwilliams200OK you said please unblock you on core-setup. Is the RID issue whats blocking you? |
Folks can ammend the RID graph in their own package to try things out; any package with a runtime.json will get merged into the graph. We shouldn't be defining a RID compatibility relationship in the central MS.NETCore.Platforms until we have a chance to assess the compatibility of the distro with others/versions. That's ok to do in prerelease so long as we test it out and vet it before shipping stable. |
Read through this a bit more and here are the two options I see:
To get the RID added please open an issue in CoreFx and spec what the Identifier should be and how it relates to existing ones and I can add it. If folks want to understand the work behind adding support to 1.0 on the side I can elaborate on that. /cc @schellap for core-setup. I believe @jasonwilliams200OK needs our help to create a build script. |
Supporting mentioned OSes would be really great. Thumbs up. |
RID is something which is required whenever we try to build anything beyond CoreCLR / CoreFX: i.e. muxer (core-setup), or else the build script assumes platform to be Ubuntu. That is why i mentioned RID. To build functional .NET Core on any operating system which Microsoft will care about in future or not, what steps need to be taken? Here is my understanding how someone in OSS land can try building .NET core for their distro:
After that we are lost because:
If you can guide us how to build muxer by ourselves on the target platform or cross-compile from Ubuntu/Fedora for example, then we can build and validate everything in ports repos (aports, pkgsrc, portage, xbps etc.). For CoreFX assemblies which require platform specific native shims, we would need to publish those platform-specific partial assemblies to nuget as well. @ericstj, at the moment, nuget and coreclr installers are identified as set of three segments:
what is missing from this equation in cruntime identifier: glibc, musl, uclibc, dietlibs etc. against which the native compilation transpired. Gentoo and VoidLinux are examples which support multiple libc (in separate SKUs; in one install there is always one main libc which could be any one of the known variants). One way to tackle it is by introducing another segment to identifier for libc name. And if that segment is missing, consider it glibc for non-windows. Something like |
I do not think that replicating all nuances of platform-specific native code packaging in nuget is a path to success. I think we need to have an option to distribute and acquire the unmanaged parts via the platform-specific package manager:
It is not that different from where we are today. You need to get the unmanaged dependencies like icu or openssl via platform-specific package manager already anyway. This would push the boundary a bit higher - to match where the boundary between managed and unmanaged code actually us. The same strategy can also be used to make corefx packages that depend on |
Meaning the recommended way for platform package manager is give the experience like:
The rest of the NuGet packages will be fetched by
Trube, but lets suppose some non-Linux SmartOS or some non-Unix like OS requiring a "managed" partial class implementation of |
Those would all come from NuGet since (or be downloaded in a SDK zip) they are IL & not platform specific.
You could actually just use dotnet publish. If Alipine linux RID parents to linux RID it'll just 'exclude' all the native bits that aren't built in packages, but include all the corefx linux & unix specific implementations. This is what's already happening to build out the shared framework in core-setup. @piotrpMSFT I wonder if we could publish a shared-framework+SDK that is published for the Linux RID but missing the native bits. That way the only thing someone needs to do to make that work on a new distro is bring their own CoreCLR/Host/Shims. That solves the shared-framework case (standalone would be busted since that expects everything from Nuget) but it seems like a reasonable first step.
Suppose this OS has a RID |
Here's an example of what that the lineup would look like to merge in native Alpine packages out of band: https://gist.github.com/ericstj/c9d79fdc37362377507bc5b03ab795f5 This can be in any package, so long as it's referenced by the app the bits will get merged in. I think this is important for the standalone scenario, but not necessarily the shared/CLI bring up as I mentioned above. If we want to go down the route of building this lineup out of band I can show you how to create a |
This is to unblock you, in the short-term. The end goal is to produce a First step after coreclr and corefx would be to build the muxer with the native compiler toolchain and CMake: Look for Two parameters need to be slightly different:
To get the pure managed assets, like @ericstj mentions above, you can use the following project.json and do a
With the managed and the native components from the CoreCLR/CoreFX and Core-Setup, you should be able to put together the You might have to create a This file also includes the RID fallback graph used by the muxer to select assemblies for the current RID, from a portable app layout which contains multiple RID folders (
At this point, this is a functional Next is to make CLI work with the framework. Most of the CLI is managed except few muxer friends ( Last step is to use this |
The information is quite helpful. I will make .dotent_stage0 for Alpine and then for Void soon. Thanks!
Thanks for highlighting this @ericeil. By the analogy, AmigaOS won't inherit Unix whenever PowerPC architecture support will arrive to CoreCLR: https://www.power.org/ :) |
@schellap, after building the muxer on alpine, I:
After that I commented out alp:~/core-setup$ ./build.sh
Restoring Build Script projects...
Did you mean to run dotnet SDK commands? Please install dotnet SDK from:
http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409 Any ideas what am I missing? |
If you see the ubuntu bits here, there would be an |
Thanks @schellap. ATM, I am blocked by dotnet/coreclr#6211. |
@jasonwilliams200OK Thanks to your 'trip' I was also able to compile all for FreeBSD. Error I'm having right now is: dotnet.dll is from ubuntu SDK - cli repo also requires this to build - shouldn't this be doable using coreclr ? |
@sec, I am able to build Regarding the System.BadImageFormatException, dotnet.dll should be fine as it is a MSIL assembly. Here is the procedure I followed: On Windows (using PowerShell):
Now we have three dll files. We could have fourth one copy using scp from win to nix:
On Unix-like:
(I also removed and orphaned
This is pretty much it, after that I executed |
BadImageFormatException can be caused by trying to run ReadyToRun .dll native compiled for Linux on FreeBSD. Make sure to copy the MSIL assembly that is not ReadyToRun compiled. |
Thanks @janvorli I tried using your docker file however when I tried to run my application in it it gave me an error container_linux.go:247: starting container process caused "exec: "dotnet": executable file not found in $PATH" ENV DOTNET_VERSION 2.0.0-preview2-25407-01 RUN curl -SL $DOTNET_DOWNLOAD_URL --output dotnet.tar.gz then it gave me error so I added RUN /bin/sh -c "apk add --no-cache bash" RUN ALPINE_GLIBC_BASE_URL="https://github.com/sgerrand/alpine-pkg-glibc/releases/download" && ENV LANG=C.UTF-8 Now I get Error dotnet: /usr/lib/libstdc++.so.6: no version information available (required by dotnet) Please help. |
@mar10m3n3z35 I am sorry, I was probably not clear. This Docker file creates environment for building native parts of coreclr / corefx / core-setup repos, not for running dotnet tools. There is no version of dotnet core tarball that can work on Alpine (due to its usage of MUSL library) yet. Fixing the build is just the first step towards that. |
In the meantime, is it possible to build on alpine with glibc? alpine-pkg-glibc |
@imacks I think that coreclr master should compile on Alpine, since dotnet/coreclr#13052 got merged a while ago. |
+1 Do we know if there is anyone is actively working towards this? |
@janvorli is looking at getting everything going on Alpine again. |
@kbatman37 yes, I am actively working on that. The native parts builds were already fixed for Alpine some time ago, now I am working on making dotnet core on Alpine work end to end. |
@janvorli Will it be available at docker registry as microsoft official image? (https://hub.docker.com/r/microsoft/dotnet/) |
I was not thinking about the docker container yet, but I don't see a reason why it would not be there. |
Yes please! |
Hey just wanted to see if there was any movement on this? |
Noticed this yesterday... dotnet/corert#4552 (comment) |
@janvorli is extremely close to having builds for Alpine. I dont think any of the builds are available yet but I am guessing he's days away. |
@Petermarcu @janvorli when you will success with builds for Alpine, will they be available as tags within main docker image for .net core? |
@murbanowicz - yes the plan is to create Apline based Docker images for .NET Core. dotnet/dotnet-docker#22 tracks this work. |
@MichaelSimons I think we have a build you can pull into a container now. |
From dotnet/dotnet-docker-nightly#480
Where can we track the concrete remaining work preferably in the form of checklist? Bit of a retrospective .. Either we were getting vague replies like "Jan is working on it", "Jan is extremely close" or pointer to this quite-broad issue https://github.com/dotnet/coreclr/issues/917 with over 240+ comments and does not provide a concrete definition of "remaining work" at all. This would have helped the lack-of-clarity issues and you could have gotten way more contributions by just having information put in one place (a good example: https://github.com/dotnet/coreclr/issues/5851, solid, to-the-point "check-list"). |
@kasper3 right, I am sorry for not tracking the work in an easily discoverable way. I have just created dotnet/core#1076 to fix that. Please let me know if you'd like to see more detail added there. |
Linking announcement here: |
@janvorli, can this be closed since Alpine support has landed in 2.1? For Amiga and others, more specific issues can be opened separately. |
@jkotas, maybe the title of this issue can be renamed to Alpine Linux, instead of multiple operating systems. This is the most commented opened issue in the repo, which, i think, can safely be closed (after title renaming). |
Agree. Thanks |
musl (for Alpine), μClibc (for Alpine and Lilblue) and Newlib (for AmigaOS, Cygwin and PlayStation Portable) are standard C library implementations for embedded systems, which don't include Memory Management Unit (MMU).
If .NET team has plans to target microcontrollers/embedded-systems with coreclr, please provide support for those platforms.
Note that static lib libnix is also available for AmigaOS: http://cahirwpz.users.sourceforge.net/libnix/Description.html#Description (or https://github.com/cahirwpz/m68k-amigaos-toolchain)
Here is a list of major C standard libraries implementations: http://en.wikipedia.org/wiki/C_standard_library#Implementations
The text was updated successfully, but these errors were encountered: