runtime: Illegal instruction on SAMA5D35 (ARMv7, VFPv3-D16) due to VMOV d16 usage
I have a single board computer that runs a SAMA5D35 cpu. I am running linux, and using dotnet 9. Here is my CPU’s information:
cat /proc/cpuinfo
processor : 0
model name : ARMv7 Processor rev 1 (v7l)
BogoMIPS : 33.00
Features : half thumb fastmult vfp edsp vfpv3 vfpv3d16 tls vfpv4
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xc05
CPU revision : 1
Hardware : Atmel SAMA5
Revision : 0000
Serial : 0000000000000000
The CPU states that it does support VFP.
I can build a simple HelloWorld project that just prints “Hello World”. I am building with dotnet publish -r linux-arm. Unfortunatly, when I try to run the app, I get an error: Illegal instruction (core dumped). Debugging with GDB reveals that it is due to a [VMOV](https://developer.arm.com/documentation/dui0473/m/vfp-instructions/vmov--between-one-arm-register-and-single-precision-vfp-) instruction:
gdb --args dotnet HelloWorld.dll
GNU gdb (GDB) 14.2
Copyright (C) 2023 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Type "show copying" and "show warranty" for details.
This GDB was configured as "arm-oe-linux-gnueabi".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<https://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from dotnet...
(No debugging symbols found in dotnet)
(gdb)
---- Sent utf8 encoded message: "run\r" ----
run
Starting program: /usr/bin/dotnet HelloWorld.dll
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Program received signal SIGILL, Illegal instruction.
0x0067b116 in ?? ()
(gdb)
---- Sent utf8 encoded message: "x/i 0x0067b116\r" ----
x/i 0x0067b116
=> 0x67b116: vmov.f64 d16, #240 @ 0xbf800000 -1.0
(gdb)
My understanding is that vfpv3d16 in the cpu features means that registers d0-d15 are double precision, and s0 - s31 are single precision. ARM’s documentation states that An instruction that attempts to access any of the registers D16-D31 generates an Undefined Instruction exception.
This issue happens on dotnet 7, 8, & 9. It happens whether I publish single file or not, and whether I publish self contained, or framework dependent. I have tried setting DOTNET_EnableHWIntrinsic=0 and PublishReadyToRun=false but still the same result. I have tried setting up a runtimeconfig.template.json with the following options:
{
"runtimeOptions": {
"configProperties": {
"System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeSupported": false,
"System.Runtime.CompilerServices.RuntimeFeature.IsDynamicCodeCompiled": false,
}
}
}
My question is how can I prevent dotnet from generating this instruction? Is there some flag that can be set while building the application, or do I need to compile my own version of the dotnet runtime that skips generating this instruction?
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 26 (12 by maintainers)
You should use mcr.microsoft.com/dotnet-buildtools/prereqs:azurelinux-3.0-net9.0-cross-arm
You want to use release/9.0. NativeAOT is not supported in release/8.0 on linux-arm.
Is it the
OPENSSL_initerror? It may get fixed if you use the release/9.0 and azurelinux-3.0 build image I have listed above.NativeAOT compiler and libraries are not bundled into the SDK. They are separate nuget packages published on nuget.org.
https://www.nuget.org/packages/Microsoft.DotNet.ILCompiler/ is a platform neutral meta package and then there platform specific packages like https://www.nuget.org/packages/runtime.linux-x64.Microsoft.DotNet.ILCompiler/ and https://www.nuget.org/packages/runtime.linux-arm.Microsoft.DotNet.ILCompiler/ with the platform specific bits.
When you are cross-building, you need both host and target package (e.g. both linux-x64 and linux-arm in your case) and they need to be the exact same version.
Now, if you build your local linux-arm package, it is going to have
9.0.0-devversion. If you were to avoid building9.0.0-devversion for linux-x64 and download it from nuget.org instead, you would have to do version editing to make the version match. Either edit the version of the downloaded package to9.0.0-devor edit the version of your local package to match whatever you downloaded. It is not easy to get this right.