From jvos at openjdk.org Mon Jan 5 09:52:09 2026 From: jvos at openjdk.org (Johan Vos) Date: Mon, 5 Jan 2026 09:52:09 GMT Subject: RFR: 8370659: [mobile] enable static-libs-image for Android [v2] In-Reply-To: References: Message-ID: > This PR adds the changes required to compile libjvm.a and the classlibs using the latest upstream code. > > Some notes: > > To configure/make, the following configuration is recommended: > > bash ./configure \ > --disable-warnings-as-errors \ > --openjdk-target=aarch64-linux-android \ > --with-boot-jdk=/opt/jdk-25 \ > --with-toolchain-path=/opt/android-ndk-r29/toolchains/llvm/prebuilt/linux-x86_64/bin \ > --with-sysroot=/opt/android-ndk-r29/toolchains/llvm/prebuilt/linux-x86_64/sysroot \ > --with-toolchain-type=clang > > > After configuring the build, run > `make static-libs-image` > > Note that this requires Android NDK 29, which can be downloaded from https://developer.android.com/ndk/downloads > I only tested this using Linux. Mac/Windows builds may or may not work. > > In `make/autoconf/flags-cflags.m4`, the minimum android version is set to 32 (`-target aarch64-linux-android32`). The reason for this is that this version comes with a version of bionic that supports thr_current. This is not strictly needed, but lower versions would require more bionic-specific patches. > > I use `#ifdef __BIONIC__ `and similar in most places where we do "Android" specific checks. The reason for this is that those checks mainly refer to support that is (or isn't) available in Bionic. As such, it is better to compare e.g. bionic with musl and libc unless we are specifically using Android API's > > I can provide a sample with a Makefile that validates the build on a real phone, but I think that is not in scope of this PR. Johan Vos has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision: - Merge branch 'master' into 8370659-android - Changes required to compile libjvm.a and the classlibs using the latest upstream code. ------------- Changes: - all: https://git.openjdk.org/mobile/pull/40/files - new: https://git.openjdk.org/mobile/pull/40/files/f7b2b4b5..b07138f3 Webrevs: - full: https://webrevs.openjdk.org/?repo=mobile&pr=40&range=01 - incr: https://webrevs.openjdk.org/?repo=mobile&pr=40&range=00-01 Stats: 382120 lines in 5538 files changed: 246515 ins; 83555 del; 52050 mod Patch: https://git.openjdk.org/mobile/pull/40.diff Fetch: git fetch https://git.openjdk.org/mobile.git pull/40/head:pull/40 PR: https://git.openjdk.org/mobile/pull/40 From jvos at openjdk.org Mon Jan 5 11:11:53 2026 From: jvos at openjdk.org (Johan Vos) Date: Mon, 5 Jan 2026 11:11:53 GMT Subject: RFR: 8370659: [mobile] enable static-libs-image for Android [v2] In-Reply-To: References: Message-ID: On Mon, 22 Dec 2025 13:37:09 GMT, Julian Waters wrote: >> Johan Vos has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision: >> >> - Merge branch 'master' into 8370659-android >> - Changes required to compile libjvm.a and the classlibs using the latest upstream code. > > make/autoconf/flags-cflags.m4 line 73: > >> 71: >> 72: # Debug symbols >> 73: if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$OPENJDK_TARGET_OS" = xandroid; then > > What gcc flags does Android need that can't be done in the clang block? @TheShermanTanker That's an excellent question, and I'm not happy with my answer. Unless I'm missing something, unfortunately there is no way to use different debug flags when building for target versus for build system. When compiling for target Android on a Linux host, the same set of flags are used. We use different compilers though: clang for the Android code for code that eventually will run on Android, and c for the tools that will run on the build system. The check in flags-cflags.m4 checks for the toolchain, but the flags are also applied for code that needs to be built and executed on the build system. > make/autoconf/flags-cflags.m4 line 435: > >> 433: CFLAGS_OS_DEF_JVM="-D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_" >> 434: elif test "x$OPENJDK_TARGET_OS" = xandroid; then >> 435: CFLAGS_OS_DEF_JVM="-target aarch64-linux-android32 -DLINUX -D_ALLBSD_SOURCE -DANDROID" > > Interesting that -target is needed, I thought --openjdk-target would handle that. Admittedly however I'm not very experienced with clang/LLVM, my area of expertise is more related to gcc. openjdk-target and target are different things. The target parameter here is purely for android, and it is a combination of the usual triplet with a version (32 in this case, which is not related to 32bits). ------------- PR Review Comment: https://git.openjdk.org/mobile/pull/40#discussion_r2661126005 PR Review Comment: https://git.openjdk.org/mobile/pull/40#discussion_r2661130939 From jwaters at openjdk.org Mon Jan 5 11:59:26 2026 From: jwaters at openjdk.org (Julian Waters) Date: Mon, 5 Jan 2026 11:59:26 GMT Subject: RFR: 8370659: [mobile] enable static-libs-image for Android [v2] In-Reply-To: References: Message-ID: On Mon, 5 Jan 2026 11:06:40 GMT, Johan Vos wrote: >> make/autoconf/flags-cflags.m4 line 73: >> >>> 71: >>> 72: # Debug symbols >>> 73: if test "x$TOOLCHAIN_TYPE" = xgcc || test "x$OPENJDK_TARGET_OS" = xandroid; then >> >> What gcc flags does Android need that can't be done in the clang block? > > @TheShermanTanker That's an excellent question, and I'm not happy with my answer. Unless I'm missing something, unfortunately there is no way to use different debug flags when building for target versus for build system. When compiling for target Android on a Linux host, the same set of flags are used. We use different compilers though: clang for the Android code for code that eventually will run on Android, and c for the tools that will run on the build system. > The check in flags-cflags.m4 checks for the toolchain, but the flags are also applied for code that needs to be built and executed on the build system. I see. I'll investigate more into that to see if I can help upstream when I can. ------------- PR Review Comment: https://git.openjdk.org/mobile/pull/40#discussion_r2661249998 From ihse at openjdk.org Wed Jan 7 12:23:49 2026 From: ihse at openjdk.org (Magnus Ihse Bursie) Date: Wed, 7 Jan 2026 12:23:49 GMT Subject: RFR: 8370659: [mobile] enable static-libs-image for Android [v2] In-Reply-To: References: Message-ID: On Mon, 5 Jan 2026 09:52:09 GMT, Johan Vos wrote: >> This PR adds the changes required to compile libjvm.a and the classlibs using the latest upstream code. >> >> Some notes: >> >> To configure/make, the following configuration is recommended: >> >> bash ./configure \ >> --disable-warnings-as-errors \ >> --openjdk-target=aarch64-linux-android \ >> --with-boot-jdk=/opt/jdk-25 \ >> --with-toolchain-path=/opt/android-ndk-r29/toolchains/llvm/prebuilt/linux-x86_64/bin \ >> --with-sysroot=/opt/android-ndk-r29/toolchains/llvm/prebuilt/linux-x86_64/sysroot \ >> --with-toolchain-type=clang >> >> >> After configuring the build, run >> `make static-libs-image` >> >> Note that this requires Android NDK 29, which can be downloaded from https://developer.android.com/ndk/downloads >> I only tested this using Linux. Mac/Windows builds may or may not work. >> >> In `make/autoconf/flags-cflags.m4`, the minimum android version is set to 32 (`-target aarch64-linux-android32`). The reason for this is that this version comes with a version of bionic that supports thr_current. This is not strictly needed, but lower versions would require more bionic-specific patches. >> >> I use `#ifdef __BIONIC__ `and similar in most places where we do "Android" specific checks. The reason for this is that those checks mainly refer to support that is (or isn't) available in Bionic. As such, it is better to compare e.g. bionic with musl and libc unless we are specifically using Android API's >> >> I can provide a sample with a Makefile that validates the build on a real phone, but I think that is not in scope of this PR. > > Johan Vos has updated the pull request with a new target base due to a merge or a rebase. The incremental webrev excludes the unrelated changes brought in by the merge/rebase. The pull request contains two additional commits since the last revision: > > - Merge branch 'master' into 8370659-android > - Changes required to compile libjvm.a and the classlibs using the latest upstream code. We have a kind of third level as the OS_ENV; this is currently used on Windows only to separate msys/wsl/cygwin, but it could presumably be re-used (mis-used?) for Android as well. Or, we should introduce a separate OS_SUBTYPE for Android. Or,perhaps even better, introduce an OS_FAMILY=linux for OS=linux and OS=android. That might be a better fit for the "macOS is BSD" conundrum as well, so we could have OS_FAMILY=bsd and keep OS=macosx or OS=bsd to separate them. There were a lot of these BIONIC ifdefs. I must admit I don't even know what bionic is; it seems to be the android libc? Maybe we should make it more explicit, like ANDROID_LIBC or ANDROID_BIONIC? ------------- PR Comment: https://git.openjdk.org/mobile/pull/40#issuecomment-3718609073 PR Comment: https://git.openjdk.org/mobile/pull/40#issuecomment-3718612610 From jwaters at openjdk.org Wed Jan 7 12:50:13 2026 From: jwaters at openjdk.org (Julian Waters) Date: Wed, 7 Jan 2026 12:50:13 GMT Subject: RFR: 8370659: [mobile] enable static-libs-image for Android [v2] In-Reply-To: References: Message-ID: On Wed, 7 Jan 2026 12:19:27 GMT, Magnus Ihse Bursie wrote: > There were a lot of these BIONIC ifdefs. I must admit I don't even know what bionic is; it seems to be the android libc? Maybe we should make it more explicit, like ANDROID_LIBC or ANDROID_BIONIC? Bionic is indeed the Android C runtime library. Not sure if that's a built in compiler define or if it's defined by a header though? > We have a kind of third level as the OS_ENV; this is currently used on Windows only to separate msys/wsl/cygwin, but it could presumably be re-used (mis-used?) for Android as well. Or, we should introduce a separate OS_SUBTYPE for Android. > > Or,perhaps even better, introduce an OS_FAMILY=linux for OS=linux and OS=android. That might be a better fit for the "macOS is BSD" conundrum as well, so we could have OS_FAMILY=bsd and keep OS=macosx or OS=bsd to separate them. I'm not too sure what OS_SUBTYPE is? I don't find any references to it in the build system. ------------- PR Comment: https://git.openjdk.org/mobile/pull/40#issuecomment-3718692918 PR Comment: https://git.openjdk.org/mobile/pull/40#issuecomment-3718703155 From jvos at openjdk.org Thu Jan 8 07:58:08 2026 From: jvos at openjdk.org (Johan Vos) Date: Thu, 8 Jan 2026 07:58:08 GMT Subject: RFR: 8370659: [mobile] enable static-libs-image for Android [v2] In-Reply-To: References: Message-ID: On Wed, 7 Jan 2026 12:46:37 GMT, Julian Waters wrote: > We have a kind of third level as the OS_ENV; this is currently used on Windows only to separate msys/wsl/cygwin, but it could presumably be re-used (mis-used?) for Android as well. Or, we should introduce a separate OS_SUBTYPE for Android. > > Or,perhaps even better, introduce an OS_FAMILY=linux for OS=linux and OS=android. That might be a better fit for the "macOS is BSD" conundrum as well, so we could have OS_FAMILY=bsd and keep OS=macosx or OS=bsd to separate them. I agree with that. I think using OS_ENV for this is rather mis-using that property (or at least using it in a different field than the msys/cygwin options), but OS_FAMILY would make sense. However, I think that needs to be introduced upstream in jdk. The macos/bsd relation is a perfect example on why that new OS_FAMILY would be very useful. If something like that is added upstream (and used in different makefiles), we can apply it to Android as well. Until then, I suggest we are pragmatic here. ------------- PR Comment: https://git.openjdk.org/mobile/pull/40#issuecomment-3722552448 From jvos at openjdk.org Thu Jan 8 08:03:45 2026 From: jvos at openjdk.org (Johan Vos) Date: Thu, 8 Jan 2026 08:03:45 GMT Subject: RFR: 8370659: [mobile] enable static-libs-image for Android [v2] In-Reply-To: References: Message-ID: <3qOMWPZiXf0Vsr5jk8aAhr7GKVru9tm-fvdAAPa2KGE=.abbe4c8b-17c1-4cbb-b8cc-cd91bdaccb13@github.com> On Wed, 7 Jan 2026 12:46:37 GMT, Julian Waters wrote: > > We have a kind of third level as the OS_ENV; this is currently used on Windows only to separate msys/wsl/cygwin, but it could presumably be re-used (mis-used?) for Android as well. Or, we should introduce a separate OS_SUBTYPE for Android. > > Or,perhaps even better, introduce an OS_FAMILY=linux for OS=linux and OS=android. That might be a better fit for the "macOS is BSD" conundrum as well, so we could have OS_FAMILY=bsd and keep OS=macosx or OS=bsd to separate them. > > I'm not too sure what OS_SUBTYPE is? I don't find any references to it in the build system. I think @magicus suggests that adding a new OS_SUBTYPE variable is an option to fix this, similar to how OS_FAMILY would be a new variable to fix this. All suggestions (including re-using OS_ENV) come down to a 3-level hierarchy, which I believe is helpful, but should imho be introduced upstream (as otherwise we'll have to modify makefiles as well, which would increase the gap with upstream -- which is the opposite of what we want). ------------- PR Comment: https://git.openjdk.org/mobile/pull/40#issuecomment-3722586592 From jvos at openjdk.org Thu Jan 8 08:28:13 2026 From: jvos at openjdk.org (Johan Vos) Date: Thu, 8 Jan 2026 08:28:13 GMT Subject: RFR: 8370659: [mobile] enable static-libs-image for Android [v2] In-Reply-To: References: Message-ID: On Wed, 7 Jan 2026 12:43:58 GMT, Julian Waters wrote: > > There were a lot of these BIONIC ifdefs. I must admit I don't even know what bionic is; it seems to be the android libc? Maybe we should make it more explicit, like ANDROID_LIBC or ANDROID_BIONIC? > > Bionic is indeed the Android C runtime library. Not sure if that's a built in compiler define or if it's defined by a header though? In practice, Android uses the bionic libc, although the 1-1 coupling is in theory not required. I try to check on __ANDROID__ when dealing with platform-code, and check on __BIONIC__ when dealing with libc code. __BIONIC__ is defined in the standard headers of the (Android) NDK. This is similar to how __GLIBC__ is defined. In e.g. os_linux.cpp, there are a number of checks on __GLIBC__, __MUSL_LIBC and __BIONIC__ because the corresponding libc variants are slightly different. Note that in case of musl, there is no built-in equivalent of __GLIBC__ and __BIONIC__, so that one is set in flags-cflags.m4 ------------- PR Comment: https://git.openjdk.org/mobile/pull/40#issuecomment-3722758768 From jvos at openjdk.org Thu Jan 8 08:43:10 2026 From: jvos at openjdk.org (Johan Vos) Date: Thu, 8 Jan 2026 08:43:10 GMT Subject: RFR: 8370659: [mobile] enable static-libs-image for Android [v3] In-Reply-To: References: Message-ID: > This PR adds the changes required to compile libjvm.a and the classlibs using the latest upstream code. > > Some notes: > > To configure/make, the following configuration is recommended: > > bash ./configure \ > --disable-warnings-as-errors \ > --openjdk-target=aarch64-linux-android \ > --with-boot-jdk=/opt/jdk-25 \ > --with-toolchain-path=/opt/android-ndk-r29/toolchains/llvm/prebuilt/linux-x86_64/bin \ > --with-sysroot=/opt/android-ndk-r29/toolchains/llvm/prebuilt/linux-x86_64/sysroot \ > --with-toolchain-type=clang > > > After configuring the build, run > `make static-libs-image` > > Note that this requires Android NDK 29, which can be downloaded from https://developer.android.com/ndk/downloads > I only tested this using Linux. Mac/Windows builds may or may not work. > > In `make/autoconf/flags-cflags.m4`, the minimum android version is set to 32 (`-target aarch64-linux-android32`). The reason for this is that this version comes with a version of bionic that supports thr_current. This is not strictly needed, but lower versions would require more bionic-specific patches. > > I use `#ifdef __BIONIC__ `and similar in most places where we do "Android" specific checks. The reason for this is that those checks mainly refer to support that is (or isn't) available in Bionic. As such, it is better to compare e.g. bionic with musl and libc unless we are specifically using Android API's > > I can provide a sample with a Makefile that validates the build on a real phone, but I think that is not in scope of this PR. Johan Vos has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains three commits: - Merge branch 'master' into 8370659-android - Merge branch 'master' into 8370659-android - Changes required to compile libjvm.a and the classlibs using the latest upstream code. ------------- Changes: https://git.openjdk.org/mobile/pull/40/files Webrev: https://webrevs.openjdk.org/?repo=mobile&pr=40&range=02 Stats: 69 lines in 11 files changed: 66 ins; 0 del; 3 mod Patch: https://git.openjdk.org/mobile/pull/40.diff Fetch: git fetch https://git.openjdk.org/mobile.git pull/40/head:pull/40 PR: https://git.openjdk.org/mobile/pull/40 From jwaters at openjdk.org Thu Jan 8 09:13:00 2026 From: jwaters at openjdk.org (Julian Waters) Date: Thu, 8 Jan 2026 09:13:00 GMT Subject: RFR: 8370659: [mobile] enable static-libs-image for Android [v2] In-Reply-To: <3qOMWPZiXf0Vsr5jk8aAhr7GKVru9tm-fvdAAPa2KGE=.abbe4c8b-17c1-4cbb-b8cc-cd91bdaccb13@github.com> References: <3qOMWPZiXf0Vsr5jk8aAhr7GKVru9tm-fvdAAPa2KGE=.abbe4c8b-17c1-4cbb-b8cc-cd91bdaccb13@github.com> Message-ID: On Thu, 8 Jan 2026 07:59:21 GMT, Johan Vos wrote: > > > We have a kind of third level as the OS_ENV; this is currently used on Windows only to separate msys/wsl/cygwin, but it could presumably be re-used (mis-used?) for Android as well. Or, we should introduce a separate OS_SUBTYPE for Android. > > > Or,perhaps even better, introduce an OS_FAMILY=linux for OS=linux and OS=android. That might be a better fit for the "macOS is BSD" conundrum as well, so we could have OS_FAMILY=bsd and keep OS=macosx or OS=bsd to separate them. > > > > > > I'm not too sure what OS_SUBTYPE is? I don't find any references to it in the build system. > > I think @magicus suggests that adding a new OS_SUBTYPE variable is an option to fix this, similar to how OS_FAMILY would be a new variable to fix this. All suggestions (including re-using OS_ENV) come down to a 3-level hierarchy, which I believe is helpful, but should imho be introduced upstream (as otherwise we'll have to modify makefiles as well, which would increase the gap with upstream -- which is the opposite of what we want). Ah, I misread that. Sorry for the lapse in understanding. ------------- PR Comment: https://git.openjdk.org/mobile/pull/40#issuecomment-3722913973 From ihse at openjdk.org Thu Jan 8 13:52:58 2026 From: ihse at openjdk.org (Magnus Ihse Bursie) Date: Thu, 8 Jan 2026 13:52:58 GMT Subject: RFR: 8370659: [mobile] enable static-libs-image for Android [v3] In-Reply-To: References: Message-ID: On Thu, 8 Jan 2026 08:43:10 GMT, Johan Vos wrote: >> This PR adds the changes required to compile libjvm.a and the classlibs using the latest upstream code. >> >> Some notes: >> >> To configure/make, the following configuration is recommended: >> >> bash ./configure \ >> --disable-warnings-as-errors \ >> --openjdk-target=aarch64-linux-android \ >> --with-boot-jdk=/opt/jdk-25 \ >> --with-toolchain-path=/opt/android-ndk-r29/toolchains/llvm/prebuilt/linux-x86_64/bin \ >> --with-sysroot=/opt/android-ndk-r29/toolchains/llvm/prebuilt/linux-x86_64/sysroot \ >> --with-toolchain-type=clang >> >> >> After configuring the build, run >> `make static-libs-image` >> >> Note that this requires Android NDK 29, which can be downloaded from https://developer.android.com/ndk/downloads >> I only tested this using Linux. Mac/Windows builds may or may not work. >> >> In `make/autoconf/flags-cflags.m4`, the minimum android version is set to 32 (`-target aarch64-linux-android32`). The reason for this is that this version comes with a version of bionic that supports thr_current. This is not strictly needed, but lower versions would require more bionic-specific patches. >> >> I use `#ifdef __BIONIC__ `and similar in most places where we do "Android" specific checks. The reason for this is that those checks mainly refer to support that is (or isn't) available in Bionic. As such, it is better to compare e.g. bionic with musl and libc unless we are specifically using Android API's >> >> I can provide a sample with a Makefile that validates the build on a real phone, but I think that is not in scope of this PR. > > Johan Vos has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains three commits: > > - Merge branch 'master' into 8370659-android > - Merge branch 'master' into 8370659-android > - Changes required to compile libjvm.a and the classlibs using the latest upstream code. Yes, I agree that such a change needs to be made upstream first. This looks okay in the meantime. ------------- Marked as reviewed by ihse (Reviewer). PR Review: https://git.openjdk.org/mobile/pull/40#pullrequestreview-3639516159 From jvos at openjdk.org Thu Jan 8 14:38:57 2026 From: jvos at openjdk.org (Johan Vos) Date: Thu, 8 Jan 2026 14:38:57 GMT Subject: Integrated: 8370659: [mobile] enable static-libs-image for Android In-Reply-To: References: Message-ID: On Sun, 26 Oct 2025 16:10:09 GMT, Johan Vos wrote: > This PR adds the changes required to compile libjvm.a and the classlibs using the latest upstream code. > > Some notes: > > To configure/make, the following configuration is recommended: > > bash ./configure \ > --disable-warnings-as-errors \ > --openjdk-target=aarch64-linux-android \ > --with-boot-jdk=/opt/jdk-25 \ > --with-toolchain-path=/opt/android-ndk-r29/toolchains/llvm/prebuilt/linux-x86_64/bin \ > --with-sysroot=/opt/android-ndk-r29/toolchains/llvm/prebuilt/linux-x86_64/sysroot \ > --with-toolchain-type=clang > > > After configuring the build, run > `make static-libs-image` > > Note that this requires Android NDK 29, which can be downloaded from https://developer.android.com/ndk/downloads > I only tested this using Linux. Mac/Windows builds may or may not work. > > In `make/autoconf/flags-cflags.m4`, the minimum android version is set to 32 (`-target aarch64-linux-android32`). The reason for this is that this version comes with a version of bionic that supports thr_current. This is not strictly needed, but lower versions would require more bionic-specific patches. > > I use `#ifdef __BIONIC__ `and similar in most places where we do "Android" specific checks. The reason for this is that those checks mainly refer to support that is (or isn't) available in Bionic. As such, it is better to compare e.g. bionic with musl and libc unless we are specifically using Android API's > > I can provide a sample with a Makefile that validates the build on a real phone, but I think that is not in scope of this PR. This pull request has now been integrated. Changeset: a4899b49 Author: Johan Vos URL: https://git.openjdk.org/mobile/commit/a4899b4917c8bc6a9726d38a35ae79ee0f4364aa Stats: 69 lines in 11 files changed: 66 ins; 0 del; 3 mod 8370659: [mobile] enable static-libs-image for Android Reviewed-by: jwaters, ihse ------------- PR: https://git.openjdk.org/mobile/pull/40