Skip to content

Commit 1753549

Browse files
simonrozsivalCopilotjkotasCopilot
authored
[android] Enable android-arm CoreCLR with softfp ABI handling (#127578)
> [!NOTE] > This PR description was updated with GitHub Copilot. Fixes #127500. ## Description This re-enables the `android-arm` CoreCLR runtime pack and CI coverage, and fixes the Android ARM softfp ABI handling needed for native code, ReadyToRun/Crossgen2-generated code, and NativeAOT target handling. Android `arm` maps to the `armeabi-v7a` ABI. That ABI can use VFP instructions internally, but floating-point arguments and return values cross function-call boundaries through core registers/stack rather than VFP argument registers. In .NET target terminology, the matching AOT/JIT ABI is `armel`. The original enablement exposed runtime crashes caused by parts of the build and code-generation pipeline disagreeing on that ABI. Native/CoreCLR builds needed `ARM_SOFTFP`, and AOT compiler target handling needed to treat Android ARM as Linux/Bionic with the softfp ABI. ## Changes - Re-enable `android-arm` as a supported CoreCLR runtime pack target. - Re-enable Android ARM CoreCLR legs in the runtime and extra-platform CI pipelines. - Add Android ARM Helix queue selection. - Set `ARM_SOFTFP` for Android ARM native/CoreCLR builds. - Treat Android ARM compile definitions as softfp when setting CoreCLR target definitions. - Keep Android as an accepted AOT command-line target OS without extending the internal `TargetOS` enum. - Centralize Android command-line normalization in both Crossgen2 and NativeAOT ILCompiler: ```text --targetos:android -> TargetOS.Linux --targetos:android --targetarch:arm -> NativeAotArmel / softfp ABI --targetos:android --targetarch:arm64 -> NativeAot ``` - Update Crossgen2 call sites to pass the real Android target identity instead of duplicating Android-to-Linux remaps in MSBuild. - Update NativeAOT build integration to pass `--targetos:android` through to ILCompiler while preserving the existing bionic ARM `armel` target-architecture handling. ## Validation Built Android ARM locally: ```sh ./build.sh clr+libs+host+packs -os android -arch arm -c Release ``` Result: ```text Build succeeded. 0 Warning(s) 0 Error(s) ``` Validated on a physical Android device with `armeabi-v7a` support. The following Android ARM test runs completed with zero failures with both `TestReadyToRun=true` and `TestReadyToRun=false`: - `System.Runtime.Tests` - `System.Runtime.Numerics.Tests` - `System.Numerics.Vectors.Tests` - `System.Numerics.Tensors.Tests` - `Microsoft.Bcl.Numerics.Tests` Additional validation for the centralized AOT target handling: ```sh ./build.sh clr+libs+host /p:RestoreDisableParallel=true ./dotnet.sh build src/coreclr/tools/aot/crossgen2/crossgen2.csproj /p:RestoreDisableParallel=true ./dotnet.sh build src/coreclr/tools/aot/ILCompiler/ILCompiler.csproj /p:RestoreDisableParallel=true ./dotnet.sh build src/tasks/Crossgen2Tasks/Crossgen2Tasks.csproj /p:RestoreDisableParallel=true ./build.sh tasks /p:RestoreDisableParallel=true ./dotnet.sh build src/coreclr/tools/aot/ILCompiler.TypeSystem.Tests/ILCompiler.TypeSystem.Tests.csproj /t:Test --no-restore ./dotnet.sh build src/coreclr/tools/aot/ILCompiler.Compiler.Tests/ILCompiler.Compiler.Tests.csproj /t:Test --no-restore ``` Also smoke-tested that both Crossgen2 and ILCompiler accept Android target arguments, including `--targetos:android --targetarch:arm` and `--targetos:android --targetarch:arm64`, and that the existing `--targetos:linux --targetarch:armel` normalization still works. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jan Kotas <jkotas@microsoft.com> Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 11b17d7 commit 1753549

20 files changed

Lines changed: 66 additions & 82 deletions

File tree

eng/Subsets.props

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@
2929
<!-- Determine if the CoreCLR runtime can build/run for the specified target. -->
3030
<_CoreCLRSupportedOS Condition="'$(TargetsMobile)' != 'true' and '$(TargetsLinuxBionic)' != 'true'">true</_CoreCLRSupportedOS>
3131

32-
<!-- Android 32-bit builds blocked by https://github.com/dotnet/runtime/issues/111665 -->
33-
<_CoreCLRSupportedOS Condition="'$(TargetsAndroid)' == 'true' and '$(TargetArchitecture)' != 'arm' and '$(TargetArchitecture)' != 'x86'">true</_CoreCLRSupportedOS>
32+
<_CoreCLRSupportedOS Condition="'$(TargetsAndroid)' == 'true' and '$(TargetArchitecture)' != 'x86'">true</_CoreCLRSupportedOS>
3433
<_CoreCLRSupportedOS Condition="'$(TargetsBrowser)' == 'true'">true</_CoreCLRSupportedOS>
3534
<_CoreCLRSupportedOS Condition="'$(TargetsAppleMobile)' == 'true'">true</_CoreCLRSupportedOS>
3635

eng/native/configureplatform.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,10 @@ if(CLR_CMAKE_TARGET_OS STREQUAL android)
371371
set(CLR_CMAKE_TARGET_UNIX 1)
372372
set(CLR_CMAKE_TARGET_LINUX 1)
373373
set(CLR_CMAKE_TARGET_ANDROID 1)
374+
375+
if(CLR_CMAKE_TARGET_ARCH_ARM)
376+
set(ARM_SOFTFP 1)
377+
endif(CLR_CMAKE_TARGET_ARCH_ARM)
374378
endif(CLR_CMAKE_TARGET_OS STREQUAL android)
375379

376380
if(CLR_CMAKE_TARGET_OS STREQUAL darwin)

eng/native/gen-buildsys.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,6 @@ if [[ "$CROSSCOMPILE" == "1" ]]; then
8181
fi
8282
fi
8383

84-
if [[ "$host_arch" == "armel" ]]; then
85-
cmake_extra_defines="$cmake_extra_defines -DARM_SOFTFP=1"
86-
fi
87-
8884
if ! cmake_command=$(command -v cmake); then
8985
echo "CMake was not found in PATH."
9086
exit 1

eng/pipelines/coreclr/templates/helix-queues-setup.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ jobs:
4646
- ${{ if eq(variables['System.TeamProject'], 'internal') }}:
4747
- OSX.15.Amd64
4848

49+
# Android arm
50+
- ${{ if in(parameters.platform, 'android_arm') }}:
51+
- ${{ if eq(variables['System.TeamProject'], 'public') }}:
52+
- Windows.11.Amd64.Android-armel.Open
53+
- ${{ if eq(variables['System.TeamProject'], 'internal') }}:
54+
- Ubuntu.2204.Amd64.Android.29
55+
4956
# Android arm64
5057
- ${{ if in(parameters.platform, 'android_arm64') }}:
5158
- ${{ if eq(variables['System.TeamProject'], 'public') }}:

eng/pipelines/extra-platforms/runtime-extra-platforms-android.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ jobs:
9696
buildConfig: Release
9797
runtimeFlavor: coreclr
9898
platforms:
99+
- android_arm
99100
- android_arm64
100101
variables:
101102
# map dependencies variables to local variables

eng/pipelines/libraries/helix-queues-setup.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ jobs:
9494
- Ubuntu.2204.Amd64.Android.29.Open
9595
- ${{ if and(ne(variables['System.TeamProject'], 'public'), in(parameters.platform, 'android_arm', 'android_arm64', 'linux_bionic_arm', 'linux_bionic_arm64')) }}:
9696
- Ubuntu.2204.Amd64.Android.29.Open
97-
- ${{ if and(eq(variables['System.TeamProject'], 'public'), in(parameters.platform, 'android_arm', 'android_arm64', 'linux_bionic_arm', 'linux_bionic_arm64')) }}:
97+
- ${{ if and(eq(variables['System.TeamProject'], 'public'), in(parameters.platform, 'android_arm', 'linux_bionic_arm')) }}:
98+
- Windows.11.Amd64.Android-armel.Open
99+
- ${{ if and(eq(variables['System.TeamProject'], 'public'), in(parameters.platform, 'android_arm64', 'linux_bionic_arm64')) }}:
98100
- Windows.11.Amd64.Android.Open
99101

100102
# iOS Simulator/Mac Catalyst arm64

eng/pipelines/runtime.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ extends:
11061106
eq(variables['isRollingBuild'], true))
11071107
11081108
#
1109-
# Android arm64 devices and x64 emulators
1109+
# Android arm/arm64 devices and x64 emulators
11101110
# Build the whole product using CoreCLR and run functional tests
11111111
#
11121112
- template: /eng/pipelines/common/platform-matrix.yml
@@ -1116,6 +1116,7 @@ extends:
11161116
buildConfig: Release
11171117
runtimeFlavor: coreclr
11181118
platforms:
1119+
- android_arm
11191120
- android_x64
11201121
- android_arm64
11211122
variables:

