Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Enable building for arm64 on arm64 #8468

Merged
merged 1 commit into from Oct 8, 2019
Merged

Conversation

omajid
Copy link
Member

@omajid omajid commented Oct 4, 2019

To enable building core-setup on arm64 machines (not cross compiled), we need
to do a few things:

  • Set the right TargetArchitecture

    When TargetArchitecture is not explicitly specified and when the currently
    running architecture is Arm64, use arm64 as the TargetArchitecture. Don't
    always use the currently running architecture as that doesn't play well with
    an x86 Visual Studio trying to create x64 builds.

  • Use the right coreclr JIT

    If we are cross-compiling, we need to use the x86_arm64 libclrjit.so. But if
    we are building on an arm64 machine, we need to filter the list of found
    libclrjit.so files to pick the normal-RID (eg, linux-arm64) libclrjit.so from
    the two:

    ./.packages/transport.runtime.linux-arm64.microsoft.netcore.jit/<version>/runtimes/linux-arm64/native/libclrjit.so
    ./.packages/transport.runtime.linux-arm64.microsoft.netcore.jit/<version>/runtimes/x64_arm64/native/libclrjit.so
    

This is another attempt at #7696. It tries to be more conservative by only modifying TargetArchitecture/Platform for arm64.

cc @dagood @vitek-karas

To enable building core-setup on arm64 machines (not cross compiled), we need
to do a few things:

- Set the right TargetArchitecture

  When `TargetArchitecture` is not explicitly specified and when the currently
  running architecture is Arm64, use arm64 as the `TargetArchitecture`. Don't
  always use the currently running architecture as that doesn't play well with
  an x86 Visual Studio trying to create x64 builds.

- Use the right coreclr JIT

  If we are cross-compiling, we need to use the x86_arm64 libclrjit.so. But if
  we are building on an arm64 machine, we need to filter the list of found
  libclrjit.so files to pick the normal-RID (eg, linux-arm64) libclrjit.so from
  the two:

  ./.packages/transport.runtime.linux-arm64.microsoft.netcore.jit/<version>/runtimes/linux-arm64/native/libclrjit.so
  ./.packages/transport.runtime.linux-arm64.microsoft.netcore.jit/<version>/runtimes/x64_arm64/native/libclrjit.so
@omajid
Copy link
Member Author

omajid commented Oct 7, 2019

Rebased to resolve conflicts with master branch. Testing on arm64 now.

Copy link
Member

@dagood dagood left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Looks good and targeted.

@dagood
Copy link
Member

dagood commented Oct 7, 2019

@omajid Is this looking ok in your testing, good to merge?

@omajid
Copy link
Member Author

omajid commented Oct 8, 2019

Yes! A build works. I have not done any extended testing

@dagood dagood merged commit 57ba280 into dotnet:master Oct 8, 2019
omajid added a commit to omajid/dotnet-aspnetcore that referenced this pull request Nov 11, 2019
This commit allows ASP.NET Core to be built on arm64 machines directly,
without relying on cross-compilation.

There's a few changes in here:

1. Ask msbuild to look into the BuildArchitecture

   By default, our build systems assums the machine is x64. This
   modifies the build configuration to check the architecture of the
   currently running build machine, and set BuildArchitecture to that.

2. Fix crossgen in Microsoft.AspNetCore.App.Runtime

   We run crossgen for supported architectures (including x64 and
   arm64). For that, we need a jit that we can point crossgen to.
   Generally, we can rely on the build scripts to find the right
   `libclrjit.so`. However, arm64 has multiple `libclirjit.so`, for
   different use-cases. There's one for arm64 (for running on arm64) and
   there's another one for cross-compiling for arm64 on x64. We need to
   figure out and use the right one explicitly rather than assuming the
   right one gets picked up.

   See dotnet/core-setup#8468 for similar
   changes made in core-setup.

This also needs dotnet#14790 to fully
work on arm64.
JunTaoLuo pushed a commit to dotnet/aspnetcore that referenced this pull request Nov 11, 2019
This commit allows ASP.NET Core to be built on arm64 machines directly,
without relying on cross-compilation.

There's a few changes in here:

1. Ask msbuild to look into the BuildArchitecture

   By default, our build systems assums the machine is x64. This
   modifies the build configuration to check the architecture of the
   currently running build machine, and set BuildArchitecture to that.

2. Fix crossgen in Microsoft.AspNetCore.App.Runtime

   We run crossgen for supported architectures (including x64 and
   arm64). For that, we need a jit that we can point crossgen to.
   Generally, we can rely on the build scripts to find the right
   `libclrjit.so`. However, arm64 has multiple `libclirjit.so`, for
   different use-cases. There's one for arm64 (for running on arm64) and
   there's another one for cross-compiling for arm64 on x64. We need to
   figure out and use the right one explicitly rather than assuming the
   right one gets picked up.

   See dotnet/core-setup#8468 for similar
   changes made in core-setup.

This also needs #14790 to fully
work on arm64.
omajid added a commit to omajid/dotnet-source-build that referenced this pull request Nov 12, 2019
This chnage allows source-build to be cloned and built on arm64
 machines. I have tested this on RHEL 8 aarch64.

