runtime icon indicating copy to clipboard operation
runtime copied to clipboard

How get and build test version of dotnet ARM.

Open tomaszchacuk opened this issue 10 years ago • 45 comments

Hi.

I am intending to create some piece of software that would target ARM Linux (Ubuntu 16.04 + Rasppberry PI 2/3). Due to the fact that dotnet core for arm is planned to be released in unknown time I would like to take whatever there is to run dontet core on arm. I require it for Kestrel server (Websockets, and HTTP, but not full ASP.MVC)

IWhat is the branch location for the arm version and how can I build it on my own ? I need to have "something" and cannot wait with starting the project till the end of the year .

tomaszchacuk avatar Jul 18 '16 21:07 tomaszchacuk

cc @richlander @cmckinsey @gkhanna79

pgavlin avatar Jul 18 '16 23:07 pgavlin

@tomaszchacuk dotnet for ARM is in proof of concept quality state. In fact it is completely broken. ;-) If you want to program in C# just forget about dotnet and use mono (http://www.mono-project.com). mono is already available in Debian (and Ubuntu) for ARM. mono also has poor quality but at least sometimes it works. ;-)

mkborg avatar Jul 19 '16 10:07 mkborg

What is the branch location for the arm version

All arm specific changes are in master in this repo.

How can I build it on my own ?

The instructions to build CoreCLR are at https://github.com/dotnet/coreclr/blob/master/Documentation/building/linux-instructions.md. However, this will build just the coreclr runtime, not the dotnet tool - that I believe does not work on ARM well yet. You can try to make this work by using dotnet tool on x64, and copying the build artifacts over to your ARM machine.

@leemgs Have you or somebody on your team tried running ASP.NET on ARM?

jkotas avatar Jul 19 '16 12:07 jkotas

If you want to program in C# just forget about dotnet and use mono (http://www.mono-project.com).

Oh believe me I tried - this was the first thing. The problem is I don't want to use ASP .NET 4 but ASP.NET Core(kestrel) wich works on windows but compiled when moved to linux does not work on mono (451 profile) Simple Hello world without Kestrel done the same way works. There are issues arround the net about this.

I am at the point where just nothing works properly :-)

tomaszchacuk avatar Jul 19 '16 13:07 tomaszchacuk