eng/testing/tests.readytorun.targets

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
<Target Name="ResolveReadyToRunCompilers">
44
<PropertyGroup>
55
<Crossgen2Path>$([MSBuild]::NormalizePath('$(Crossgen2InBuildDir)', 'crossgen2$(ExeSuffix)'))</Crossgen2Path>
6-
<_CrossGenTargetOS Condition="'$(TargetsAndroid)' != 'true'">$(TargetOS)</_CrossGenTargetOS>
7-
<_CrossGenTargetOS Condition="'$(TargetsAndroid)' == 'true'">linux</_CrossGenTargetOS>
86
</PropertyGroup>
97

108
<ItemGroup>
119
<Crossgen2Tool Include="$(Crossgen2Path)"
1210
TargetArch="$(TargetArchitecture)"
13-
TargetOS="$(_CrossGenTargetOS)"
11+
TargetOS="$(TargetOS)"
1412
PerfmapFormatVersion="$(PublishReadyToRunPerfmapFormatVersion)"/>
1513
</ItemGroup>
1614
</Target>

src/coreclr/clrdefinitions.cmake

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -292,8 +292,4 @@ function(set_target_definitions_to_custom_os_and_arch)
292292
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_WASM)
293293
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE TARGET_WASM32)
294294
endif()
295-
296-
if (TARGETDETAILS_ARCH STREQUAL "armel")
297-
target_compile_definitions(${TARGETDETAILS_TARGET} PRIVATE ARM_SOFTFP)
298-
endif()
299295
endfunction()

