Skip to content
Merged
Show file tree
Hide file tree
Changes from 53 commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
90c22cb
Beginnings of native Android build
grendello Dec 6, 2024
6f1b917
Don't package what's not needed on Android
grendello Dec 6, 2024
c25fbd9
TARGET_LINUX == TARGET_ANDROID for crosscomp.h
grendello Dec 6, 2024
bfcbb3e
Beginnings of native Android build
grendello Dec 6, 2024
97f2555
Don't package what's not needed on Android
grendello Dec 6, 2024
3d9da10
TARGET_LINUX == TARGET_ANDROID for crosscomp.h
grendello Dec 6, 2024
9e173df
Merge remote-tracking branch 'grendel/dev/grendel/android-build-with-…
steveisok Dec 6, 2024
bb9f323
Fix cmake endif / make sure RuntimeFlavor is CoreCLR
steveisok Dec 6, 2024
b0f3d55
Use dummyprovider instead of lttngprovider / disable FEATURE_PERFTRAC…
steveisok Dec 9, 2024
f9eb950
Put a GEN_SHARED_LIB check around install_with_stripped_symbols in Sy…
steveisok Dec 11, 2024
a69fcfd
Bump min API level to 29 (proper TLS support) and link the right syst…
steveisok Dec 11, 2024
54fbb50
Fix host/target confusion in R2R tool publish / Add Android target to…
steveisok Dec 13, 2024
061badd
Beginnings of native Android build
grendello Dec 6, 2024
343547d
Don't package what's not needed on Android
grendello Dec 6, 2024
d9d653a
TARGET_LINUX == TARGET_ANDROID for crosscomp.h
grendello Dec 6, 2024
be4941b
Fix cmake endif / make sure RuntimeFlavor is CoreCLR
steveisok Dec 6, 2024
db133cb
Use dummyprovider instead of lttngprovider / disable FEATURE_PERFTRAC…
steveisok Dec 9, 2024
6473af2
Put a GEN_SHARED_LIB check around install_with_stripped_symbols in Sy…
steveisok Dec 11, 2024
4d9f500
Bump min API level to 29 (proper TLS support) and link the right syst…
steveisok Dec 11, 2024
d5e0292
Fix host/target confusion in R2R tool publish / Add Android target to…
steveisok Dec 13, 2024
54d5725
Enable doublemapping via memfd_create and few fixes
janvorli Dec 18, 2024
7d78dec
Enable cross-build for macos
ivanpovazan Dec 18, 2024
7026cc8
First version of HelloAndroid
ivanpovazan Dec 18, 2024
9823a55
Cleanup
ivanpovazan Jan 10, 2025
7797943
Merge remote-tracking branch 'grendel/dev/grendel/android-build-with-…
steveisok Jan 10, 2025
2e4c737
Revert changes to R2R that alias Android to linux and put it in a few…
steveisok Jan 10, 2025
2516884
Merge remote-tracking branch 'upstream/main' into dev/grendel/android…
steveisok Jan 10, 2025
074a955
Merge branch 'main' into dev/grendel/android-build-with-ndk
grendello Jan 13, 2025
240ad01
Oops, too much
grendello Jan 13, 2025
34cdc56
Undo host awareness in crossgen_publish as building it is about the t…
steveisok Jan 14, 2025
c171ce3
Fix setting target platform in tryrun.cmake
ivanpovazan Jan 15, 2025
a515ed8
Make sure android runtime pack is generated and crossgen_inbuild uses…
steveisok Jan 15, 2025
3831805
Merge remote-tracking branch 'grendel/dev/grendel/android-build-with-…
steveisok Jan 15, 2025
9779aeb
Condition min api level for coreclr and not.
steveisok Jan 15, 2025
f9e8184
Feedback
steveisok Jan 16, 2025
e709bdf
Add FEATURE_NATIVEAOT_ONLY
steveisok Jan 16, 2025
eb56c75
Remove unnecessary prop
steveisok Jan 16, 2025
5b58f87
Add tracking issue for follow-up work
kotlarmilos Jan 16, 2025
aba5cbb
Revert FEATURE_NATIVEAOT_ONLY
steveisok Jan 16, 2025
78ca848
Set PrimaryRuntimeFlavor on mobile official build and don't try to ge…
steveisok Jan 16, 2025
d3e8eb2
Override API level in coreclr runtime.proj and flow runtimeFlavor int…
steveisok Jan 16, 2025
579610c
Disable ThreadStatic optimizations until emulated TLS support is added
steveisok Jan 17, 2025
7e40691
Using API level 21 should be good now
steveisok Jan 17, 2025
460a2d6
Update tracking issues
kotlarmilos Jan 17, 2025
2d322d2
Add tracking issue for libunwind errors
kotlarmilos Jan 17, 2025
880ab09
Set runtime feature flag in cmake config
kotlarmilos Jan 17, 2025
a5d1115
Fixing typo for eventpipe build
ivanpovazan Jan 17, 2025
5a94dea
Don't get in the way of building coreclr+mono runtimes together. Work…
steveisok Jan 18, 2025
41ce72b
Merge branch 'main' into dev/grendel/android-build-with-ndk
grendello Jan 20, 2025
fbf9fdd
Merge remote-tracking branch 'upstream/main' into dev/grendel/android…
steveisok Jan 22, 2025
05273c5
Allow cross build on osx when targeting arm32, fix bad arm32 linker a…
steveisok Jan 22, 2025
de2e7cb
Revert CLR_CMAKE_RUNTIME_CORECLR and enable event pipe TCP stuff
steveisok Jan 22, 2025
1477651
Exclude arm and x86 from generating packages / Always set CrossBuild=…
steveisok Jan 23, 2025
cc97c13
Avoid setting crossbuild for now on linux hosts
steveisok Jan 23, 2025
bb00de1
Remove CrossBuild=true and instead make sure _BuildAnyCrossArch is pr…
steveisok Jan 23, 2025
9bd94e0
Merge remote-tracking branch 'upstream/main' into dev/grendel/android…
steveisok Jan 24, 2025
b806157
PR feedback
ivanpovazan Jan 24, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
<PropertyGroup Label="CalculatePackageRID">
<_packageOS>$(_portableOS)</_packageOS>

