Repository navigation
how to build release version of coreclr for android? #33237
Description
Activity
- addedarea-Infrastructure-coreclrOnly use for closed issuesOnly use for closed issuesuntriagedNew issue has not been triaged by the area ownerNew issue has not been triaged by the area owner
on Mar 5, 2020 Which .sh script are you using for the build? You don't need to use -DBUILD_TYPE=Release, there is an option of the build script that sets that. If you build it using the build.sh in the src/coreclr, then you just add
Releaseto the command line. If you build it using the build.sh in the root, the option is-runtimeConfiguration Release, but I think that it has been recently changed to be the default.
There is also a -stripsymbols option to strip the symbols from the binaries.cc @am11
Reacted by Adeel Mujahid@gemSender, we are in process of updating the Android builds. The PRs are under review at the moment. If you could try to build runtime repo (excluding mono for now) with the PR branch following these instructions: #32800 (comment), and give us some feedback that would be help us validating the changes. :)
For release build, you can add
--configuration Releaseto thebuild.shcommand.
(I have just rebased my branch with dotnet/master, also trying out a fresh build)Which .sh script are you using for the build? You don't need to use -DBUILD_TYPE=Release, there is an option of the build script that sets that. If you build it using the build.sh in the src/coreclr, then you just add
Releaseto the command line. If you build it using the build.sh in the root, the option is-runtimeConfiguration Release, but I think that it has been recently changed to be the default.
There is also a -stripsymbols option to strip the symbols from the binaries.I'v tried this but got new error messages when building v2.2.8 released . Then I tried v3.0.3 and got blocked by "liblttng-ust-devel building test" in "src/pal/src/configure.cmake" even if i installed liblttng-ust-devel for ndk 。 I'm trying to build the branch as @am11 mentioned.
For release build, you can add
--configuration Releaseto thebuild.shcommand.
(I have just rebased my branch with dotnet/master, also trying out a fresh build)i tried this but got cmake configure error blew:
CMake Error at /home/razor/coreclr_runtime_src/eng/native/configuretools.cmake:66 (message):
objcopy not found
Call Stack (most recent call first):
CMakeLists.txt:6 (include)-- Configuring incomplete, errors occurred!
See also "/home/razor/coreclr_runtime_src/artifacts/obj/android.28-arm64.Release/CMakeFiles/CMakeOutput.log"./home/razor/coreclr_runtime_src/src/installer/corehost/build.proj(43,5): error MSB3073: The command "/home/razor/coreclr_runtime_src/src/installer/corehost/build.sh Release arm64 -apphostver "5.0.0-dev" -hostver "5.0.0-dev" -fxrver "5.0.0-dev" -policyver "5.0.0-dev" -commithash "0065943756c868a7603d9c0d4d0dc46fc1ad72ee" -cross" exited with code 1.
then I enter command "find .tools/android-rootfs/android-ndk-r21 | grep objcopy"
.tools/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/x86_64-linux-android/bin/objcopy
.tools/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/aarch64-linux-android/bin/objcopy
.tools/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/i686-linux-android/bin/objcopy
.tools/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/x86_64-linux-android-objcopy
.tools/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/arm-linux-androideabi-objcopy
.tools/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/llvm-objcopy
.tools/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/aarch64-linux-android-objcopy
.tools/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/i686-linux-android-objcopy
.tools/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/share/man/man1/aarch64-linux-android-objcopy.1
.tools/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/share/man/man1/x86_64-linux-android-objcopy.1
.tools/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/share/man/man1/i686-linux-android-objcopy.1
.tools/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/share/man/man1/arm-linux-androideabi-objcopy.1
.tools/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/arm-linux-androideabi/bin/objcopy
.tools/android-rootfs/android-ndk-r21/toolchains/x86_64-4.9/prebuilt/linux-x86_64/x86_64-linux-android/bin/objcopy
.tools/android-rootfs/android-ndk-r21/toolchains/x86_64-4.9/prebuilt/linux-x86_64/bin/x86_64-linux-android-objcopy
.tools/android-rootfs/android-ndk-r21/toolchains/x86_64-4.9/prebuilt/linux-x86_64/share/man/man1/x86_64-linux-android-objcopy.1
.tools/android-rootfs/android-ndk-r21/toolchains/x86-4.9/prebuilt/linux-x86_64/i686-linux-android/bin/objcopy
.tools/android-rootfs/android-ndk-r21/toolchains/x86-4.9/prebuilt/linux-x86_64/bin/i686-linux-android-objcopy
.tools/android-rootfs/android-ndk-r21/toolchains/x86-4.9/prebuilt/linux-x86_64/share/man/man1/i686-linux-android-objcopy.1
.tools/android-rootfs/android-ndk-r21/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/bin/arm-linux-androideabi-objcopy
.tools/android-rootfs/android-ndk-r21/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/share/man/man1/arm-linux-androideabi-objcopy.1
.tools/android-rootfs/android-ndk-r21/toolchains/arm-linux-androideabi-4.9/prebuilt/linux-x86_64/arm-linux-androideabi/bin/objcopy
.tools/android-rootfs/android-ndk-r21/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/aarch64-linux-android/bin/objcopy
.tools/android-rootfs/android-ndk-r21/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/bin/aarch64-linux-android-objcopy
.tools/android-rootfs/android-ndk-r21/toolchains/aarch64-linux-android-4.9/prebuilt/linux-x86_64/share/man/man1/aarch64-linux-android-objcopy.1enter command "whereis objcopy"
objcopy: /usr/bin/objcopy /usr/share/man/man1/objcopy.1.gz
I was able to build coreclr with my PR branch (on Ubuntu bionic host) with the following command yesterday:
ROOTFS_DIR=$(realpath .tools/android-rootfs/android-ndk-r21/sysroot) ./build.sh --cross --arch arm64 --subsetCategory coreclr --configuration Releasegit hash is tip of my PR branch:
$ git rev-parse HEAD 0065943756c868a7603d9c0d4d0dc46fc1ad72ee $ git status On branch feature/android-build Your branch is up to date with 'origin/feature/android-build'.if it all looks the same, could you try cleaning the repo with
git clean -xdf, followed byeng/common/cross/build-android-rootfs.shthen execute above command. Also please show this part of the logs (where native build commences):Commencing CoreCLR Repo build __DistroRid: android.28-arm64 __RuntimeId: android.28-arm64 Setting up directories for build Checking prerequisites... /usr/bin/cmake Restoring the OptimizationData package Restore completed in 1.42 sec for /datadrive/projects/runtime4/src/coreclr/src/.nuget/optdata/optdata.csproj. Commencing build of "CoreCLR component" for Linux.arm64.Release in /datadrive/projects/runtime4/artifacts/obj/coreclr/Linux.arm64.Release Restore completed in 782.43 ms for /datadrive/projects/runtime4/eng/empty.csproj. Invoking "/datadrive/projects/runtime4/eng/native/gen-buildsys.sh" "/datadrive/projects/runtime4/src/coreclr" "/datadrive/projects/runtime4/src/coreclr" "/datadrive/projects/runtime4/artifacts/obj/coreclr/Linux.arm64.Release" arm64 clang "" "" Release "" -DCLR_ENG_NATIVE_DIR="/datadrive/projects/runtime4/eng/native" -DCLR_CMAKE_PGO_INSTRUMENT=0 -DCLR_CMAKE_OPTDATA_PATH= -DCLR_CMAKE_PGO_OPTIMIZE=1 -DCLR_REPO_ROOT_DIR="/datadrive/projects/runtime4" -DSTRIP_SYMBOLS=true loading initial cache file /datadrive/projects/runtime4/src/coreclr/tryrun.cmake -- Check for working C compiler: /datadrive/projects/android-arm64-rootfs/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- Check for working C compiler: /datadrive/projects/android-arm64-rootfs/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /datadrive/projects/android-arm64-rootfs/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
I was able to build coreclr with my PR branch (on Ubuntu bionic host) with the following command yesterday:
ROOTFS_DIR=$(realpath .tools/android-rootfs/android-ndk-r21/sysroot) ./build.sh --cross --arch arm64 --subsetCategory coreclr --configuration Releasegit hash is tip of my PR branch:
$ git rev-parse HEAD 0065943756c868a7603d9c0d4d0dc46fc1ad72ee $ git status On branch feature/android-build Your branch is up to date with 'origin/feature/android-build'.if it all looks the same, could you try cleaning the repo with
git clean -xdf, followed byeng/common/cross/build-android-rootfs.shthen execute above command. Also please show this part of the logs (where native build commences):Commencing CoreCLR Repo build __DistroRid: android.28-arm64 __RuntimeId: android.28-arm64 Setting up directories for build Checking prerequisites... /usr/bin/cmake Restoring the OptimizationData package Restore completed in 1.42 sec for /datadrive/projects/runtime4/src/coreclr/src/.nuget/optdata/optdata.csproj. Commencing build of "CoreCLR component" for Linux.arm64.Release in /datadrive/projects/runtime4/artifacts/obj/coreclr/Linux.arm64.Release Restore completed in 782.43 ms for /datadrive/projects/runtime4/eng/empty.csproj. Invoking "/datadrive/projects/runtime4/eng/native/gen-buildsys.sh" "/datadrive/projects/runtime4/src/coreclr" "/datadrive/projects/runtime4/src/coreclr" "/datadrive/projects/runtime4/artifacts/obj/coreclr/Linux.arm64.Release" arm64 clang "" "" Release "" -DCLR_ENG_NATIVE_DIR="/datadrive/projects/runtime4/eng/native" -DCLR_CMAKE_PGO_INSTRUMENT=0 -DCLR_CMAKE_OPTDATA_PATH= -DCLR_CMAKE_PGO_OPTIMIZE=1 -DCLR_REPO_ROOT_DIR="/datadrive/projects/runtime4" -DSTRIP_SYMBOLS=true loading initial cache file /datadrive/projects/runtime4/src/coreclr/tryrun.cmake -- Check for working C compiler: /datadrive/projects/android-arm64-rootfs/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- Check for working C compiler: /datadrive/projects/android-arm64-rootfs/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /datadrive/projects/android-arm64-rootfs/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
I built coreclr native library successfully with the branch you shared , Thank you for your reply !
I was able to build coreclr with my PR branch (on Ubuntu bionic host) with the following command yesterday:
ROOTFS_DIR=$(realpath .tools/android-rootfs/android-ndk-r21/sysroot) ./build.sh --cross --arch arm64 --subsetCategory coreclr --configuration Releasegit hash is tip of my PR branch:
$ git rev-parse HEAD 0065943756c868a7603d9c0d4d0dc46fc1ad72ee $ git status On branch feature/android-build Your branch is up to date with 'origin/feature/android-build'.if it all looks the same, could you try cleaning the repo with
git clean -xdf, followed byeng/common/cross/build-android-rootfs.shthen execute above command. Also please show this part of the logs (where native build commences):Commencing CoreCLR Repo build __DistroRid: android.28-arm64 __RuntimeId: android.28-arm64 Setting up directories for build Checking prerequisites... /usr/bin/cmake Restoring the OptimizationData package Restore completed in 1.42 sec for /datadrive/projects/runtime4/src/coreclr/src/.nuget/optdata/optdata.csproj. Commencing build of "CoreCLR component" for Linux.arm64.Release in /datadrive/projects/runtime4/artifacts/obj/coreclr/Linux.arm64.Release Restore completed in 782.43 ms for /datadrive/projects/runtime4/eng/empty.csproj. Invoking "/datadrive/projects/runtime4/eng/native/gen-buildsys.sh" "/datadrive/projects/runtime4/src/coreclr" "/datadrive/projects/runtime4/src/coreclr" "/datadrive/projects/runtime4/artifacts/obj/coreclr/Linux.arm64.Release" arm64 clang "" "" Release "" -DCLR_ENG_NATIVE_DIR="/datadrive/projects/runtime4/eng/native" -DCLR_CMAKE_PGO_INSTRUMENT=0 -DCLR_CMAKE_OPTDATA_PATH= -DCLR_CMAKE_PGO_OPTIMIZE=1 -DCLR_REPO_ROOT_DIR="/datadrive/projects/runtime4" -DSTRIP_SYMBOLS=true loading initial cache file /datadrive/projects/runtime4/src/coreclr/tryrun.cmake -- Check for working C compiler: /datadrive/projects/android-arm64-rootfs/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- Check for working C compiler: /datadrive/projects/android-arm64-rootfs/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -- works -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Detecting C compile features -- Detecting C compile features - done -- Check for working CXX compiler: /datadrive/projects/android-arm64-rootfs/android-rootfs/android-ndk-r21/toolchains/llvm/prebuilt/linux-x86_64/bin/clang++
I tried to host coreclr on my Android app, but when I loaded libcoreclr.so with the dlopen function, an error occurred. I called the dlerror function, and the error it returned was "libgcc_s.so.1 not found"。 Is the error relate with linking glibc library while compiling coreclr ?
29 remaining items
I've just found what's wrong. I've tried the build again, this time in a different checkout of the runtime repo and it failed the same way as for you. I've then checked the checkout I've tried it in before and it still worked. Looking at the state of that checkout reveals the reason. In the checkout I was trying it before, I had a state from March for some reason (commit bc28cbe at the head). At that time, it worked. Now it does not.
I've ran a git bisect to find the change that has broken the Android build. It was this one: #35173 - Port CoreCLR to SunOS
The problem is a failure to find an ICU include:In file included from /home/janvorli/git/runtime4/src/libraries/Native/Unix/System.Globalization.Native/pal_casing.c:9: /home/janvorli/git/runtime4/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim_internal.h:23:10: fatal error: 'unicode/ucurr.h' file not found #include <unicode/ucurr.h>I haven't looked at what in that change has broken it. @am11 do you happen to have any quick ideas?
I've ran a git bisect to find the change that has broken the Android build
Actually I fixed the Android build in February #32800. There are dozens of breaking changes since. I am surprised that git bisect has only found my other PR, while the error @nathanpovo is encountering is:
/home/nathan/github/dotnet/runtime/src/libraries/Native/Unix/System.Globalization.Native/pal_icushim_internal.h:22:10: fatal error: 'unicode/uclean.h' file not found
and that header was added in:
5c99007#diff-7ede8c5e272d0eff6c61b098c43459717e75840c2b333caee9d5fd0fe5cce81f
(this was not me..)My previous comment was intended as: unless someone looks after Android (or any other platform for that matter) properly, such build breakages are inevitable.
@am11 I completely agree that since we don't test / officially support Android with coreclr, it can break any time.
dotnet-policy-service commented
on May 13, 2025 ContributorMore actionsDue to lack of recent activity, this issue has been marked as a candidate for backlog cleanup. It will be closed if no further activity occurs within 14 more days. Any new comment (by anyone, not necessarily the author) will undo this process.
This process is part of our issue cleanup automation.
- addedbacklog-cleanup-candidateAn inactive issue that has been marked for automated closure.An inactive issue that has been marked for automated closure.
on May 13, 2025 dotnet-policy-service commented
on May 27, 2025 ContributorMore actionsThis issue will now be closed since it had been marked
no-recent-activitybut received no further activity in the past 14 days. It is still possible to reopen or comment on the issue, but please note that the issue will be locked if it remains inactive for another 30 days.Reacted by Jia Yuan Lo- locked and limited conversation to collaborators
on Jun 27, 2025 - removedbacklog-cleanup-candidateAn inactive issue that has been marked for automated closure.An inactive issue that has been marked for automated closure.
on Jun 27, 2025
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
I append “cmakeargs -DBUILD_TYPE=Release" at the end of build command and still got debug version with huge size of "libcoreclr.so"