diff --git a/eng/Subsets.props b/eng/Subsets.props
index 2906f49cd76d73..211dc6a8a180c0 100644
--- a/eng/Subsets.props
+++ b/eng/Subsets.props
@@ -50,7 +50,7 @@
Mono
- CoreCLR
+ CoreCLR
Mono
$(PrimaryRuntimeFlavor)
diff --git a/eng/native/build-commons.sh b/eng/native/build-commons.sh
index 509063d7a4a43f..e9d696fa87f14a 100755
--- a/eng/native/build-commons.sh
+++ b/eng/native/build-commons.sh
@@ -84,6 +84,8 @@ build_native()
exit 1
fi
+ cmakeArgs="-C $__RepoRootDir/eng/native/tryrun.cmake $cmakeArgs"
+
# keep ANDROID_PLATFORM in sync with SetOSTargetMinVersions in the root Directory.Build.props
cmakeArgs="-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-21 $cmakeArgs"
diff --git a/eng/native/tryrun.cmake b/eng/native/tryrun.cmake
index 04c6d1a98fdae7..97947fe887936f 100644
--- a/eng/native/tryrun.cmake
+++ b/eng/native/tryrun.cmake
@@ -1,6 +1,21 @@
set(CROSS_ROOTFS $ENV{ROOTFS_DIR})
set(TARGET_ARCH_NAME $ENV{TARGET_BUILD_ARCH})
+# Also allow building as Android without specifying `-cross`.
+if(NOT DEFINED TARGET_ARCH_NAME AND DEFINED ANDROID_PLATFORM)
+ if(ANDROID_ABI STREQUAL "arm64-v8a")
+ set(TARGET_ARCH_NAME "arm64")
+ elseif(ANDROID_ABI STREQUAL "x86_64")
+ set(TARGET_ARCH_NAME "x64")
+ elseif(ANDROID_ABI STREQUAL "armeabi-v7a")
+ set(TARGET_ARCH_NAME "arm")
+ elseif(ANDROID_ABI STREQUAL "x86")
+ set(TARGET_ARCH_NAME "x86")
+ else()
+ message(FATAL_ERROR "ANDROID_ABI ${ANDROID_ABI} not recognized!")
+ endif()
+endif()
+
macro(set_cache_value)
set(${ARGV0} ${ARGV1} CACHE STRING "Result from TRY_RUN" FORCE)
set(${ARGV0}__TRYRUN_OUTPUT "dummy output" CACHE STRING "Output from TRY_RUN" FORCE)
diff --git a/eng/pipelines/runtime-official.yml b/eng/pipelines/runtime-official.yml
index 2ef77a1c7e4f9d..76cc86289c805b 100644
--- a/eng/pipelines/runtime-official.yml
+++ b/eng/pipelines/runtime-official.yml
@@ -112,6 +112,8 @@ extends:
- iossimulator_x64
- iossimulator_arm64
- ios_arm64
+ - linux_bionic_arm64
+ - linux_bionic_x64
jobParameters:
buildArgs: -s clr.nativeaotlibs+clr.nativeaotruntime+libs+packs -c $(_BuildConfig) /p:BuildNativeAOTRuntimePack=true
nameSuffix: AllSubsets_NativeAOT
diff --git a/src/coreclr/CMakeLists.txt b/src/coreclr/CMakeLists.txt
index 1495cb736f8cb6..9720b0c2650e82 100644
--- a/src/coreclr/CMakeLists.txt
+++ b/src/coreclr/CMakeLists.txt
@@ -97,7 +97,7 @@ endif(NOT CLR_CROSS_COMPONENTS_BUILD)
# - do not depend on clr's compile definitions
#-----------------------------------------
if(CLR_CMAKE_HOST_UNIX)
- if(CLR_CMAKE_TARGET_ANDROID)
+ if(CLR_CMAKE_TARGET_ANDROID AND NOT DEFINED CMAKE_ANDROID_NDK)
find_library(LZMA NAMES lzma)
if(LZMA STREQUAL LZMA-NOTFOUND)
message(FATAL_ERROR "Cannot find liblzma.")
diff --git a/src/coreclr/build-runtime.sh b/src/coreclr/build-runtime.sh
index 49d2627630a426..90179bc4756542 100755
--- a/src/coreclr/build-runtime.sh
+++ b/src/coreclr/build-runtime.sh
@@ -106,6 +106,9 @@ source "$__ProjectRoot"/_build-commons.sh
__LogsDir="$__RootBinDir/log/$__BuildType"
__MsbuildDebugLogsDir="$__LogsDir/MsbuildDebugLogs"
__ConfigTriplet="$__TargetOS.$__TargetArch.$__BuildType"
+if [[ "$__TargetOS" == "linux-bionic" ]]; then
+ __ConfigTriplet="linux.$__TargetArch.$__BuildType"
+fi
__BinDir="$__RootBinDir/bin/coreclr/$__ConfigTriplet"
__ArtifactsObjDir="$__RepoRootDir/artifacts/obj"
__ArtifactsIntermediatesDir="$__ArtifactsObjDir/coreclr"
diff --git a/src/coreclr/nativeaot/CMakeLists.txt b/src/coreclr/nativeaot/CMakeLists.txt
index 91fa37cfad0907..957a7ac5d47c8b 100644
--- a/src/coreclr/nativeaot/CMakeLists.txt
+++ b/src/coreclr/nativeaot/CMakeLists.txt
@@ -45,6 +45,7 @@ endif()
if(CLR_CMAKE_TARGET_ANDROID)
add_definitions(-DFEATURE_EMULATED_TLS)
+ add_definitions(-DANDROID_FORCE_ICU_DATA_DIR)
endif()
add_subdirectory(Bootstrap)
diff --git a/src/coreclr/runtime.proj b/src/coreclr/runtime.proj
index 8d5410c4eab667..496e28198429f2 100644
--- a/src/coreclr/runtime.proj
+++ b/src/coreclr/runtime.proj
@@ -3,6 +3,9 @@
ClrFullNativeBuild;ClrRuntimeSubset;ClrJitSubset;ClrPalTestsSubset;ClrAllJitsSubset;ClrILToolsSubset;ClrNativeAotSubset;ClrSpmiSubset;ClrCrossComponentsSubset;HostArchitecture;PgoInstrument;NativeOptimizationDataSupported;CMakeArgs
<_IcuDir Condition="'$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)' != ''">$(PkgMicrosoft_NETCore_Runtime_ICU_Transport)/runtimes/$(TargetOS)-$(TargetArchitecture)$(_RuntimeVariant)/native
+
+ <_BuildNativeTargetOS>$(TargetOS)
+ <_BuildNativeTargetOS Condition="'$(TargetsLinuxBionic)' == 'true'">linux-bionic
@@ -28,7 +31,7 @@
<_CoreClrBuildArg Condition="'$(CrossBuild)' == 'true'" Include="-cross" />
<_CoreClrBuildArg Condition="'$(PortableBuild)' != 'true'" Include="-portablebuild=false" />
<_CoreClrBuildArg Condition="'$(KeepNativeSymbols)' != 'false'" Include="-keepnativesymbols" />
- <_CoreClrBuildArg Include="-os $(TargetOS)" />
+ <_CoreClrBuildArg Include="-os $(_BuildNativeTargetOS)" />
<_CoreClrBuildArg Condition="$([MSBuild]::IsOsPlatform(Windows)) and
('$(TargetArchitecture)' == 'x86' or '$(TargetArchitecture)' == 'x64') and
@@ -61,6 +64,21 @@
<_CoreClrBuildArg Include="-cmakeargs -DCMAKE_ICU_DIR="$(_IcuDir)"" />
+
+ <_CoreClrBuildArg Include="-DCMAKE_TOOLCHAIN_FILE=$(ANDROID_NDK_ROOT)/build/cmake/android.toolchain.cmake"/>
+ <_CoreClrBuildArg Include="-DANDROID_NDK=$(ANDROID_NDK_ROOT)"/>
+ <_CoreClrBuildArg Include="-DANDROID_STL=none"/>
+ <_CoreClrBuildArg Include="-DANDROID_CPP_FEATURES="no-rtti no-exceptions""/>
+ <_CoreClrBuildArg Include="-DANDROID_PLATFORM=android-$(AndroidApiLevelMin)"/>
+ <_CoreClrBuildArg Condition="'$(Platform)' == 'arm64'" Include="-DANDROID_ABI=arm64-v8a" />
+ <_CoreClrBuildArg Condition="'$(Platform)' == 'arm'" Include="-DANDROID_ABI=armeabi-v7a" />
+ <_CoreClrBuildArg Condition="'$(Platform)' == 'x86'" Include="-DANDROID_ABI=x86" />
+ <_CoreClrBuildArg Condition="'$(Platform)' == 'x64'" Include="-DANDROID_ABI=x86_64" />
+
+
+ <_CoreClrBuildArg Include="-cmakeargs -DFEATURE_EVENT_TRACE=0"/>
+
+
<_CoreClrBuildScript Condition="$([MSBuild]::IsOsPlatform(Windows))">build-runtime.cmd
<_CoreClrBuildScript Condition="!$([MSBuild]::IsOsPlatform(Windows))">build-runtime.sh
diff --git a/src/native/corehost/apphost/static/CMakeLists.txt b/src/native/corehost/apphost/static/CMakeLists.txt
index adc5dfeaefac5f..c491311cfbb912 100644
--- a/src/native/corehost/apphost/static/CMakeLists.txt
+++ b/src/native/corehost/apphost/static/CMakeLists.txt
@@ -157,7 +157,7 @@ else()
include(${CLR_SRC_NATIVE_DIR}/libs/System.IO.Compression.Native/extra_libs.cmake)
append_extra_compression_libs(NATIVE_LIBS)
- if (NOT CLR_CMAKE_TARGET_TVOS) # no gssapi on tvOS, see https://developer.apple.com/documentation/gss
+ if (NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_HOST_ANDROID) # no gssapi on tvOS, see https://developer.apple.com/documentation/gss
# Additional requirements for System.Net.Security.Native
include(${CLR_SRC_NATIVE_DIR}/libs/System.Net.Security.Native/extra_libs.cmake)
append_extra_security_libs(NATIVE_LIBS)
@@ -167,7 +167,7 @@ else()
include(${CLR_SRC_NATIVE_DIR}/libs/System.Native/extra_libs.cmake)
append_extra_system_libs(NATIVE_LIBS)
- if(NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS)
+ if(NOT CLR_CMAKE_TARGET_MACCATALYST AND NOT CLR_CMAKE_TARGET_IOS AND NOT CLR_CMAKE_TARGET_TVOS AND NOT CLR_CMAKE_HOST_ANDROID)
# Additional requirements for System.Security.Cryptography.Native.OpenSsl
include(${CLR_SRC_NATIVE_DIR}/libs/System.Security.Cryptography.Native/extra_libs.cmake)
append_extra_cryptography_libs(NATIVE_LIBS)