This change includes backports of the following pull-requests
 which have been merged into their respective master branches:

- dotnet/aspnetcore#14790
- dotnet/aspnetcore#15354
- dotnet/installer#4102
- dotnet/core-setup#8468
- dotnet/corefx#40453
omajid added a commit to omajid/dotnet-source-build that referenced this pull request Nov 12, 2019
This chnage allows source-build to be cloned and built on arm64
 machines. I have tested this on RHEL 8 aarch64.

This change includes backports of the following pull-requests
 which have been merged into their respective master branches:

- dotnet/aspnetcore#14790
- dotnet/aspnetcore#15354
- dotnet/installer#4102
- dotnet/core-setup#8468
- dotnet/corefx#40453
omajid added a commit to omajid/dotnet-source-build that referenced this pull request Nov 12, 2019
This chnage allows source-build to be cloned and built on arm64
 machines. I have tested this on RHEL 8 aarch64.

This change includes backports of the following pull-requests
 which have been merged into their respective master branches:

- dotnet/aspnetcore#14790
- dotnet/aspnetcore#15354
- dotnet/installer#4102
- dotnet/core-setup#8468
- dotnet/corefx#40453
omajid added a commit to omajid/dotnet-source-build that referenced this pull request Nov 12, 2019
This chnage allows source-build to be cloned and built on arm64
 machines. I have tested this on RHEL 8 aarch64.

This change includes backports of the following pull-requests
 which have been merged into their respective master branches:

- dotnet/aspnetcore#14790
- dotnet/aspnetcore#15354
- dotnet/installer#4102
- dotnet/core-setup#8468
- dotnet/corefx#40453
omajid added a commit to omajid/dotnet-source-build that referenced this pull request Nov 15, 2019
This chnage allows source-build to be cloned and built on arm64
 machines. I have tested this on RHEL 8 aarch64.

This change includes backports of the following pull-requests
 which have been merged into their respective master branches:

- dotnet/aspnetcore#14790
- dotnet/aspnetcore#15354
- dotnet/installer#4102
- dotnet/core-setup#8468
- dotnet/corefx#40453
omajid added a commit to omajid/dotnet-source-build that referenced this pull request Nov 15, 2019
This chnage allows source-build to be cloned and built on arm64
 machines. I have tested this on RHEL 8 aarch64.

This change includes backports of the following pull-requests
 which have been merged into their respective master branches:

- dotnet/aspnetcore#14790
- dotnet/aspnetcore#15354
- dotnet/installer#4102
- dotnet/core-setup#8468
- dotnet/corefx#40453
omajid added a commit to omajid/dotnet-source-build that referenced this pull request Nov 15, 2019
This chnage allows source-build to be cloned and built on arm64
 machines. I have tested this on RHEL 8 aarch64.

This change includes backports of the following pull-requests
 which have been merged into their respective master branches:

- dotnet/aspnetcore#14790
- dotnet/aspnetcore#15354
- dotnet/installer#4102
- dotnet/core-setup#8468
- dotnet/corefx#40453
omajid added a commit to omajid/dotnet-source-build that referenced this pull request Nov 15, 2019
This chnage allows source-build to be cloned and built on arm64
 machines. I have tested this on RHEL 8 aarch64.

This change includes backports of the following pull-requests
 which have been merged into their respective master branches:

- dotnet/aspnetcore#14790
- dotnet/aspnetcore#15354
- dotnet/installer#4102
- dotnet/core-setup#8468
- dotnet/corefx#40453
omajid added a commit to omajid/dotnet-source-build that referenced this pull request Nov 15, 2019
This chnage allows source-build to be cloned and built on arm64
 machines. I have tested this on RHEL 8 aarch64.

This change includes backports of the following pull-requests
 which have been merged into their respective master branches:

- dotnet/aspnetcore#14790
- dotnet/aspnetcore#15354
- dotnet/installer#4102
- dotnet/core-setup#8468
- dotnet/corefx#40453
omajid added a commit to omajid/dotnet-source-build that referenced this pull request Nov 16, 2019
This chnage allows source-build to be cloned and built on arm64
machines. It shouldn't affect cross compilation at all, however. I have
tested this on RHEL 8 aarch64.

This change includes backports of the following pull-requests which have
been merged into their respective master branches:

- dotnet/aspnetcore#14790
- dotnet/aspnetcore#15354
- dotnet/installer#4102
- dotnet/core-setup#8468
- dotnet/corefx#40453

To support using darc on arm64, this commit removes the customizations
of LD_LIBRARY_PATH and instead forces darc to run again a .NET Core 3.0
runtime. This in-turn makes darc pick up the right libgit2sharp
automatically for the right set of platforms and architectures.

There's a number of existing build configuration that are
conditionalized on arm64, such as setting up a root file system. Those
they are actually only meant to be invoked when cross-compiling for
arm64 (on x86_64). This commit modifies those conditions to not apply
when building on an arm64 machine.
omajid added a commit to omajid/dotnet-source-build that referenced this pull request Nov 20, 2019
This change allows source-build to be cloned and built on arm64
machines. It shouldn't affect cross compilation at all, however. I have
tested this on RHEL 8 aarch64.

