Skip to content

SH installs wrong architecture on ARM64 host, ARM32 OS #16

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

Closed
directhex opened this issue May 29, 2019 · 8 comments
Closed

SH installs wrong architecture on ARM64 host, ARM32 OS #16

directhex opened this issue May 29, 2019 · 8 comments
Assignees
Labels
bug Something isn't working maintenance-mode-prerequisite Maintenance mode prerequisites triaged

Comments

@directhex
Copy link

Issue Description

get_machine_architecture contains the following:

https://github.com/microsoft/azure-pipelines-tasks/blob/08914a70defbdbe73b2bb87e8d0663bdbeb248e0/Tasks/UseDotNetV2/externals/get-os-distro.sh#L159-L178

This is... fundamentally not how uname should be used.

  1. uname refers to the profile of the running kernel, not the executing environment. It can be a 100% mismatch, and that's valid and fine. The .NET Core environment which gets installed needs to match the executing environment, not the kernel.

Some examples:

(xenial-armhf)root@xam-softiron-16:/# uname -a
Linux xam-softiron-16 4.15.0-50-generic dotnet/cli#54~16.04.1-Ubuntu SMP Wed May 8 15:55:41 UTC 2019 aarch64 aarch64 aarch64 GNU/Linux
(xenial-armhf)root@xam-softiron-16:/# file /bin/bash
/bin/bash: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib, for GNU/Linux 3.2.0, BuildID[sha1]=9a214a5bbfe98a862fd835fdcbfa1d9f8dabff0e, stripped
root@breakfast:/# uname -a
Linux breakfast 4.15.0-50-generic dotnet/cli#54-Ubuntu SMP Mon May 6 18:46:08 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
root@breakfast:/# file /bin/bash 
/bin/bash: ELF 32-bit LSB shared object, Intel 80386, version 1 (SYSV), dynamically linked, interpreter /lib, for GNU/Linux 3.2.0, BuildID[sha1]=d3d60e9d8193746d270cd74bcb2f5742ffc65d48, stripped

In both these cases, these are 64-bit kernels with 32-bit executing environments. There is no guarantee that 64-bit libraries are available to execute 64-bit code, and it is a 32-bit .NET Core which should be installed.

  1. armv7l is not the only valid uname which requires a 32-bit .NET Core. 32-bit compatibility kernel profile on 64-bit ARM kernels will show armv8l:
$ uname -a
Linux xam-softiron-15 4.15.0-50-generic dotnet/cli#54~16.04.1-Ubuntu SMP Wed May 8 15:55:41 UTC 2019 armv8l armv8l armv8l GNU/Linux

ref: microsoft/azure-pipelines-tasks#10439

@johnbeisner
Copy link

@directhex
'get-os-distro.sh' appears to be a partial copy of https://dot.net/v1/dotnet-install.sh
https://dot.net/v1/dotnet-install.sh and https://dot.net/v1/dotnet-install.ps1 are supported by the CLI team and .Net core as an SDK acquisition method. More to the point, https://dot.net/v1/dotnet-install.sh has an 'architecture' parameter expressly for the situation you have described. Please try this command:
./dotnet-install.sh --architecture arm
Let me know if this works for you.

@directhex
Copy link
Author

The --architecture override works, but the auto-detection should still be corrected.

dotnet: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-armhf.so.3, for GNU/Linux 2.6.32, BuildID[sha1]=e152ba87e063bbbf82e6dd5a94959d433b1661e1, stripped

Also, I don't think it can be passed through if installing via the Arcade eng/common/tools.sh wrapper?

@marek-safar
Copy link

@livarcocc is this something what will be addressed or we need to work on a workaround?

@directhex
Copy link
Author

