Issue
I am trying to cross-compile openjdk 11u to android. I am using following command:
CC=aarch64-linux-android21-clang CXX=aarch64-linux-android21-clang++ bash configure --openjdk-target=aarch64-linux-android21 --with-toolchain-path=/mnt/d/ubuntu/NDK/build/tools/toolchain --with-sysroot=/mnt/d/ubuntu/NDK/build/tools/toolchain/sysroot --disable-warnings-as-errors
but i am getting output errors below:
checking resolved symbolic links for CC... no symlink configure: The C compiler (located as /mnt/d/ubuntu/NDK/build/tools/toolchain/bin/aarch64-linux-android21-clang) does not seem to be the required gcc compiler. configure: The result from running with --version was: "" configure: error: A gcc compiler is required. Try setting --with-tools-dir. configure exiting with result code 1
but if i use
/mnt/d/ubuntu/NDK/build/tools/toolchain/bin/aarch64-linux-android21-clang --version
the output is:
Android (6454773 based on r365631c2) clang version 9.0.8 (https://android.googlesource.com/toolchain/llvm-project 98c855489587874b2a325e7a516b99d838599c6f) (based on LLVM 9.0.8svn) Target: aarch64-unknown-linux-android21 Thread model: posix InstalledDir: /mnt/d/ubuntu/NDK/build/tools/toolchain/bin
Solution
If you read GCC vs. Clang/LLVM: An In-Depth Comparison of C/C++ Compilers, it is patently clear that clang is not a gcc compiler.
However, when you look at the source tree (e.g. .../jdk11/make/autoconf/toolchain.m4) there are clear signs that a clang toolchain can be used to build the JVM. The problem appears to be that the m4 macros don't understand android as a target platform, and appear to have fallen back to trying to use gcc.
Note that the Java 11 build instructions say this:
clang
The minimum accepted version of clang is 3.2. Older versions will not be accepted by
configure.To use clang instead of gcc on Linux, use
--with-toolchain-type=clang.
Having said that, I don't rate your chances of getting OpenJDK Java 11 to work on Android by simply cross-compiling it.
There is an OpenJDK project for porting Java to mobile devices at http://openjdk.java.net/projects/mobile/ ... and they seem to have stalled at Java 9. This suggests to me that there will be significant work to be done to get to a working OpenJDK Java 11 on Android. You might want to touch base with that project and anyone who might still be working on it.
Answered By - Stephen C
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.