This change includes backports of the following pull-requests which have
been merged into their respective master branches:

- dotnet/aspnetcore#14790
- dotnet/aspnetcore#15354
- dotnet/installer#4102
- dotnet/core-setup#8468
- dotnet/corefx#40453

There's a number of existing build configuration that are
conditionalized on arm64, such as setting up a root file system. Those
they are actually only meant to be invoked when cross-compiling for
arm64 (on x86_64). This commit modifies those conditions to not apply
when building on an arm64 machine.
omajid added a commit to omajid/dotnet-source-build that referenced this pull request Nov 21, 2019
This change allows source-build to be cloned and built on arm64
machines. It shouldn't affect cross compilation at all, however. I have
tested this on RHEL 8 aarch64.

This change includes backports of the following pull-requests which have
been merged into their respective master branches:

- dotnet/aspnetcore#14790
- dotnet/aspnetcore#15354
- dotnet/installer#4102
- dotnet/core-setup#8468
- dotnet/corefx#40453

There's a number of existing build configuration that are
conditionalized on arm64, such as setting up a root file system. Those
they are actually only meant to be invoked when cross-compiling for
arm64 (on x86_64). This commit modifies those conditions to not apply
when building on an arm64 machine.
crummel pushed a commit to omajid/dotnet-source-build that referenced this pull request Nov 22, 2019
This change allows source-build to be cloned and built on arm64
machines. It shouldn't affect cross compilation at all, however. I have
tested this on RHEL 8 aarch64.

This change includes backports of the following pull-requests which have
been merged into their respective master branches:

- dotnet/aspnetcore#14790
- dotnet/aspnetcore#15354
- dotnet/installer#4102
- dotnet/core-setup#8468
- dotnet/corefx#40453

There's a number of existing build configuration that are
conditionalized on arm64, such as setting up a root file system. Those
they are actually only meant to be invoked when cross-compiling for
arm64 (on x86_64). This commit modifies those conditions to not apply
when building on an arm64 machine.
crummel pushed a commit to dotnet/source-build that referenced this pull request Nov 24, 2019
* Enable building on arm64

This change allows source-build to be cloned and built on arm64
machines. It shouldn't affect cross compilation at all, however. I have
tested this on RHEL 8 aarch64.

This change includes backports of the following pull-requests which have
been merged into their respective master branches:

- dotnet/aspnetcore#14790
- dotnet/aspnetcore#15354
- dotnet/installer#4102
- dotnet/core-setup#8468
- dotnet/corefx#40453

There's a number of existing build configuration that are
conditionalized on arm64, such as setting up a root file system. Those
they are actually only meant to be invoked when cross-compiling for
arm64 (on x86_64). This commit modifies those conditions to not apply
when building on an arm64 machine.

* Patch fixup.
omajid added a commit to omajid/dotnet-runtime that referenced this pull request Jul 17, 2020
crossgen2 (and by extension, runtime) fails to build on an arm64 box.
This is the error I see on Fedora 32 aarch64:

    ./build.sh
    ...
    crossgen2 -> artifacts/bin/coreclr/Linux.arm64.Debug/crossgen2/crossgen2.dll
    src/coreclr/src/tools/aot/crossgen2/crossgen2.csproj(87,5): error MSB3030: Could not copy the file "artifacts/bin/coreclr/Linux.arm64.Debug//x64/libjitinterface.so" because it was not found.

The file is there, just not under the `x64` directory:

    $ find -iname libjitinterface.so
    ./artifacts/bin/coreclr/Linux.arm64.Debug/libjitinterface.so
    ./artifacts/bin/coreclr/Linux.arm64.Debug/crossgen2/libjitinterface.so
    ./artifacts/obj/coreclr/Linux.arm64.Debug/src/tools/aot/jitinterface/libjitinterface.so

The actual bug is that crossgen2 seems to assume that if the build is
for an `arm64` RID, it's a cross-build, not a hosted build. Fix that by
explicitly checking `BuildArchitecture` as well.

Please see dotnet/corefx#40453 and
dotnet/core-setup#8468 for related fixes
enabling building for arm64 on an arm64 machine.

I have *not* verified this change in Visual Studio.
MichaelSimons pushed a commit to dotnet/source-build-externals that referenced this pull request Feb 8, 2022
* Enable building on arm64

This change allows source-build to be cloned and built on arm64
machines. It shouldn't affect cross compilation at all, however. I have
tested this on RHEL 8 aarch64.

This change includes backports of the following pull-requests which have
been merged into their respective master branches:

- dotnet/aspnetcore#14790
- dotnet/aspnetcore#15354
- dotnet/installer#4102
- dotnet/core-setup#8468
- dotnet/corefx#40453

There's a number of existing build configuration that are
conditionalized on arm64, such as setting up a root file system. Those
they are actually only meant to be invoked when cross-compiling for
arm64 (on x86_64). This commit modifies those conditions to not apply
when building on an arm64 machine.

* Patch fixup.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
3 participants