My suspicion that this prevents use of Arcade is correct. The InitializeDotNetCli function does not pass through the architecture (you'd need to bypass it and call into InstallDotNetSdk directly, which opens another can of worms)

Rather than add workarounds to Arcade, I feel it should be fixed properly, here.

@bishal-pdMSFT
Copy link

'get-os-distro.sh' appears to be a partial copy of https://dot.net/v1/dotnet-install.sh
https://dot.net/v1/dotnet-install.sh and https://dot.net/v1/dotnet-install.ps1 are supported by the CLI team and .Net core as an SDK acquisition method

@johnbeisner @livarcocc yes, you are right. 'get-os-distro.sh' is a partial copy which uses install scripts as a reference.

More to the point, https://dot.net/v1/dotnet-install.sh has an 'architecture' parameter expressly for the situation you have described. Please try this command:
./dotnet-install.sh --architecture arm

This will require all tools depending on the install scripts to expose additional parameter for architecture. Please note that the default behavior still will be different for windows and linux. dotnet-install.ps1 installs as per process architecture and dotnet-install.sh installs as per kernel architecture. For default inputs, these two should be consistent.

@bishal-pdMSFT
Copy link

@johnbeisner any comment on this thread? Are you planning to make changes to ensure that both Windows and Linux install for same architecture? This will ensure that downstream tools won't have to tke care of this.

@hiyadav
Copy link

hiyadav commented Jun 26, 2019

@livarcocc is this something what will be addressed or we need to work on a workaround?

Hey,
Is there a plan for this, is this getting addressed soon ?

directhex referenced this issue in directhex/azure-pipelines-agent Dec 9, 2019
directhex referenced this issue in directhex/arcade Dec 9, 2019
`uname -m` on ARM64 processors using 32-bit personality shows as `armv8l`, not `armv7l`. See https://github.com/torvalds/linux/blob/cef7298262e9af841fb70d8673af45caf55300a1/arch/arm64/include/asm/compat.h#L22

This allows building on 64-bit ARM machines in a 32-bit environment. Without this patch, the build system thinks 32-bit personality on ARM64 is linux-x64, and the build explodes accordingly.

32-bit personality allows building ARM32 code on modern ARM64 systems, which in this day and age are easier to obtain with decent performance characteristics.

```
builder@xam-softiron-1:~$ uname -a
Linux xam-softiron-1 4.17.0ilp32-31333-gb2d7ec3 dotnet#1 SMP Tue Oct 16 16:37:20 EDT 2018 aarch64 aarch64 aarch64 GNU/Linux
builder@xam-softiron-1:~$ linux32 uname -a
Linux xam-softiron-1 4.17.0ilp32-31333-gb2d7ec3 dotnet#1 SMP Tue Oct 16 16:37:20 EDT 2018 armv8l armv8l armv8l GNU/Linux
```

Closes: https://github.com/dotnet/cli/issues/11437
@johnbeisner johnbeisner removed their assignment Dec 23, 2019
@msftgits msftgits transferred this issue from dotnet/cli Jan 31, 2020
@bekir-ozturk bekir-ozturk transferred this issue from dotnet/sdk May 19, 2020
@donJoseLuis donJoseLuis added the bug Something isn't working label May 28, 2020
@donJoseLuis donJoseLuis changed the title dotnet-install.sh architecture detection installs wrong architecture on ARM64 host, ARM32 OS SH installs wrong architecture on ARM64 host, ARM32 OS May 28, 2020
@AR-May AR-May self-assigned this Nov 5, 2020
@AR-May AR-May added the maintenance-mode-prerequisite Maintenance mode prerequisites label Nov 6, 2020
@AR-May
Copy link
Member

AR-May commented Dec 7, 2020

There are two failure cases in the issue:
• The kernel is 64-bit, the kernel truthfully reports that it is 64-bit, but the OS is 32-bit
• The kernel is 64-bit, the kernel lies and reports that it is 32-bit, but the OS is 32-bit
After the discussion with the team, we came to the decision not to fix the first case. The install scripts are going to a maintenance mode and this one does not seem a high priority point of this issue at the moment.
The second case was fixed by PR #111.

@AR-May AR-May closed this as completed Dec 7, 2020
directhex pushed a commit to mono/linux-packaging-fsharp that referenced this issue Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working maintenance-mode-prerequisite Maintenance mode prerequisites triaged
Projects
None yet
Development

No branches or pull requests

8 participants