Skip to content

Enable CoreCLR runtime pack for android-arm (armeabi-v7a)#11172

Draft
simonrozsival wants to merge 7 commits into
mainfrom
dev/simonrozsival/coreclr-android-arm
Draft

Enable CoreCLR runtime pack for android-arm (armeabi-v7a)#11172
simonrozsival wants to merge 7 commits into
mainfrom
dev/simonrozsival/coreclr-android-arm

Conversation

@simonrozsival
Copy link
Copy Markdown
Member

@simonrozsival simonrozsival commented Apr 21, 2026

Note

This PR was AI/Copilot-generated.

Summary

Enable the CoreCLR runtime flavor for the armeabi-v7a (android-arm) ABI, following the same pattern as android-arm64 and android-x64.

Changes

build-tools/scripts/Ndk.projitems.in

  • Set SupportCoreCLR=True for armeabi-v7a (was False)
  • Add ApiLevelNonMono metadata (referencing the new AndroidNdkApiLevelNonMono_Arm property)
  • Add AndroidNdkApiLevelNonMono_Arm property with @NDK_ARMEABI_V7_API_NON_MONO@ placeholder

build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs

  • Add @NDK_ARMEABI_V7_API_NON_MONO@NdkMinimumNonMonoAPI placeholder replacement

WorkloadManifest.in.json

  • Add Microsoft.Android.Runtime.CoreCLR.37.android-arm to the workload packs list and pack definitions

Status

This PR intentionally assumes the android-arm CoreCLR runtime pack is available end-to-end. CI may remain red until the dependent runtime/SDK changes flow into this repo:

Keep this PR as draft while those dependencies are missing.

NativeAOT android-arm wiring is tracked separately in #11423.

@simonrozsival simonrozsival added Area: CoreCLR Issues that only occur when using CoreCLR. copilot `copilot-cli` or other AIs were used to author this labels Apr 21, 2026
@simonrozsival simonrozsival marked this pull request as ready for review April 28, 2026 08:11
Copilot AI review requested due to automatic review settings April 28, 2026 08:11
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Enables CoreCLR runtime-pack support metadata for the android-arm (armeabi-v7a) ABI so the Android workload can include a CoreCLR pack for that RID, matching existing arm64/x64 patterns.

Changes:

  • Add Microsoft.Android.Runtime.CoreCLR.36.1.android-arm to the Android workload manifest packs list and pack definitions.
  • Update Ndk.projitems.in to mark armeabi-v7a as SupportCoreCLR=True and add an ApiLevelNonMono value for that ABI.
  • Extend xaprepare placeholder generation to replace the new @NDK_ARMEABI_V7_API_NON_MONO@ placeholder.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
src/Xamarin.Android.Build.Tasks/Microsoft.NET.Sdk.Android/WorkloadManifest.in.json Adds the CoreCLR android-arm runtime pack to the workload manifest.
build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs Adds placeholder substitution for the new arm32 non-mono NDK API placeholder used by generated projitems.
build-tools/scripts/Ndk.projitems.in Marks armeabi-v7a as CoreCLR-supported and introduces an arm32 non-mono API-level property/metadata.

Comment thread build-tools/scripts/Ndk.projitems.in Outdated
<AndroidRID>android-arm</AndroidRID>
<SupportMonoVM>True</SupportMonoVM>
<SupportCoreCLR>False</SupportCoreCLR>
<SupportCoreCLR>True</SupportCoreCLR>
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

Setting True for armeabi-v7a makes the build/packs treat android-arm CoreCLR as supported, but the rest of the repo is not wired up for it yet: src/native/native-clr.csproj still restricts AndroidSupportedTargetJitAbis to arm64-v8a:x86_64, src/native/CMakePresets.json.in has no coreclr-* presets for armeabi-v7a, and the CoreCLR/NonMono min-API mapping in XABuildConfig.ArchToApiLevelNonMono has no AndroidTargetArch.Arm entry (MonoAndroidHelper.GetMinimumApiLevel will throw for CoreCLR+Arm). Either keep SupportCoreCLR=false for armeabi-v7a for now, or add the missing native presets/build support and the ArchToApiLevelNonMono entry so CoreCLR android-arm builds are actually possible.

Suggested change
<SupportCoreCLR>True</SupportCoreCLR>
<SupportCoreCLR>False</SupportCoreCLR>

