How to cross compile MLIR for android?

Hi, I am trying to cross compile the MLIR into target aarch64-linux-android.
I have download the android NDK, and set the toolchain file when I am running Cmake.
The following is my cmake instruction.

cmake ..
    "-DCMAKE_BUILD_TYPE=Release" \
    "-DLLVM_ENABLE_PROJECTS=mlir" \
    "-DLLVM_TARGETS_TO_BUILD=AArch64" \
    "-DLLVM_TARGET_ARCH=AArch64" \
    "-DLLVM_ENABLE_RTTI=ON" \
    "-DLLVM_ENABLE_EH=ON" \
    "-DCMAKE_SYSTEM_NAME=aarch64" \
    "-DLLVM_ABI_BREAKING_CHECKS=FORCE_OFF" \
    "-DANDROID_NDK=$NDK" \
    "-DCMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake" \
    "-DANDROID_ABI=arm64-v8a" \
    "-DLLVM_ENABLE_ASSERTIONS=ON" \
    "-DLLVM_BUILD_EXAMPLES=OFF" \
    "-DLLVM_DEFAULT_TARGET_TRIPLE=aarch64-linux-android" \
    "-DLLVM_TABLEGEN=/home/brian1009/Desktop/Skymizer/llvm-project/build-bootstrap-tblgen/bin/llvm-tblgen" \
    "-DCLANG_TABLEGEN=/home/brian1009/Desktop/Skymizer/llvm-project/build-bootstrap-tblgen/bin/clang-tblgen" \
    "-DMLIR_TABLEGEN=/home/brian1009/Desktop/Skymizer/llvm-project/build-bootstrap-tblgen/bin/mlir-tblgen" 

The config is successful, but when I start building, there is a plenty of error that refer to undefined symbol, as shown below.

ld: error: undefined symbol: llvm::report_bad_alloc_error(char const*, bool)
>>> referenced by SmallVector.h:272 (/home/brian1009/Desktop/Skymizer/o2-project/umbrella/closesrc/llvm-project/llvm/include/llvm/ADT/SmallVector.h:272)
>>>               CMakeFiles/TestPlugin.dir/TestPlugin.cpp.o:(llvm::SmallVectorTemplateBase<std::__ndk1::function<bool (llvm::StringRef, llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >&, llvm::ArrayRef<llvm::PassBuilder::PipelineElement>)>, false>::grow(unsigned long))
>>> referenced by SmallVector.h:279 (/home/brian1009/Desktop/Skymizer/o2-project/umbrella/closesrc/llvm-project/llvm/include/llvm/ADT/SmallVector.h:279)
>>>               CMakeFiles/TestPlugin.dir/TestPlugin.cpp.o:(llvm::SmallVectorTemplateBase<std::__ndk1::function<bool (llvm::StringRef, llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module> >&, llvm::ArrayRef<llvm::PassBuilder::PipelineElement>)>, false>::grow(unsigned long))
>>> referenced by MemAlloc.h:33 (/home/brian1009/Desktop/Skymizer/o2-project/umbrella/closesrc/llvm-project/llvm/include/llvm/Support/MemAlloc.h:33)
>>>               CMakeFiles/TestPlugin.dir/TestPlugin.cpp.o:(llvm::safe_malloc(unsigned long))

Can anyone help me or give me some suggestion of where the error might come from ?

Thank you.

Hey,

MLIR has a category here (MLIR - LLVM Discussion Forums) where folks may see this easier (I don’t know Discourse well enough to move a post).

Where is TestPlugin.cpp from? Is this something at head in LLVM repo or NDK?

Best,

Jacques