ISSUE: configure: Using clang C compiler version 17.0.2 [Android (11349228, +pgo, +bolt, +lto, -mlgo, based on r487747e) clang version 17.0.2 (https://android.googlesource.com/toolchain/llvm-project d9f89f4d16663d5012e5c09495f3b30ece3d2362) Target: x86_64-unknown-linux-gnu] checking for aarch64-linux-android-/opt/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang... /opt/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang checking whether the C compiler works... no check conf.log, line 409: /opt/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/bin/clang --sysroot=/opt/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/sysroot --sysroot=/opt/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/sysroot --sysroot=/opt/android-ndk-r26c/toolchains/llvm/prebuilt/linux-x86_64/sysroot conftest.c 410 ld.lld: error: cannot open Scrt1.o: No such file or directory 411 ld.lld: error: cannot open crti.o: No such file or directory 412 ld.lld: error: cannot open crtbeginS.o: No such file or directory 413 ld.lld: error: unable to find library -lgcc 414 ld.lld: error: unable to find library -lgcc_s 415 ld.lld: error: unable to find library -lc 416 ld.lld: error: unable to find library -lgcc 417 ld.lld: error: unable to find library -lgcc_s SOLUTION: 1) define android as an os in platform.m4: 59 --- a/make/autoconf/platform.m4 60 +++ b/make/autoconf/platform.m4 61 @@ -198,6 +198,10 @@ AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_CPU], 62 AC_DEFUN([PLATFORM_EXTRACT_VARS_FROM_OS], 63 [ 64 case "$1" in 65 + *android*) 66 + VAR_OS=android 67 + VAR_OS_TYPE=unix 68 + ;; 2) define android specific compiler flags in flags-cflags.m4 @@ -465,6 +465,8 @@ AC_DEFUN([FLAGS_SETUP_CFLAGS_HELPER], CFLAGS_OS_DEF_JDK="-D_ALLBSD_SOURCE" elif test "x$OPENJDK_TARGET_OS" = xwindows; then CFLAGS_OS_DEF_JVM="-D_WINDOWS -DWIN32 -D_JNI_IMPLEMENTATION_" + elif test "x$OPENJDK_TARGET_OS" = xandroid; then + CFLAGS_OS_DEF_JDK="-target aarch64-linux-android -DLINUX -D__USE_BSD" fi ISSUE: configure: The BuildC compiler (located as /usr/bin/cc) does not seem to be the required clang compiler. configure: The result from running with --version was: "cc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 (reason: buildC compiler can be gcc while target compiler is clang) SOLUTION: remove buildC settings: in autoconf/toolchain.m4 @@ -874,11 +874,13 @@ AC_DEFUN_ONCE([TOOLCHAIN_SETUP_BUILD_COMPILERS], PATH="$OLDPATH" - TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CC, [BuildC]) - TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CXX, [BuildC++]) - TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_], [build ]) - TOOLCHAIN_EXTRACT_LD_VERSION(BUILD_LD, [build linker]) - TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_]) + if test "x$OPENJDK_TARGET_OS" != "xandroid"; then + TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CC, [BuildC]) + TOOLCHAIN_EXTRACT_COMPILER_VERSION(BUILD_CXX, [BuildC++]) + TOOLCHAIN_PREPARE_FOR_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_], [build ]) + TOOLCHAIN_EXTRACT_LD_VERSION(BUILD_LD, [build linker]) + TOOLCHAIN_PREPARE_FOR_LD_VERSION_COMPARISONS([BUILD_], [OPENJDK_BUILD_]) + fi ISSUE: configure: error: Could not find freetype! You might be able to fix this by running 'sudo apt-get install libfreetype6-dev'. SOLUTION: don't assume libfreetype is a system lib for android in lib-freetype.m4 @@ -103,6 +103,7 @@ AC_DEFUN_ONCE([LIB_SETUP_FREETYPE], FREETYPE_TO_USE=bundled if test "x$OPENJDK_TARGET_OS" != "xwindows" && \ test "x$OPENJDK_TARGET_OS" != "xmacosx" && \ + test "x$OPENJDK_TARGET_OS" != "xandroid" && \ test "x$OPENJDK_TARGET_OS" != "xaix"; then FREETYPE_TO_USE=system fi CONFIGURE now runs fine make ISSUE -> missing globals_android_aarch64.hpp etc cp hotspot/os/android and os_arch add os/linux to Include path ISSUE Compiling up to 3447 files for java.base /home/johan/openjdk/github/jdk/src/java.base/sharclasses/java/lang/System.java:95: error: cannot find symbol import sun.nio.fs.DefaultFileSystemProvider; SOLUTION: add linux classes to android build in make/common/Modules.gmk: 91 ifeq ($(OPENJDK_TARGET_OS), android) 92 SRC_SUBDIRS += linux/classes 93 endif ISSUE In file included from /home/johan/openjdk/github/jdk/src/java.base/share/native/libnet/net_util.h:31: /home/johan/openjdk/github/jdk/src/java.base/unix/native/libnet/net_util_md.h:70:25: error: field has incomplete type 'struct sockaddr_in' struct sockaddr_in sa4; SOLUTION: 107 +#ifdef ANDROID 108 +#include 109 +#endif ISSUE: no files to compile for libextnet SOLUTION: Add linux native sources to android build in make/common/JdkNativeCompilation.gmk +ifeq ($(OPENJDK_TARGET_OS), android) + FindSrcDirsForComponent += \ + $(call uniq, $(wildcard \ + $(TOPDIR)/src/$(strip $1)/linux/native/$(strip $2))) +endif ISSUE: AWT/Swing/X11 /home/johan/openjdk/github/jdk/src/java.desktop/unix/classes/sun/awt/X11/XDecoratedPeer.java:248: error: cannot find symbol public void handleFocusEvent(XEvent xev) { symbol: class XEvent location: class XDecoratedPeer SOLUTION: generated sources in make/modules/java.desktop/Gensrc.gmk: 35 ifeq ($(call isTargetOs, linux aix android), true) 36 include gensrc/GensrcX11Wrappers.gmk 37 endif ISSUE: More errors related to X11/AWT SOLUTION: * We do not want X11 or AWT at all. * Disable it in autoconf/libraries @@ -42,7 +42,7 @@ m4_include([lib-tests.m4]) AC_DEFUN_ONCE([LIB_DETERMINE_DEPENDENCIES], [ # Check if X11 is needed - if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx; then + if test "x$OPENJDK_TARGET_OS" = xwindows || test "x$OPENJDK_TARGET_OS" = xmacosx || test "x$OPENJDK_TARGET_OS" = xandroid; then # No X11 support on windows or macosx NEEDS_LIB_X11=false else * Disable building the awt/sound libs: 95 --- a/make/modules/java.desktop/Lib.gmk 96 +++ b/make/modules/java.desktop/Lib.gmk 97 @@ -35,10 +35,12 @@ $(call FillFindCache, $(wildcard $(TOPDIR)/src/java.desktop/*/native)) 98 ################################################################################ 99 # Create the AWT/2D libraries 100 101 -include lib/AwtLibraries.gmk 102 -include lib/ClientLibraries.gmk 103 +ifeq ($(call isTargetOs, android), false) 104 + include lib/AwtLibraries.gmk 105 + include lib/ClientLibraries.gmk 106 +endif 107 108 -ifeq ($(call isTargetOs, aix), false) 109 +ifeq ($(call isTargetOs, aix android), false) 110 ############################################################################## 111 # Build libjsound 112 ############################################################################## No X11 on android -ifeq ($(call isTargetOs, macosx), true) +ifeq ($(call isTargetOs, macosx android), true) # exclude all X11 on Mac. ISSUE: /home/johan/openjdk/github/jdk/src/jdk.hotspot.agent/linux/native/libsaproc/elfmacros.h:38:9: error: 'ELF_ST_TYPE' macro redefined [-Werror,-Wmacro-redefined] #define ELF_ST_TYPE ELF64_ST_TYPE ^ SOLUTION: remove redefinition on android: 107 diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/elfmacros.h b/src/jdk.hotspot.agent/linux/native/libsaproc/elfmacros.h 108 index 2dc0b611c2e..78508bc7eb1 100644 109 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/elfmacros.h 110 +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/elfmacros.h 111 @@ -35,7 +35,9 @@ 112 #define ELF_ADDR Elf64_Addr 113 #define ELF_AUXV Elf64_auxv_t 114 115 +#ifndef ANDROID 116 #define ELF_ST_TYPE ELF64_ST_TYPE 117 +#endif 118 119 #else 120 ISSUE: /home/johan/openjdk/github/jdk/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c:189:4: error: use of undeclared identifier 'prstatus_t' prstatus_t* prstat = (prstatus_t*) buf; SOLUTION: diff --git a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c index b1b69c81e2e..972f9e3ac4b 100644 --- a/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c +++ b/src/jdk.hotspot.agent/linux/native/libsaproc/ps_core.c @@ -184,6 +184,9 @@ static ps_prochandle_ops core_ops = { // read regs and create thread from NT_PRSTATUS entries from core file static bool core_handle_prstatus(struct ps_prochandle* ph, const char* buf, size_t nbytes) { +#ifdef ANDROID + return false; +#else // we have to read prstatus_t from buf // assert(nbytes == sizeof(prstaus_t), "size mismatch on prstatus_t"); prstatus_t* prstat = (prstatus_t*) buf; @@ -243,6 +246,7 @@ static bool core_handle_prstatus(struct ps_prochandle* ph, const char* buf, size } return true; +#endif // ANDROID }