You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
how to build release version of coreclr for android? #33237
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 Release to 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.
@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 Release to the build.sh command.
(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 Release to 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 Release to the build.sh command.
(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".
$ 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 by eng/common/cross/build-android-rootfs.sh then 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"forLinux.arm64.Releasein /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++
$ 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 by eng/common/cross/build-android-rootfs.sh then 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"forLinux.arm64.Releasein /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 !
$ 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 by eng/common/cross/build-android-rootfs.sh then 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"forLinux.arm64.Releasein /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 ?
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
My previous comment was intended as: unless someone looks after Android (or any other platform for that matter) properly, such build breakages are inevitable.
Due 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 issue will now be closed since it had been marked no-recent-activity but 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.
Activity
janvorli commentedon 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.
jkotas commentedon Mar 5, 2020
cc @am11
am11 commentedon Mar 5, 2020
@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. :)
am11 commentedon Mar 5, 2020
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)
gemSender commentedon Mar 6, 2020
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.
gemSender commentedon Mar 6, 2020
i tried this but got cmake configure error blew:
-- 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"
enter command "whereis objcopy"
am11 commentedon Mar 6, 2020
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):gemSender commentedon Mar 7, 2020
I built coreclr native library successfully with the branch you shared , Thank you for your reply !
gemSender commentedon Mar 9, 2020
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
janvorli commentedon Nov 10, 2020
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.
janvorli commentedon Nov 11, 2020
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:
I haven't looked at what in that change has broken it. @am11 do you happen to have any quick ideas?
am11 commentedon Nov 11, 2020
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:
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.
janvorli commentedon Nov 11, 2020
@am11 I completely agree that since we don't test / officially support Android with coreclr, it can break any time.
dotnet-policy-service commentedon May 13, 2025
Due 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.
dotnet-policy-service commentedon May 27, 2025
This 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.