Conversation
There was a problem hiding this comment.
Pull request overview
Makes the Android NDK API level used by NativeAOT’s Unix build integration configurable, addressing link failures caused by hardcoding API level 21 when the runtime is built against a higher NDK level.
Changes:
- Introduce
CrossCompileAndroidApiLevelMSBuild property with a default of24. - Replace hardcoded
android21/androideabi21target triple components withandroid$(CrossCompileAndroidApiLevel)/androideabi$(CrossCompileAndroidApiLevel).
src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
Show resolved
Hide resolved
src/coreclr/nativeaot/BuildIntegration/Microsoft.NETCore.Native.Unix.targets
Outdated
Show resolved
Hide resolved
|
Tagging subscribers to this area: @agocke, @dotnet/ilc-contrib |
|
@MichalStrehovsky I'll modify the PR to set it back to 21, there's no need to make the bump right now across the entire runtime, it was just a "by the way" change. With regards to syncing, we should in general keep the levels compatible between what dotnet/runtime uses and what's used by .NET for Android, but this is not to say they have to be set to the same value. API 21 and 24 aren't compatible on the binary level, so this is a situation where we need to be in agreement and use 24 on the NativeAOT linking side (CoreCLR host in .NET for Android will be fine, even though we build against 24 and libcoreclr.so is built against 21). I wouldn't make using the same API level on both sides a matter of policy, I'd recommend we keep the two compatible, even if they would differ. Tests we have on the Android side will be able to tell us if there are incompatibilities. |
Context: dotnet/android#9926
Context: dotnet/android@bef768d
.NET for Androidrecently switched CoreCLR and NativeAOT NDK API levels from 21 to 24, which uncovered an issue in the NativeAOTMicrosoft.NETCore.Native.Unix.targetsSetupOSSpecificPropstarget, where the target hardcodes the Android API level to21.This causes the following link error when trying to build an Android NativeAOT application:
The reason for this is that API 24
libc.socontains these two symbols, while the one from API 21 does not. Since.NET for Androidruntime is built with API 24, andNativeAOTbuild forces the API 21 level by passing the--target=${ARCH}-linux-android21argument to the linker, we get the above error.This PR makes the API level configurable and default to 24. The default value is merely the
current API level
.NET for Androidtargets, it doesn't need to be updated in the future - the.NET for Androidtargets will take care of setting the property to the appropriate value, should the default change.