<_packageOS Condition="'$(CrossBuild)' == 'true' and '$(_portableOS)' != 'linux-musl' and '$(_portableOS)' != 'linux-bionic'">$(_hostOS)</_packageOS>
<_packageOS Condition="'$(CrossBuild)' == 'true' and '$(_portableOS)' != 'linux-musl' and '$(_portableOS)' != 'linux-bionic' and '$(_portableOS)' != 'android'">$(_hostOS)</_packageOS>

<!-- source-build sets PackageOS to build with non-portable rid packages that were source-built previously. -->
<PackageRID Condition="'$(PackageOS)' != ''">$(PackageOS)-$(TargetArchitecture)</PackageRID>
Expand Down
11 changes: 11 additions & 0 deletions eng/Subsets.props
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
<PropertyGroup>
<!-- Determine if the CoreCLR runtime can build/run for the specified target. -->
<_CoreCLRSupportedOS Condition="'$(TargetsMobile)' != 'true' and '$(TargetsLinuxBionic)' != 'true'">true</_CoreCLRSupportedOS>

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

<_CoreCLRSupportedArch Condition="'$(TargetArchitecture)' != 'armv6' and '$(TargetArchitecture)' != 'ppc64le' and '$(TargetArchitecture)' != 's390x'">true</_CoreCLRSupportedArch>
<CoreCLRSupported Condition="'$(_CoreCLRSupportedOS)' == 'true' and '$(_CoreCLRSupportedArch)' == 'true'">true</CoreCLRSupported>

Expand Down Expand Up @@ -56,6 +60,7 @@
<PropertyGroup>
<DefaultSubsets>clr+mono+libs+tools+host+packs</DefaultSubsets>
<DefaultSubsets Condition="'$(TargetsMobile)' == 'true'">mono+libs+packs</DefaultSubsets>
<DefaultSubsets Condition="'$(TargetsAndroid)' == 'true' and '$(CoreCLRSupported)' == 'true'">clr.runtime+clr.alljits+clr.corelib+clr.nativecorelib+clr.tools+clr.packages+mono+libs+host+packs</DefaultSubsets>
<DefaultSubsets Condition="'$(TargetsAppleMobile)' == 'true'">clr.nativeaotruntime+clr.nativeaotlibs+mono+libs+packs</DefaultSubsets>
<DefaultSubsets Condition="'$(TargetsLinuxBionic)' == 'true' and '$(MonoSupported)' == 'true'">clr.nativeaotruntime+clr.nativeaotlibs+mono+libs+host+packs</DefaultSubsets>
<DefaultSubsets Condition="'$(TargetsLinuxBionic)' == 'true' and '$(MonoSupported)' != 'true'">clr.nativeaotruntime+clr.nativeaotlibs+libs+packs</DefaultSubsets>
Expand All @@ -80,14 +85,20 @@
<_subset Condition="'$(Subset)' != ''">+$(Subset.ToLowerInvariant())+</_subset>
<_subset Condition="'$(Subset)' == ''">+$(DefaultSubsets)+</_subset>
</PropertyGroup>