Copilot uses AI. Check for mistakes.
Comment on lines 10 to 17
"Microsoft.Android.Runtime.Mono.36.1.android-x64",
"Microsoft.Android.Runtime.CoreCLR.36.1.android-arm",
"Microsoft.Android.Runtime.CoreCLR.36.1.android-arm64",
"Microsoft.Android.Runtime.CoreCLR.36.1.android-x64",
Copy link

Copilot AI Apr 28, 2026

Choose a reason for hiding this comment

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

The workload manifest now declares Microsoft.Android.Runtime.CoreCLR.36.1.android-arm as part of the android workload. With the current repo state, CoreCLR native runtime builds/packs are only produced for arm64/x86_64 (see src/native/native-clr.csproj and CMake presets), so this entry is likely to make workload install/pack creation fail or produce an incomplete runtime pack for android-arm. Please ensure the CoreCLR android-arm runtime pack is actually generated and published by the build (native runtime build + runtime pack creation) before listing it here, or gate the manifest entry until those pieces are in place.

Copilot uses AI. Check for mistakes.
@simonrozsival
Copy link
Copy Markdown
Member Author

@copilot address the review and make sure the rest of the repo is ready for armeabi-v7a support

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 28, 2026

@copilot address the review and make sure the rest of the repo is ready for armeabi-v7a support

Wired up the remaining pieces in 84c9882:

  • src/native/CMakePresets.json.in: added nonmono-common-armeabi-v7a and coreclr-default-{debug,release}-armeabi-v7a presets so --preset coreclr-default-*-armeabi-v7a resolves during _ConfigureRuntimes.
  • build-tools/xaprepare/xaprepare/Steps/Step_GenerateFiles.cs: added @NDK_ARMEABI_V7_NONMONO_API_NET@ (CMakePresets) and @NDK_ARMEABI_V7_NONMONO_API@ (XABuildConfig) placeholder substitutions, both mapping to BuildAndroidPlatforms.NdkMinimumNonMonoAPI.
  • build-tools/scripts/XABuildConfig.cs.in: added AndroidTargetArch.Arm to ArchToApiLevelNonMono so MonoAndroidHelper.GetMinimumApiLevel no longer throws for CoreCLR + Arm.
  • src/native/native-clr.csproj: added armeabi-v7a to AndroidSupportedTargetJitAbis so the CoreCLR native runtime is actually built and packaged for that ABI. AOT abis are left as arm64:x86_64.

@simonrozsival
Copy link
Copy Markdown
Member Author

@copilot build failed:

Build Summary: Failed ❌
Build ID: 13956134
Definition: Xamarin.Android-PR
Branch: dev/simonrozsival/coreclr-android-arm
Commit: 84c988208a894ea1c04aa19c1d8502e1c776915a
Reason: batchedCI

All three platform stages (Linux, macOS, Windows) failed with the same root cause: a C++ compilation error in the native CLR host.

Failed Stages
Linux > Build (make jenkins)
macOS > Build (make jenkins)
Windows > Build (Build Solution)
All three stages fail identically during the _BuildAndroidRuntimes target in native-clr.csproj.

Root Cause: C++ Type Mismatch in typemap.cc
File: src/native/clr/host/typemap.cc line 149

error: no matching function for call to 'hash'
Code:

hash_t mvid_hash = xxhash::hash (mvid, 16z);
The mvid parameter is const uint8_t * (const unsigned char *), but xxhash::hash() only accepts const char *.

Candidate not viable (from src/native/common/include/shared/xxhash.hh:61):

candidate function template not viable: no known conversion from
  'const uint8_t *' (aka 'const unsigned char *') to 'const char *'
  for 1st argument
Fix Needed
The call at typemap.cc:149 needs a reinterpret_cast<const char *>(mvid), or xxhash::hash() needs an overload accepting const uint8_t *.