src/coreclr/crossgen-corelib.proj

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,7 @@
159159
<CrossGenDllCmd Condition="'$(PublishReadyToRunContainerFormat)' != ''">$(CrossGenDllCmd) --obj-format:$(PublishReadyToRunContainerFormat)</CrossGenDllCmd>
160160
<CrossGenDllCmd Condition="'$(PublishReadyToRunContainerFormat)' == 'wasm'">$(CrossGenDllCmd) --codegenopt:JitWasmNyiToR2RUnsupported=1</CrossGenDllCmd>
161161
<CrossGenDllCmd Condition="'$(UseComposite)' == 'true'">$(CrossGenDllCmd) --composite</CrossGenDllCmd>
162-
<CrossGenDllCmd Condition="'$(TargetsAndroid)' != 'true'">$(CrossGenDllCmd) --targetos:$(TargetOS)</CrossGenDllCmd>
163-
<!-- Unless and until Android requires R2R specific customizations, we're just dealing with another linux -->
164-
<CrossGenDllCmd Condition="'$(TargetsAndroid)' == 'true'">$(CrossGenDllCmd) --targetos:linux</CrossGenDllCmd>
162+
<CrossGenDllCmd>$(CrossGenDllCmd) --targetos:$(TargetOS)</CrossGenDllCmd>
165163
<CrossGenDllCmd Condition="'$(UsingToolIbcOptimization)' != 'true' and '$(EnableNgenOptimization)' == 'true'">$(CrossGenDllCmd) -m:$(MergedMibcPath) --embed-pgo-data</CrossGenDllCmd>
166164
<CrossGenDllCmd>$(CrossGenDllCmd) -O</CrossGenDllCmd>
167165
<!-- Enable type and field layout verification to make it easier to catch when the crossgen2 type layout engine and the runtime disagree on layout conventions -->

0 commit comments

Comments
 (0)