<PropertyGroup Condition="'$(RuntimeFlavor)' == ''">
<RuntimeFlavor Condition="'$(TargetsMobile)' == 'true' and !$(_subset.Contains('+clr.nativeaotlibs+'))">Mono</RuntimeFlavor>
<RuntimeFlavor Condition="('$(TargetsMobile)' == 'true' or '$(TargetsLinuxBionic)' == 'true') and $(_subset.Contains('+clr.nativeaotlibs+'))">CoreCLR</RuntimeFlavor>
<RuntimeFlavor Condition="'$(TargetsAndroid)' == 'true' and $(_subset.Contains('+clr.'))">CoreCLR</RuntimeFlavor>
<RuntimeFlavor Condition="'$(RuntimeFlavor)' == '' and ($(_subset.Contains('+mono+')) or $(_subset.Contains('+mono.runtime+'))) and (!$(_subset.Contains('+clr+')) and !$(_subset.Contains('+clr.runtime+')) and !$(_subset.Contains('+clr.corelib+')))">Mono</RuntimeFlavor>
<RuntimeFlavor Condition="'$(RuntimeFlavor)' == ''">$(PrimaryRuntimeFlavor)</RuntimeFlavor>
</PropertyGroup>

<PropertyGroup>
<CrossBuild Condition="'$(CrossBuild)' == '' and '$(TargetsAndroid)' == 'true'">true</CrossBuild>
</PropertyGroup>
Copy link
Member

Choose a reason for hiding this comment

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

What is the expected way to invoke build.sh for android? Do we need to pass -cross? If we do need to pass -cross this property should already be set by that.

And if we don't pass -cross: does the code path added in eng/build.sh in this PR kick in? (It seems to be conditioned on -cross being passed to build.sh.)

