runtime icon indicating copy to clipboard operation
runtime copied to clipboard

Enabling Linux ARM32 for .NET Core

Open hqueue opened this issue 9 years ago • 155 comments

Host: Ubuntu 14.04 x64 Target: Ubuntu 14.04 or(and) 16.04 ARM, Ubuntu 14.04 ARM Softfp and Tizen

To enable core-setup for Linux ARM32, we are going to follow steps suggested in PR dotnet/core-setup#712.

ARM hardfp

Common

  • [x] stable default clang version for cross compilation (#1411)
  • [x] Use same logic to prepare rootfs across dotnet (#1432)

CoreCLR

  • [x] Update CoreCLR to generate nuget packages of CoreCLR (PR dotnet/coreclr#8421)
  • [x] Remaining CoreCLR ARM32 issues tracked by issue dotnet/coreclr#8549. Still on going

CoreFX

  • [x] Add RID for Linux/ARM (dotnet/corefx#14161)
  • [x] Add Xenial (Ubuntu 16.04) support for build-rootfs.sh (issue https://github.com/dotnet/corefx/issues/14538)
  • [x] Make clang3.6 default toolset for cross arm32 build (issue https://github.com/dotnet/corefx/issues/15511)
  • [x] Enable CI support for Linux Arm32 (https://github.com/dotnet/coreclr/issues/9273, https://github.com/dotnet/corefx/pull/15900)
  • [x] Update CoreFX to generate nuget packages of CoreFX (issue dotnet/corefx#14298)
  • [x] Enable CoreFX Pipeline build support for Linux for Arm32 and publish packages.

core-setup For core-setup, we will follow steps below.

  • [x] Add support for Linux Arm32 RID (PR dotnet/core-setup#712)
  • [x] Preparing ROOTFS for cross-compilation Infrastructure (issue dotnet/core-setup#729, PR dotnet/core-setup#747)
  • [x] Enable cross compiling corehost for Linux/ARM (issue dotnet/runtime#2547, PR dotnet/core-setup#749, dotnet/core-setup#766, dotnet/core-setup#812 )
  • [x] Update build script to enable cross building (PR dotnet/core-setup#712)
  • [x] Update build script to enable downloading and packaging for Linux/ARM (PR dotnet/core-setup#712)
  • [x] Build nuget packages for the host and Microsoft.NETCore.App metapackage (PR dotnet/core-setup#712)
  • [x] Make clang3.6 default toolset for cross arm32 build (issue https://github.com/dotnet/core-setup/issues/1322)
  • [x] Enable CI support for Linux Arm32 (issue https://github.com/dotnet/core-setup/issues/790)(PR https://github.com/dotnet/core-setup/pull/1512)
  • [x] Enable Pipeline build support for Linux Arm32 (issue https://github.com/dotnet/core-setup/issues/789)
  • [x] Update Core-Setup readme.md to reflect the download location of Linux Arm32 archive binaries.

For example, we want to build core-setup for Linux/ARM using following command.

$ ./build.sh  --env-vars DISABLE_CROSSGEN=1,TARGETPLATFORM=arm,TARGETRID=ubuntu.14.04-arm,CROSS=1,ROOTFS_DIR=/home/jyoung/git/dotnet/rootfs-coreclr/arm/

ASP.NET

  • [x] Build LibUV for Arm32 (Issue https://github.com/aspnet/libuv-build/issues/19).

ARM softfp

We will use armel for arm-softfp through out the dotnet.

Common

  • [x] stable default clang version for cross compilation (#1411)
  • [x] Use same logic to prepare rootfs across dotnet (#1432)

Debian.8

CoreFX - Part1

  • [x] Add RID for armel (dotnet/corefx#14792)

CoreCLR

  • [x] Use armel for arm-softfp through out the dotnet. (https://github.com/dotnet/coreclr/issues/8770, https://github.com/dotnet/coreclr/pull/8771)
  • [x] Generate packages for armel RID (dotnet/coreclr#8827)
  • [x] Prepare ROOTFS for cross-compilation Infrastructure (already available)

CoreFX - Part2

  • [x] Use armel for arm-softfp through out the dotnet. (https://github.com/dotnet/corefx/pull/14803)
  • [x] Prepare ROOTFS for cross-compilation Infrastructure (already available)

core-setup For core-setup, we will follow steps below.

  • [x] Use armel for arm-softfp through out the dotnet (#1025)
  • [x] Generate nupkgs and tarball for debian.8-armel (#1025)
./build.sh --skiptests --env-vars DISABLE_CROSSGEN=1,TARGETPLATFORM=armel,TARGETRID=debian.8-armel,CROSS=1,ROOTFS_DIR=/home/jyoung/git/dotnet/rootfs/armel

Tizen 4.0.0

CoreFX - Part1

  • [x] Add RID for Tizen

CoreCLR

  • [x] Prepare ROOTFS for cross-compilation Infrastructure (https://github.com/dotnet/coreclr/pull/8781)
  • [x] Enable PipeLine build support for Linux armel (Tizen) (dotnet/coreclr#9689)

CoreFX - Part2

  • [x] Prepare ROOTFS for cross-compilation Infrastructure (https://github.com/dotnet/corefx/pull/14844)
  • [x] Prepare host packages for Tizen.4.0.0-armel (https://github.com/dotnet/corefx/issues/16175)
  • [x] Remove workaround to prevent armel package restore (https://github.com/dotnet/corefx/issues/16174)
  • [x] Enable CoreFX Pipeline build support for Linux for armel (Tizen) and publish packages (dotnet/corefx#16335)

core-setup For core-setup, we will follow steps below.

  • [x] Prepare ROOTFS for cross-compilation Infrastructure (#1025)
  • [x] Generate nupkgs and tarball for tizen.4.0.0-armel (#1025)
  • [x] Enable Pipeline build support for Linux armel (Tizen) (#1566)

dotnet-ci

  • [x] Add Tizen OS to Machine map (https://github.com/dotnet/dotnet-ci/pull/603)
./build.sh -c Release --skiptests --env-vars DISABLE_CROSSGEN=1,TARGETPLATFORM=armel,TARGETRID=tizen.4.0.0-armel,CROSS=1,ROOTFS_DIR=/home/jyoung/git/dotnet/rootfs/armel-tizen

Results

ubuntu.14.04-arm (Latest build is available at https://github.com/dotnet/core-setup#daily-builds) dotnet-ubuntu.14.04-arm.1.2.0-beta-001291-00.tar.gz (Last updated on Jan 19) dotnet-sdk-ubuntu.14.04-arm.1.0.0-preview5-004431.tar.gz ubuntu.16.04-arm (Latest build is available at https://github.com/dotnet/core-setup#daily-builds) dotnet-ubuntu.16.04-arm.1.2.0-beta-001291-00.tar.gz (Last updated on Jan 19) dotnet-sdk-ubuntu.16.04-arm.1.0.0-preview5-004431.tar.gz debian.8-armel dotnet-debian.8-armel.1.2.0-beta-001271-00.tar.gz tizen.4.0.0-armel dotnet-tizen.4.0.0-armel.1.2.0-beta-001273-00.tar.gz

hqueue avatar Dec 05 '16 05:12 hqueue

CC @schellap @ramarag @janvorli

gkhanna79 avatar Dec 05 '16 21:12 gkhanna79

As I have mentioned in the discussion in dotnet/core-setup#724, I believe that we should be consistent in the way we do cross build over our repos. That means to use rootfs and to do the cross build using clang and not GCC. The same way we do it in CoreCLR and CoreFX. I hope we can reuse the logic from the build.sh in CoreCLR here.

janvorli avatar Dec 06 '16 14:12 janvorli

@hqueue @hseok-oh Is Ubuntu 14.04 an intended target for Arm32?

gkhanna79 avatar Dec 12 '16 18:12 gkhanna79

@gkhanna79 AFAIK default rid is ubuntu.14.04-arm for coreclr ARM and default ARM rootfs is trusty which is ubuntu 14.04.

hqueue avatar Dec 13 '16 02:12 hqueue

@hqueue @gkhanna79 RaspberryPI2 used ubuntu 14.04. (but no longer maintained) https://wiki.ubuntu.com/ARM/RaspberryPi

hseok-oh avatar Dec 13 '16 02:12 hseok-oh

@hseok-oh If Ubuntu 14.04 is not maintained and supported, is there a specific reason to support it for Linux Arm32? If not, it will simplify bunch of things (e.g. libcoreclrtraceptprovider.so builds just fine for 16.04 but needs additional work for 14.04).

What do you think?

gkhanna79 avatar Dec 13 '16 17:12 gkhanna79

AFAIK default rid is ubuntu.14.04-arm for coreclr ARM and default ARM rootfs is trusty which is ubuntu 14.04

I don't know who chose those defaults or why. Could it be cause Tizen OS is based upon Ubuntu 14.04? do we build libcoreclrtraceptprovider.so for Tizen?

gkhanna79 avatar Dec 13 '16 17:12 gkhanna79

@kouvel This is the Linux Arm32 main work-list issue.

gkhanna79 avatar Dec 13 '16 18:12 gkhanna79

CC @schellap

gkhanna79 avatar Dec 13 '16 18:12 gkhanna79

AFAIK default rid is ubuntu.14.04-arm for coreclr ARM and default ARM rootfs is trusty which is ubuntu 14.04

I don't know who chose those defaults or why. Could it be cause Tizen OS is based upon Ubuntu 14.04? do we build libcoreclrtraceptprovider.so for Tizen?

@gkhanna79 I don't think it's related to Tizen OS. The most possible explanation will be that ubuntu 14.04 is selected because of devices (e.g. ARM Emulator, Raspberry pi 2 and etc.) which were used to bring up CoreCLR ARM. Please check out https://github.com/dotnet/coreclr/issues/3805 for ARM emulator which is used at the very early stage of CoreCLR ARM32 bring up.

hqueue avatar Dec 14 '16 05:12 hqueue

Thanks for the explanation @hqueue. For now, we can continue to build for both 14.04 and 16.04 and see how far we will need the 14.04 implementation.

With regards to the emulator, I noticed that in CoreCLR repo, we bootup the emulator and setup the rootfs within it and then perform the build. This is different from the build instructions we have at https://github.com/dotnet/coreclr/blob/master/Documentation/building/cross-building.md where it comprises of two steps:

  1. Build rootfs for an architecture
  2. Perform a cross build of the repo

We strive hard to ensure that CI builds the same way as any developer would. Since the above steps are how any developer in the community would be expected to build for Arm32, what do you think of updating the CI script to do just that and not rely on emulator to be present for performing the build?

Secondly, the emulator should only be required to deploy binaries and execute tests. I notice that we only run 22 tests within the emulator, even though the repo has 11K+ tests. Do these 22 tests add any value from the CI perspective (e.g. here is a log of a recent PR that shows the 22 tests that ran - https://ci.dot.net/job/dotnet_coreclr/job/master/job/arm_emulator_cross_debug_ubuntu_prtest/1080/consoleFull) since they dont seem to cover key scenarios where breaks maybe introduced?

gkhanna79 avatar Dec 15 '16 20:12 gkhanna79

@gkhanna79 For the first question, I will call @sjsinju @wateret, since I'm not aware of the latest of ARM CI.

@sjsinju @wateret Can you please answer the first question above regarding CI and ARM emulator ?

For the second one, I also think tests are not sufficient to cover key sccenarios. We will look into them.

hqueue avatar Dec 16 '16 07:12 hqueue

@gkhanna79 CI cross-builds the same way as any developers would. You can check out arm32_ci_script.sh#L227. The emulator is only for running tests. Of course, we still need pre-built rootfs to cross-build though.

One more thing that may be confusing is that the CI has arm-softfp rootfs only which cannot be created by 'any developers'. There is my work on CoreFX for enabling arm-hardfp(ubuntu 14.04). After it's done I will apply it to CoreCLR as well.

wateret avatar Dec 20 '16 05:12 wateret

@gkhanna79 I couldn't find where libuv.so is built. Could you give me an advice?

jyoungyun avatar Dec 20 '16 07:12 jyoungyun

@jyoungyun not sure if it's the way libuv is built for .NET, but for raspberry pi the instructions so far have been to download it from the libuv project & compile it:

See the these comments from @leemgs related to dotnet/coreclr#6321

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

That worked for me to get Kestrel up & running on Raspberry Pi; but note that newer versions of libuv are now available at http://dist.libuv.org/dist/

qmfrederik avatar Dec 20 '16 12:12 qmfrederik

CI cross-builds the same way as any developers would.

@wateret My point is that we should decouple cross building in CI from emulator. The nuance is that in CI, we setup rootfs from emulator and then perform cross-build while a regular developer will not. My suggestion is to fix the script to do the following:

  1. Without the emulator, perform the cross build (e.g. cross/build-rootfs.sh arm)
  2. Load the emulator only for running tests. Thus, if we were to decide that emulator may no longer be needed for testing for some reason, then cross-build continues to function as it is expected.

gkhanna79 avatar Dec 20 '16 18:12 gkhanna79

@hqueue did you find anything interesting about running the 22 tests in CI?

gkhanna79 avatar Dec 20 '16 18:12 gkhanna79

@qmfrederik Thank you for your answer. What you are talking about is how to download libuv.so directly. But I want to know where the libuv*.nupkg is generated. The NETCoreApp is dependent on libuv module so I wanna generate libuv*.nupkg for arm.

jyoungyun avatar Dec 21 '16 01:12 jyoungyun

@gkhanna79

we setup rootfs from emulator and then perform cross-build while a regular developer will not.

Just make things clear, the emulator image is nothing but pre-built rootfs. Of course the emulator also needs it for running tests.

For the first one you suggested, basically I agree with you. However it takes pretty long to build rootfs with build-rootfs.sh. As far as I remember it took 1-2 hours on my linux machine. I'm not sure if it is acceptable. For the second one, the emulator is loaded only for running tests already. Build does not run on the emulator. It cross-builds.

wateret avatar Dec 21 '16 04:12 wateret

did you find anything interesting about running the 22 tests in CI?

@gkhanna79 Those 22 tests are TCs where we observed regression frequently when brining-up CoreCLR for Linux ARM32. Therefore the coverage of 22 tests does not cover the code which is not modified freqeuently. However we cannot run all TCs (11K+) with ARM emulator becasue it took very long time and we faced timeout in CI environment.

I also think we need more TCs for CI, but not sure about how to choose candidates. Can you suggest any options ?

cc: @jyoungyun

hqueue avatar Dec 21 '16 06:12 hqueue