Friend of mine had issues with network sockets in latest mono version. We solved it reverting mono to one of previous release versions (sorry I don't remember exact numbers).

mkborg avatar Jul 19 '16 13:07 mkborg

@leemgs Have you or somebody on your team tried running ASP.NET on ARM?

Still Not. Most of the members concentrate on .NET Core's stabilization (both CoreCLR and CoreFX unit-tests) after enabling .NET Core on Linux/ARM32.

leemgs avatar Jul 19 '16 13:07 leemgs

I am intending to create some piece of software that would target ARM Linux (Ubuntu 16.04 + Rasppb....

@tomaszchacuk , If you try to build/run .NET Core (CoreCLR + CoreFX) for Raspberry Pi2 board + Ubuntu/ARM 14.04 32bit (hardfp), I recommend that you use Ubuntu 14.04 LTS X64 to avoid unnecessary engineering cost.

leemgs avatar Jul 19 '16 13:07 leemgs

.NET Core repos (CoreCLR, CoreFX, Core-Setup, CLI) are not yet enabled to build for Arm32 (on either Windows or Linux) in the open.

I need to have "something" and cannot wait with starting the project till the end of the year .

Enabling for Arm32 would mean to support building and testing, at minimum, the above 4 repos. If you must start immediately on this, the right thing would be to start enabling the various repos and bring them up. We can guide you in the process - and CoreCLR would be a good starting point.

What do you think?

gkhanna79 avatar Jul 19 '16 15:07 gkhanna79

@mkborg We ported our tooling (3D Game engine) using CoreCLR on ARM and it works quite nicely. I would not say it is completely broken although it is still in the early stages.

manu-st avatar Jul 20 '16 00:07 manu-st

We ported our tooling (3D Game engine) using CoreCLR on ARM and it works quite nicely

@manu-silicon , Yes You mentioned your status previously. :+1: Can you share us the demo (e.g. Youtube video or others) of 3D game engine that you have successfully ported on ARM Tegra board?

leemgs avatar Jul 20 '16 00:07 leemgs

@tomaszchacuk @jkotas I just tried the following 'Hello, World' example:

using System;
using System.IO;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;

namespace AspDotnetExample
{
  public class Runner
  {
    public static void Main(string[] args)
    {
      var host = new WebHostBuilder()
        .UseKestrel()
        .UseStartup<Service>()
        .Build();

      host.Run();
    }
  }

  public class Service
  {
    public void Configure(IApplicationBuilder app)
    {
      app.Run(async (context) => {
          await context.Response.WriteAsync(
              "Hello World. The Time is: " +
              DateTime.Now.ToString("hh:mm:ss tt"));

      });
    }
  }
}

I first build and publish the above example using dotnet from Ubuntu 14.04 (x64) where dotnet is available, and copy the published binaries into ARM device where we run CoreCLR unittest. Then, I just tried to run the example with corerun included in the testing binaries (CoreCLR + CoreFX):

Unfortunately, I just encountered the following error:

$ ./corerun ../hello_world.dll

Unhandled Exception: System.AggregateException: One or more errors occurred. (Unable to load DLL 'libuv': The specified module could not be found.
 (Exception from HRESULT: 0x8007007E)) ---> System.DllNotFoundException: Unable to load DLL 'libuv': The specified module could not be found.
 (Exception from HRESULT: 0x8007007E)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.NativeMethods.uv_loop_size()
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.loop_size()
   at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvLoopHandle.Init(Libuv uv)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelThread.ThreadStart(Object parameter)
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelEngine.Start(Int32 count)
   at Microsoft.AspNetCore.Server.Kestrel.KestrelServer.Start[TContext](IHttpApplication`1 application)
   at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start()
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host, CancellationToken token, String shutdownMessage)
   at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run(IWebHost host)
   at AspDotnetExample.Runner.Main(String[] args)

It seems that libuv is necessary, but currently it is missing in the testing environment.

@tomaszchacuk You may try this approach on your RPi. This approach requires only CoreCLR and CoreFX (CLI and core-setup are not required). Currently, it is possible to cross-build both CoreCLR and CoreFX for ARM/Linux although those are at the very early stage.

parjong avatar Jul 20 '16 00:07 parjong

(Unable to load DLL 'libuv': The specified module could not be found. It seems that libuv is necessary, but currently it is missing in the testing environment.

If the reason is only the lack of the libuv library, I recommend that @tomaszchacuk install libuv library manually on Raspberry Pi board as following:

rpi2@arm# sudo apt-get install gyp
rpi2@arm# wget http://dist.libuv.org/dist/v1.0.0-rc1/libuv-v1.0.0-rc1.tar.gz 
(The latest version is v1.9.1: http://dist.libuv.org/dist/v1.9.1/libuv-v1.9.1.tar.gz)
rpi2@arm# tar -xvf libuv-v1.0.0-rc1.tar.gz
rpi2@arm# cd libuv-v1.0.0-rc1/
rpi2@arm# ./gyp_uv.py -f make -Duv_library=shared_library
rpi2@arm# make -C out
rpi2@arm# sudo cp out/Debug/lib.target/libuv.so /usr/lib/libuv.so.1.0.0-rc1
rpi2@arm# sudo ln -s libuv.so.1.0.0-rc1 /usr/lib/libuv.so.1

Then run "rpi2@arm# k kestrel" command, 
Started

leemgs avatar Jul 20 '16 01:07 leemgs

@leemgs I do not have a video handy, but what we were able to run on the board is what we made compile on Linux x64 too. See the tweet we made about our Linux support (https://twitter.com/xenko3d/status/746146402850340864)

manu-st avatar Jul 20 '16 12:07 manu-st

@parjong I tried this approach. Installed libuv. The next problem was missing W2_32.dll.

I started trying to build corefx and corecls. CoreClr succeeded, but corefx. I will post the errors as soon as I return home

tomaszchacuk avatar Jul 20 '16 13:07 tomaszchacuk

The next problem was missing W2_32.dll.

This means that you are using Windows-specific build of some library. Do you happen to have callstack of the failure?

jkotas avatar Jul 20 '16 13:07 jkotas

@jkotas

Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.DllNotFoundE xception: WS2_32.dll at (wrapper managed-to-native) Microsoft.AspNetCore.Server.Kestrel.Internal.Ne tworking.Libuv+NativeMethods:WSAIoctl (intptr,int,int_,uint,int_,int,uint&,intpt r,intptr) at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.tcp_bind_wind ows_extras (Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle handle) [0x0001f] in :0 at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.tcp_bind (Mic rosoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle handle, Microso ft.AspNetCore.Server.Kestrel.Internal.Networking.SockAddr& addr, System.Int32 fl ags) [0x00023] in :0 at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.Bind (M icrosoft.AspNetCore.Server.Kestrel.ServerAddress address) [0x0004a] in :0 at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.TcpListenerPrimary.Create ListenSocket () [0x00040] in :0 at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Listener+<>c. b__6_0 (System.Object state) [0x00012] in :0 [MVID] 7fa2145c3191420fad86bd0c6af65de7 1,2,3,4,5 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] i n :0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Thre ading.Tasks.Task task) [0x0004e] in :0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNoti fication (System.Threading.Tasks.Task task) [0x0002e] in :0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.T asks.Task task) [0x0000b] in :0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwait er.GetResult () [0x00000] in :0 at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.ListenerPrimary+d__11.MoveNext () [0x000f5] in :0 [MVID] 7fa2145c3191420fad86bd0c6af65de7 5 [MVID] ef160044a2e841e9b5a8b2ccca1a98ad 0,1,2,3,4 --- End of inner exception stack trace --- at System.Threading.Tasks.Task.ThrowIfExceptional (System.Boolean includeTaskC anceledExceptions) [0x00014] in :0 at System.Threading.Tasks.Task.Wait (System.Int32 millisecondsTimeout, System. Threading.CancellationToken cancellationToken) [0x00052] in :0
at System.Threading.Tasks.Task.Wait () [0x00000] in :0 at Microsoft.AspNetCore.Server.Kestrel.Internal.KestrelEngine.CreateServer (Mi crosoft.AspNetCore.Server.Kestrel.ServerAddress address) [0x000e1] in :0 [MVID] 7fa2145c3191420fad86bd0c6af65de7 3 [MVID] ef160044a2e841e9b5a8b2ccca1a98ad 0,1,2 ---> (Inner Exception #0) System.DllNotFoundException: WS2_32.dll at (wrapper managed-to-native) Microsoft.AspNetCore.Server.Kestrel.Internal.Ne tworking.Libuv+NativeMethods:WSAIoctl (intptr,int,int_,uint,int_,int,uint&,intpt r,intptr) at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.tcp_bind_wind ows_extras (Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle handle) [0x0001f] in :0 at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.Libuv.tcp_bind (Mic rosoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle handle, Microso ft.AspNetCore.Server.Kestrel.Internal.Networking.SockAddr& addr, System.Int32 fl ags) [0x00023] in :0 at Microsoft.AspNetCore.Server.Kestrel.Internal.Networking.UvTcpHandle.Bind (M icrosoft.AspNetCore.Server.Kestrel.ServerAddress address) [0x0004a] in :0 at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.TcpListenerPrimary.Create ListenSocket () [0x00040] in :0 at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.Listener+<>c. b__6_0 (System.Object state) [0x00012] in :0 [MVID] 7fa2145c3191420fad86bd0c6af65de7 1,2,3,4,5 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] i n :0 at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Thre ading.Tasks.Task task) [0x0004e] in :0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNoti fication (System.Threading.Tasks.Task task) [0x0002e] in :0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.T asks.Task task) [0x0000b] in :0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable+ConfiguredTaskAwait er.GetResult () [0x00000] in :0 at Microsoft.AspNetCore.Server.Kestrel.Internal.Http.ListenerPrimary+d__11.MoveNext () [0x000f5] in :0 [MVID] 7fa2145c3191420fad86bd0c6af65de7 5 [MVID] ef160044a2e841e9b5a8b2ccca1a98ad 0,1,2,3,4<---

[ERROR] FATAL UNHANDLED EXCEPTION: Nested exception trying to figure out what we nt wrong

tomaszchacuk avatar Jul 20 '16 22:07 tomaszchacuk

This looks like you are running with Windows-specific build of System.Runtime.InteropServices.RuntimeInformation.dll. You need to get the Linux-specific build - when you are publishing the standalone app to copy over, make sure to publish it for Linux.

jkotas avatar Jul 20 '16 23:07 jkotas

In this case you mean publishing on Windows (donet publish ...) for Linux , right ?

tomaszchacuk avatar Jul 21 '16 06:07 tomaszchacuk

Right.

jkotas avatar Jul 21 '16 10:07 jkotas

ok after publishing to linux I have another exception:

System.TypeInitializationException: The type initializer for 'Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure.Constants' threw an exception. ---> System.DllNotFoundException: System.Native at (wrapper managed-to-native) Interop+Sys:GetUnixNamePrivate () at Interop+Sys.GetUnixName () [0x00000] in :0 at System.Runtime.InteropServices.RuntimeInformation.IsOSPlatform (System.Runtime.InteropServices.OSPlatform osPlatform) [0x00009] in :0 at Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure.Constants.GetECONNRESET () [0x00005] in :0 at Microsoft.AspNetCore.Server.Kestrel.Internal.Infrastructure.Constants..cctor () [0x00000] in :0 [MVID] 7fa2145c3191420fad86bd0c6af65de7 3,4 [MVID] 862459bd886947438b3fcf70c862f252 1,2 --- End of inner exception stack trace --- at Microsoft.AspNetCore.Hosting.Internal.WebHost.Start () [0x00053] in :0 at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run (Microsoft.AspNetCore.Hosting.IWebHost host, System.Threading.CancellationToken token, System.String shutdownMessage) [0x00002] in :0 at Microsoft.AspNetCore.Hosting.WebHostExtensions.Run (Microsoft.AspNetCore.Hosting.IWebHost host) [0x0002e] in :0 at ConsoleApplication.Program.Main (System.String[] args) [0x00016] in :0 [MVID] 0816638d468e4be5bd8e0692994db5f5 3 [MVID] 151cad73211e43ce93bfdfc0a194d607 0,1,2 [ERROR] FATAL UNHANDLED EXCEPTION: Nested exception trying to figure out what went wrong

built by :

dotnet publish -r ubuntu.16.04-x64

In publish directory i have files : System.Native.as and System.Natiuve.so Any further ideas ?

tomaszchacuk avatar Jul 22 '16 16:07 tomaszchacuk