(So far we have not been passing -cross when building for Android, there is a discussion about that at #56622).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For me, locally, this change breaks the build (and so does passing -cross):

$ ./build.sh clr+libs --os android --arch arm64 -c release --restore --build
...
Commencing CoreCLR Repo build
  Error: rootfsDir has been passed, but the location is not valid.

@steveisok are you absolutely sure it's necessary to enable cross build? Using the NDK cmake toolchain definition automatically makes the build a cross one, using the sysroot from the NDK and the appropriate target API+platform libraries and headers.

Copy link
Member

Choose a reason for hiding this comment

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

it's necessary to enable cross build

In coreclr, we consider crossbuild to be anything that's not targeting the current architecture / OS for unix based systems. So this should be cross build too. I think there are subtle parts of the build scripts that I think could misbehave if it is not done that way. I am not 100% sure though.
But, I am not a fan of feeding in the -cross option automatically. That would make the build for Android experience different from other targets where we always specify the -cross on the command line explicitly.

@grendello looking at your command line, have you set the ROOTFS_DIR env variable too? That's what's necessary for cross builds in general.

Copy link
Member

Choose a reason for hiding this comment

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

In coreclr, we consider crossbuild to be anything that's not targeting the current architecture / OS for unix based systems. So this should be cross build too. I think there are subtle parts of the build scripts that I think could misbehave if it is not done that way. I am not 100% sure though.

This is what #56622 discusses - the existing Android builds (Mono Android/Bionic, native AOT Bionic) do not pass -cross. The build infrastructure doesn't think it's a cross build (it's not considered as a cross build in libs build or in runtime build). It gets away with it because including the Android toolchain definition will make things happen.

The issue discusses switching Android build to the -cross plan but that didn't happen. I don't know if we even have Android build machines that would have the correct ROOTFS_DIR set up. We never built Android as -cross except for the community CoreCLR Android port attempt long time ago (none of the things that actually shipped and created official build specified -cross).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it's necessary to enable cross build

In coreclr, we consider crossbuild to be anything that's not targeting the current architecture / OS for unix based systems. So this should be cross build too. I think there are subtle parts of the build scripts that I think could misbehave if it is not done that way. I am not 100% sure though. But, I am not a fan of feeding in the -cross option automatically. That would make the build for Android experience different from other targets where we always specify the -cross on the command line explicitly.

@grendello looking at your command line, have you set the ROOTFS_DIR env variable too? That's what's necessary for cross builds in general.

No, I have not - to what should I point it? The NDK's toolchains/llvm/prebuilt/${OS}/sysroot directory?

Copy link
Member

Choose a reason for hiding this comment

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

we've historically never built Android/iOS/Browser with -cross since they all bring a toolchain with custom cmake and rootfs handling, we've only used -cross for "linux" builds. I'm not sure how hard it will be to untangle that.

That's what I mean by not being convinced we need to explicitly set ROOTFS_DIR in the coreclr build. Only passing the toolchain as a cmake argument will do.

Copy link
Member

Choose a reason for hiding this comment

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

Is passing -cross needed only to select a different crossgen binary or do we need it for something else?

I'm asking because -cross does a lot more than that and passing both -cross and setting up Android cmake toolchain file will cause many things to be set twice. It feels like it will cause maintenance pain.

We could make it so proper crossgen gets picked for Android even without -cross and clean that up when/if the build gets switched to the real -cross plan.

Copy link
Member

Choose a reason for hiding this comment

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

Is passing -cross needed only to select a different crossgen binary or do we need it for something else?

As far as I can tell, we only need it for crossgen. On osx (and presumably windows), the crossgen/ilcompiler builds will fail because it'll try to link against libjitinterface_arm64.so instead of libjitinterface_arm64.dylib.

Copy link
Member

Choose a reason for hiding this comment

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

I validated we don't need -cross when building from linux hosts. I pushed a commit to only enable that when on osx for now so that we can move the PR forward.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like _BuildAnyCrossArch is the property we need with a HostOS != TargetOS condition addition.


<PropertyGroup>
<DefaultCoreClrSubsets>clr.native+linuxdac+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools+host.native</DefaultCoreClrSubsets>
<DefaultCoreClrSubsets Condition="'$(PackageRID)' == 'linux-armel'">clr.native+linuxdac+clr.corelib+clr.tools+clr.nativecorelib+clr.packages+clr.nativeaotlibs+clr.crossarchtools</DefaultCoreClrSubsets>
Expand Down
2 changes: 1 addition & 1 deletion eng/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ initDistroRid()
local isCrossBuild="$3"

# Only pass ROOTFS_DIR if __DoCrossArchBuild is specified and the current platform is not an Apple platform (that doesn't use rootfs)
if [[ $isCrossBuild == 1 && "$targetOs" != "osx" && "$targetOs" != "ios" && "$targetOs" != "iossimulator" && "$targetOs" != "tvos" && "$targetOs" != "tvossimulator" && "$targetOs" != "maccatalyst" ]]; then
if [[ $isCrossBuild == 1 && "$targetOs" != "osx" && "$targetOs" != "android" && "$targetOs" != "ios" && "$targetOs" != "iossimulator" && "$targetOs" != "tvos" && "$targetOs" != "tvossimulator" && "$targetOs" != "maccatalyst" ]]; then
passedRootfsDir=${ROOTFS_DIR}
fi
initDistroRidGlobal "${targetOs}" "${targetArch}" "${passedRootfsDir}"
Expand Down
8 changes: 7 additions & 1 deletion eng/native/build-commons.sh
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,21 @@ build_native()
fi

if [[ "$targetOS" == android || "$targetOS" == linux-bionic ]]; then
# Keep in sync with $(AndroidApiLevelMin) in Directory.Build.props in the repository rooot
local ANDROID_API_LEVEL=21
if [[ -z "$ANDROID_NDK_ROOT" ]]; then
echo "Error: You need to set the ANDROID_NDK_ROOT environment variable pointing to the Android NDK root."
exit 1
fi

# cmake cache scripts can't see command line args
ANDROID_BUILD=1
export ANDROID_BUILD

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"
cmakeArgs="-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake -DANDROID_PLATFORM=android-${ANDROID_API_LEVEL} -DANDROID_NATIVE_API_LEVEL=${ANDROID_API_LEVEL} $cmakeArgs"

# Don't try to set CC/CXX in init-compiler.sh - it's handled in android.toolchain.cmake already
__Compiler="default"
Expand Down
5 changes: 5 additions & 0 deletions eng/native/configureplatform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -514,3 +514,8 @@ if (CLR_CMAKE_TARGET_ANDROID OR CLR_CMAKE_TARGET_MACCATALYST OR CLR_CMAKE_TARGET
# - Armv6: zlib-ng has build breaks
set(CLR_CMAKE_USE_SYSTEM_ZLIB 1)
endif()

if (NOT CLR_CMAKE_TARGET_ANDROID)
# opt into building tools like ildasm/ilasm
set(CLR_CMAKE_BUILD_TOOLS 1)
endif()
26 changes: 26 additions & 0 deletions eng/native/naming.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,32 @@
</PropertyGroup>

<!-- Add path globs specific to native binaries to exclude unnecessary files from packages. -->
<Choose>
<When Condition="$(HostOS.StartsWith('win'))">
<PropertyGroup>
<HostLibSuffix>.dll</HostLibSuffix>
<HostStaticLibSuffix>.lib</HostStaticLibSuffix>
<HostSymbolsSuffix>.pdb</HostSymbolsSuffix>
</PropertyGroup>
</When>
<When Condition="$(HostOS.StartsWith('osx'))">
<PropertyGroup>
<HostLibPrefix>lib</HostLibPrefix>
<HostLibSuffix>.dylib</HostLibSuffix>
<HostStaticLibSuffix>.a</HostStaticLibSuffix>
<HostSymbolsSuffix>.dwarf</HostSymbolsSuffix>
</PropertyGroup>
</When>
<Otherwise>
<PropertyGroup>
<HostLibPrefix>lib</HostLibPrefix>
<HostLibSuffix>.so</HostLibSuffix>
<HostStaticLibSuffix>.a</HostStaticLibSuffix>
<HostSymbolsSuffix>.dbg</HostSymbolsSuffix>
</PropertyGroup>
</Otherwise>
</Choose>

<Choose>
<When Condition="$(PackageRID.StartsWith('win'))">
<PropertyGroup>
Expand Down
53 changes: 28 additions & 25 deletions eng/native/tryrun.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
set(CROSS_ROOTFS $ENV{ROOTFS_DIR})
set(TARGET_ARCH_NAME $ENV{TARGET_BUILD_ARCH})
set(ANDROID_BUILD $ENV{ANDROID_BUILD})

# Also allow building as Android without specifying `-cross`.
if(NOT DEFINED TARGET_ARCH_NAME AND DEFINED ANDROID_PLATFORM)
if(NOT DEFINED TARGET_ARCH_NAME AND DEFINED ANDROID_BUILD)
if(ANDROID_ABI STREQUAL "arm64-v8a")
set(TARGET_ARCH_NAME "arm64")
elseif(ANDROID_ABI STREQUAL "x86_64")
Expand All @@ -21,34 +22,36 @@ macro(set_cache_value)
set(${ARGV0}__TRYRUN_OUTPUT "dummy output" CACHE STRING "Output from TRY_RUN" FORCE)
endmacro()

if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv7-alpine-linux-musleabihf OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/aarch64-alpine-linux-musl OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/s390x-alpine-linux-musl OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/ppc64le-alpine-linux-musl OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/i586-alpine-linux-musl OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/x86_64-alpine-linux-musl OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/riscv64-alpine-linux-musl)
if(NOT DEFINED ANDROID_BUILD)
if(EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv7-alpine-linux-musleabihf OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/armv6-alpine-linux-musleabihf OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/aarch64-alpine-linux-musl OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/s390x-alpine-linux-musl OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/ppc64le-alpine-linux-musl OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/i586-alpine-linux-musl OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/x86_64-alpine-linux-musl OR
EXISTS ${CROSS_ROOTFS}/usr/lib/gcc/riscv64-alpine-linux-musl)

set(ALPINE_LINUX 1)
elseif(EXISTS ${CROSS_ROOTFS}/bin/freebsd-version)
set(FREEBSD 1)
set(CMAKE_SYSTEM_NAME FreeBSD)
set(CLR_CMAKE_TARGET_OS freebsd)
elseif(EXISTS ${CROSS_ROOTFS}/usr/platform/i86pc)
set(ILLUMOS 1)
set(CLR_CMAKE_TARGET_OS sunos)
elseif(EXISTS /System/Library/CoreServices)
set(DARWIN 1)
elseif(EXISTS ${CROSS_ROOTFS}/etc/tizen-release)
set(TIZEN 1)
elseif(EXISTS ${CROSS_ROOTFS}/boot/system/develop/headers/config/HaikuConfig.h)
set(HAIKU 1)
set(CLR_CMAKE_TARGET_OS haiku)
set(ALPINE_LINUX 1)
elseif(EXISTS ${CROSS_ROOTFS}/bin/freebsd-version)
set(FREEBSD 1)
set(CMAKE_SYSTEM_NAME FreeBSD)
set(CLR_CMAKE_TARGET_OS freebsd)
elseif(EXISTS ${CROSS_ROOTFS}/usr/platform/i86pc)
set(ILLUMOS 1)
set(CLR_CMAKE_TARGET_OS sunos)
elseif(EXISTS /System/Library/CoreServices)
set(DARWIN 1)
elseif(EXISTS ${CROSS_ROOTFS}/etc/tizen-release)
set(TIZEN 1)
elseif(EXISTS ${CROSS_ROOTFS}/boot/system/develop/headers/config/HaikuConfig.h)
set(HAIKU 1)
set(CLR_CMAKE_TARGET_OS haiku)
endif()
endif()

if(DARWIN)
if(TARGET_ARCH_NAME MATCHES "^(arm64|x64)$")
if(DEFINED ANDROID_BUILD OR TARGET_ARCH_NAME MATCHES "^(arm64|x64)$")
set_cache_value(HAS_POSIX_SEMAPHORES_EXITCODE 1)
set_cache_value(HAVE_BROKEN_FIFO_KEVENT_EXITCODE 1)
set_cache_value(HAVE_BROKEN_FIFO_SELECT_EXITCODE 1)
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/coreclr/templates/build-perf-sample-apps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ parameters:
steps:
# Build Android sample app
- ${{ if eq(parameters.osGroup, 'android') }}:
- script: make run MONO_ARCH=arm64 DEPLOY_AND_RUN=false
- script: make run TARGET_ARCH=arm64 DEPLOY_AND_RUN=false
workingDirectory: $(Build.SourcesDirectory)/src/mono/sample/Android
displayName: Build HelloAndroid sample app
- template: /eng/pipelines/common/upload-artifact-step.yml
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/.nuget/coreclr-packages.proj
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
<ProjectReference Include="ILCompiler.Reflection.ReadyToRun.Experimental\ILCompiler.Reflection.ReadyToRun.Experimental.pkgproj" />
</ItemGroup>

<ItemGroup Condition="'$(RuntimeFlavor)' == 'CoreCLR'">
<ItemGroup Condition="'$(RuntimeFlavor)' == 'CoreCLR' and '$(TargetsMobile)' != 'true' ">
<ProjectReference Include="Microsoft.NETCore.TestHost\Microsoft.NETCore.TestHost.proj" />
</ItemGroup>

<ItemGroup>
<ItemGroup Condition=" '$(TargetsMobile)' != 'true' ">
<ProjectReference Include="Microsoft.NETCore.ILAsm\Microsoft.NETCore.ILAsm.proj" />
<ProjectReference Include="Microsoft.NETCore.ILDAsm\Microsoft.NETCore.ILDAsm.proj" />
</ItemGroup>
Expand Down
6 changes: 4 additions & 2 deletions src/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,10 @@ if(NOT CLR_CMAKE_HOST_MACCATALYST AND NOT CLR_CMAKE_HOST_IOS AND NOT CLR_CMAKE_H
add_subdirectory(utilcode)
add_subdirectory(inc)

add_subdirectory(ilasm)
add_subdirectory(ildasm)
if (CLR_CMAKE_BUILD_TOOLS)
add_subdirectory(ilasm)
add_subdirectory(ildasm)
endif(CLR_CMAKE_BUILD_TOOLS)
add_subdirectory(gcinfo)
add_subdirectory(jit)
add_subdirectory(vm)
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/clrfeatures.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ endif()

if (CLR_CMAKE_TARGET_WIN32)
set(FEATURE_TYPEEQUIVALENCE 1)
endif(CLR_CMAKE_TARGET_WIN32)
endif(CLR_CMAKE_TARGET_WIN32)
4 changes: 3 additions & 1 deletion src/coreclr/crossgen-corelib.proj
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@
<CrossGenDllCmd>$(CrossGenDllCmd) -o:$(CoreLibOutputPath)</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) -r:$([MSBuild]::NormalizePath('$(BinDir)', 'IL', '*.dll'))</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) --targetarch:$(TargetArchitecture)</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) --targetos:$(TargetOS)</CrossGenDllCmd>
<CrossGenDllCmd Condition="'$(TargetsAndroid)' != 'true'">$(CrossGenDllCmd) --targetos:$(TargetOS)</CrossGenDllCmd>
<!-- Unless and until Android requires R2R specific customizations, we're just dealing with another linux -->
<CrossGenDllCmd Condition="'$(TargetsAndroid)' == 'true'">$(CrossGenDllCmd) --targetos:linux</CrossGenDllCmd>
<CrossGenDllCmd Condition="'$(UsingToolIbcOptimization)' != 'true' and '$(EnableNgenOptimization)' == 'true'">$(CrossGenDllCmd) -m:$(MergedMibcPath) --embed-pgo-data</CrossGenDllCmd>
<CrossGenDllCmd>$(CrossGenDllCmd) -O</CrossGenDllCmd>
<CrossGenDllCmd Condition="'$(Configuration)' == 'Debug' or '$(Configuration)' == 'Checked'">$(CrossGenDllCmd) --verify-type-and-field-layout</CrossGenDllCmd>
Expand Down
4 changes: 0 additions & 4 deletions src/coreclr/dlls/mscoree/coreclr/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,10 +58,6 @@ else(CLR_CMAKE_HOST_WIN32)