Additional Warning (macOS & Linux only)
src/Mono.Android/metadata(389,3): error BG4304: Invalid XPath specification:
  /api/package[@name='android.graphics.pdf.component']/*/method[...]
This metadata binding error also fires on macOS and Linux builds but is secondary to the native compilation failure that causes the overall build to fail.

Failed Tests
No test results available — the build failed before reaching the test execution phase.

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 28, 2026

@copilot build failed:

Build Summary: Failed ❌

...

Fixed in 483822f. Root cause: on 32-bit (armeabi-v7a) xamarin::android::xxhash aliases to xxhash32, whose hash overloads only take const char *. On 64-bit it aliases to xxhash64, which has a template<typename T> hash(const T*, size_t) overload — which is why this compiled fine before arm32 was enabled. Added a reinterpret_cast<const char*>(mvid) at the call site, matching the existing pattern in mono/monodroid/embedded-assemblies.cc:787.

The BG4304 metadata error (/api/package[@name='android.graphics.pdf.component']/...) is unrelated to this PR (it's about Android API metadata, not arm32) and per the build summary is secondary to the native compilation failure, so I'm leaving it alone.

simonrozsival and others added 3 commits May 20, 2026 16:26
Enable the CoreCLR runtime flavor for the armeabi-v7a ABI, following the
same pattern as android-arm64 and android-x64.

Changes:
- Set SupportCoreCLR=True for armeabi-v7a in Ndk.projitems.in
- Add ApiLevelNonMono metadata and corresponding property/placeholder
- Add Microsoft.Android.Runtime.CoreCLR.36.1.android-arm to workload manifest

Depends on dotnet/runtime#127225 and dotnet/runtime#126838 (API level 24).

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/android/sessions/57a8b6d4-93df-4f84-9b77-3a58a6e2158b

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
Agent-Logs-Url: https://github.com/dotnet/android/sessions/0e9f046e-d5f6-471f-97d4-3f8da467c15b

Co-authored-by: simonrozsival <374616+simonrozsival@users.noreply.github.com>
@simonrozsival simonrozsival force-pushed the dev/simonrozsival/coreclr-android-arm branch from 483822f to 35be785 Compare May 20, 2026 14:27
@simonrozsival
Copy link
Copy Markdown
Member Author

@copilot

       "/Users/builder/azdo/_work/5/s/android/Xamarin.Android.sln" (default target) (1:2) ->
       "/Users/builder/azdo/_work/5/s/android/tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.csproj" (default target) (45:6) ->
         /Users/builder/azdo/_work/5/s/android/src/Xamarin.Android.Build.Tasks/Tests/Xamarin.Android.Build.Tests/Utilities/InlineData.cs(7,7): warning CS0105: The using directive for 'System.Globalization' appeared previously in this namespace [/Users/builder/azdo/_work/5/s/android/tests/MSBuildDeviceIntegration/MSBuildDeviceIntegration.csproj]


       "/Users/builder/azdo/_work/5/s/android/Xamarin.Android.sln" (default target) (1:2) ->
       "/Users/builder/azdo/_work/5/s/android/src/native/native-clr.csproj" (default target) (20:6) ->
       (_BuildAndroidRuntimes target) -> 
         ld.lld : error : unable to find library -lcoreclr [/Users/builder/azdo/_work/5/s/android/src/native/native-clr.csproj]
         clang++ : error : linker command failed with exit code 1 (use -v to see invocation) [/Users/builder/azdo/_work/5/s/android/src/native/native-clr.csproj]
         /Users/builder/azdo/_work/5/s/android/src/native/native.targets(290,5): error MSB3073: The command "/Users/builder/android-toolchain/sdk/cmake/3.30.3/bin/ninja -v" exited with code 1. [/Users/builder/azdo/_work/5/s/android/src/native/native-clr.csproj]

    266 Warning(s)
    3 Error(s)

Copy link
Copy Markdown
Contributor

Copilot AI commented May 20, 2026

@copilot

...

Addressed in 44570a4. Root cause: the android-arm CoreCLR runtime pack (Microsoft.NETCore.App.Runtime.android-arm) doesn't exist yet — that's blocked on dotnet/runtime#127225 which hasn't shipped. Without it there's no libcoreclr.so for armeabi-v7a for ld.lld to resolve -lcoreclr against. src/native/CMakeLists.txt also has no RUNTIME_DIR_ARM mapping under IS_CLR_RUNTIME for the same reason.

Reverted just the AndroidSupportedTargetJitAbis addition in native-clr.csproj so the native CoreCLR runtime isn't built for arm32 yet. The rest of the wiring (workload manifest, Ndk.projitems, CMake presets, ArchToApiLevelNonMono, the typemap.cc fix) stays in place — once the runtime pack ships, re-enabling is a one-line change.

simonrozsival and others added 3 commits May 20, 2026 17:43
Add the missing CoreCLR android-arm runtime directory placeholder and consume it from native CMake configuration so the new armeabi-v7a CoreCLR presets do not configure with an empty runtime directory.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Leave the android-arm CoreCLR runtime pack out of workload pack creation and the workload manifest until the native CoreCLR armeabi-v7a build can be enabled.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Assume the android-arm CoreCLR runtime pack is available and keep the PR wired end-to-end: native build, pack creation, and workload manifest all include android-arm CoreCLR.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area: CoreCLR Issues that only occur when using CoreCLR. copilot `copilot-cli` or other AIs were used to author this

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants