forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get Android NDK and set up environment variables that the build needs: ``` export NDK_VER=r21b export ANDROID_NDK_ROOT=~/android-ndk-${NDK_VER} export HOST_OS=linux curl https://dl.google.com/android/repository/android-ndk-${NDK_VER}-${HOST_OS}-x86_64.zip -L --output ~/andk.zip ``` Build libs with this patch: ``` TARGET_BUILD_ARCH=arm64 ./build.sh -s clr.nativeaotlibs+libs -arch arm64 -os Android ``` We need the TARGET_BUILD_ARCH hack line because this variable is only set for crossbuilds and the infra doesn't consider Android a crossbuild. Now you have framework libs in artifacts\bin\microsoft.netcore.app.runtime.android-arm64\Debug\runtimes\android-arm64 (managed and native) and NativeAOT libs in artifacts\bin\coreclr\Android.arm64.Debug\aotsdk. Use ILC as if you're compiling for ARM64 Linux but point it to the libs that came out of the Android build above. Once you have an object file, link it with the native libs that came out of the Android build of clr.nativeaotlibs+libs above: android-ndk-r21b\toolchains\llvm\prebuilt\windows-x86_64\bin\aarch64-linux-android28-clang.cmd c:\android\repro.o -lm -lstdc++ C:\android\aotsdk\libbootstrapper.a C:\android\aotsdk\libRuntime.WorkstationGC.a c:\android\native\libSystem.Native.a -o c:\android\repro To run on a phone: Get e.g. Termiux. Make sure Termiux has access to the storage: ``` termux-setup-storage ``` Copy over to a location that allows execution (~/storage does not): ``` cp ~/storage/csharpdebuginfo ~/csharpdebuginfo chmod +x csharpdebuginfo ~/csharpdebuginfo ``` You might also need to copy over libc++_shared.so from the Android NDK. I also had to LD_PRELOAD it.
- Loading branch information
1 parent
3b2a700
commit 0e17083
Showing
5 changed files
with
38 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0e17083
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
build with subset "libs.src" (full command: TARGET_BUILD_ARCH=arm64 ./build.sh -s libs+nativeaotlibs -arch arm64 -os Android) retrieve an error
"CSC : error CS2001: Source file '../artifacts/obj/coreclr/Android.arm64.Debug/nativeaot/Runtime/Full/AsmOffsets.cs' could not be found."
0e17083
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That file should be built with the clr.nativeaotlibs subset (your command lacks the clr. part, maybe that's the problem)
Or, if you already merged from latest main branch, you need to add clr.nativeaotruntime.
0e17083
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thx for reply, actually :
artifacts/bin/coreclr/Android.arm64.Debug/aotsdk/
CSC : error CS2001: Source file 'artifacts/obj/coreclr/Android.arm64.Debug/nativeaot/Runtime/Full/AsmOffsets.cs' could not be found. [src/coreclr/nativeaot/System.Private.CoreLib/src/System.Private.CoreLib.csproj]
0e17083
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same for me but I merged from latest main branch. I tried to build clr using the above command but it failed to find GSSP libs on cmake configuration process. I also tried with the method described by blob/main/docs/workflow/building/coreclr/android.md but it failed at compilation time due missing headers.
0e17083
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I compiled it successfully with latest main branch including this patch.
0e17083
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.