set_exports_linker_option(${EXPORTS_FILE})

if(CLR_CMAKE_TARGET_ANDROID AND CLR_CMAKE_HOST_ARCH_ARM)
set(EXPORTS_LINKER_OPTION "${EXPORTS_LINKER_OPTION} -Wl,--no-warn-shared-textrel")
endif(CLR_CMAKE_TARGET_ANDROID AND CLR_CMAKE_HOST_ARCH_ARM)

endif (CLR_CMAKE_HOST_WIN32)

add_definitions(-DFX_VER_INTERNALNAME_STR=CoreCLR.dll)
Expand Down
8 changes: 7 additions & 1 deletion src/coreclr/hosts/inc/coreclrhost.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,17 @@

#include <stdint.h>

#ifdef __cplusplus
#define CORECLR_HOSTING_API_LINKAGE extern "C"
#else
#define CORECLR_HOSTING_API_LINKAGE
#endif

// For each hosting API, we define a function prototype and a function pointer
// The prototype is useful for implicit linking against the dynamic coreclr
// library and the pointer for explicit dynamic loading (dlopen, LoadLibrary)
#define CORECLR_HOSTING_API(function, ...) \
extern "C" int CORECLR_CALLING_CONVENTION function(__VA_ARGS__); \
CORECLR_HOSTING_API_LINKAGE int CORECLR_CALLING_CONVENTION function(__VA_ARGS__); \
typedef int (CORECLR_CALLING_CONVENTION *function##_ptr)(__VA_ARGS__)

//
Expand Down
9 changes: 4 additions & 5 deletions src/coreclr/inc/crosscomp.h
Original file line number Diff line number Diff line change
Expand Up @@ -696,15 +696,15 @@ typedef struct _T_KNONVOLATILE_CONTEXT_POINTERS {
#define DAC_CS_NATIVE_DATA_SIZE 24
#elif defined(TARGET_FREEBSD) && defined(TARGET_ARM64)
#define DAC_CS_NATIVE_DATA_SIZE 24
#elif defined(TARGET_LINUX) && defined(TARGET_ARM)
#elif (defined(TARGET_LINUX) || defined(TARGET_ANDROID)) && defined(TARGET_ARM)
#define DAC_CS_NATIVE_DATA_SIZE 80
#elif defined(TARGET_LINUX) && defined(TARGET_ARM64)
#elif (defined(TARGET_LINUX) || defined(TARGET_ANDROID)) && defined(TARGET_ARM64)
#define DAC_CS_NATIVE_DATA_SIZE 104
#elif defined(TARGET_LINUX) && defined(TARGET_LOONGARCH64)
#define DAC_CS_NATIVE_DATA_SIZE 96
#elif defined(TARGET_LINUX) && defined(TARGET_X86)
#elif (defined(TARGET_LINUX) || defined(TARGET_ANDROID)) && defined(TARGET_X86)
#define DAC_CS_NATIVE_DATA_SIZE 76
#elif defined(TARGET_LINUX) && defined(TARGET_AMD64)
#elif (defined(TARGET_LINUX) || defined(TARGET_ANDROID)) && defined(TARGET_AMD64)
#define DAC_CS_NATIVE_DATA_SIZE 96
#elif defined(TARGET_LINUX) && defined(TARGET_S390X)
#define DAC_CS_NATIVE_DATA_SIZE 96
Expand Down Expand Up @@ -748,4 +748,3 @@ struct T_CRITICAL_SECTION {
#else
#define T_CRITICAL_SECTION CRITICAL_SECTION
#endif

10 changes: 8 additions & 2 deletions src/coreclr/minipal/Unix/doublemapping.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
#include <linux/memfd.h>
#include <sys/syscall.h> // __NR_memfd_create
#define memfd_create(...) syscall(__NR_memfd_create, __VA_ARGS__)
#elif defined(TARGET_ANDROID)
#include <sys/syscall.h> // __NR_memfd_create
#define memfd_create(...) syscall(__NR_memfd_create, __VA_ARGS__)
#endif // TARGET_LINUX && !MFD_CLOEXEC
#include "minipal.h"
#include "minipal/cpufeatures.h"
Expand Down Expand Up @@ -48,12 +51,13 @@ bool VMToOSInterface::CreateDoubleMemoryMapper(void** pHandle, size_t *pMaxExecu

#ifdef TARGET_FREEBSD
int fd = shm_open(SHM_ANON, O_RDWR | O_CREAT, S_IRWXU);
#elif defined(TARGET_LINUX)
#elif defined(TARGET_LINUX) || defined(TARGET_ANDROID)
int fd = memfd_create("doublemapper", MFD_CLOEXEC);
#else
int fd = -1;
#endif

#ifndef TARGET_ANDROID
// Bionic doesn't have shm_{open,unlink}
// POSIX fallback
if (fd == -1)
{
Expand All @@ -64,11 +68,13 @@ bool VMToOSInterface::CreateDoubleMemoryMapper(void** pHandle, size_t *pMaxExecu
fd = shm_open(name, O_RDWR | O_CREAT | O_EXCL | O_NOFOLLOW, 0600);
shm_unlink(name);
}
#endif // !TARGET_ANDROID

if (fd == -1)
{
return false;
}
#endif

if (ftruncate(fd, MaxDoubleMappedSize) == -1)
{
Expand Down
3 changes: 2 additions & 1 deletion src/coreclr/pal/src/configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -936,7 +936,8 @@ elseif(CLR_CMAKE_TARGET_HAIKU)
set(DEADLOCK_WHEN_THREAD_IS_SUSPENDED_WHILE_BLOCKED_ON_MUTEX 0)
set(HAVE_SCHED_OTHER_ASSIGNABLE 1)
else() # Anything else is Linux
if(NOT HAVE_LTTNG_TRACEPOINT_H AND FEATURE_EVENT_TRACE)
# LTTNG is not available on Android, so don't error out
if(NOT HAVE_LTTNG_TRACEPOINT_H AND NOT CLR_CMAKE_TARGET_ANDROID AND FEATURE_EVENT_TRACE)
unset(HAVE_LTTNG_TRACEPOINT_H CACHE)
message(FATAL_ERROR "Cannot find liblttng-ust-dev. Try installing liblttng-ust-dev (or the appropriate packages for your platform)")
endif()
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/pal/src/eventprovider/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
set(EVENT_MANIFEST ${VM_DIR}/ClrEtwAll.man)

if(CLR_CMAKE_HOST_LINUX)
if(CLR_CMAKE_HOST_LINUX AND NOT CLR_CMAKE_HOST_ANDROID)
add_subdirectory(lttngprovider)
else()
add_subdirectory(dummyprovider)
Expand Down
3 changes: 3 additions & 0 deletions src/coreclr/pal/src/map/map.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2553,6 +2553,8 @@ BOOL MAPMarkSectionAsNotNeeded(LPCVOID lpAddress)
}

BOOL retval = TRUE;

#ifndef TARGET_ANDROID
CPalThread * pThread = InternalGetCurrentThread();
InternalEnterCriticalSection(pThread, &mapping_critsec);
PLIST_ENTRY pLink, pLinkNext = NULL;
Expand Down Expand Up @@ -2583,6 +2585,7 @@ BOOL MAPMarkSectionAsNotNeeded(LPCVOID lpAddress)
}

InternalLeaveCriticalSection(pThread, &mapping_critsec);
#endif // TARGET_ANDROID

TRACE_(LOADER)("MAPMarkSectionAsNotNeeded returning %d\n", retval);
return retval;
Expand Down
8 changes: 3 additions & 5 deletions src/coreclr/runtime.proj
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,14 @@
<ItemGroup Condition="('$(TargetsAndroid)' == 'true' or '$(TargetsLinuxBionic)' == 'true') and '$(ANDROID_NDK_ROOT)' != ''">
<_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=&quot;no-rtti no-exceptions&quot;"/>
<_CoreClrBuildArg Include="-DANDROID_STL=c++_static"/>
<_CoreClrBuildArg Include="-DANDROID_CPP_FEATURES=&quot;no-rtti exceptions&quot;"/>
<_CoreClrBuildArg Include="-DANDROID_PLATFORM=android-$(AndroidApiLevelMin)"/>
<_CoreClrBuildArg Include="-DANDROID_NATIVE_API_LEVEL=$(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" />

<!-- No LTTNG on Android -->
<_CoreClrBuildArg Include="-cmakeargs -DFEATURE_EVENT_TRACE=0"/>
</ItemGroup>

<PropertyGroup>
Expand Down
Loading
Loading