Issue
I'm trying to compile LLVM/Clang 8.0.1 for Android with Cmake (since autotools i used before are no longer supported) on mac.
I'm using https://github.com/llvm/llvm-project.git. In build dir i'm using the following configure script (followed manuals):
cmake ../llvm \
-DCMAKE_INSTALL_PREFIX=/Users/asmirnov/Library/Android/llvm_android_arm \
-DLLVM_ENABLE_PROJECTS=clang \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_THREADS=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_TARGETS_TO_BUILD="ARM;X86" \
-DLIBCLANG_BUILD_STATIC=ON \
-DLLVM_INCLUDE_TESTS=OFF \
-DLLVM_ENABLE_ZLIB=OFF \
\
-DCMAKE_CROSSCOMPILING=True \
-DLLVM_TABLEGEN=/Users/asmirnov/Library/Android/llvm/bin/llvm-tblgen \
-DCLANG_TABLEGEN=/Users/asmirnov/Documents/dev/src/llvm-project/build/bin/clang-tblgen \
-DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf \
-DLLVM_TARGET_ARCH=ARM \
-DBUILD_SHARED_LIBS=ON \
-DLLVM_ENABLE_PIC=False \
-DCMAKE_TOOLCHAIN_FILE=/Users/asmirnov/Library/Android/ndk/android-ndk-r20/build/cmake/android.toolchain.cmake
As you can see i'm using CMake toolchain file from Android NDK (20).
Also i've compiled it locally and passing LLVM_TABLEGEN
and CLANG_TABLEGEN
.
Configuration went successfully, but during the build i get the following errors:
/Users/asmirnov/Documents/dev/src/llvm-project/llvm/lib/Transforms/Hello/Hello.cpp:27: error: undefined reference to 'llvm::Pass::~Pass()'
/Users/asmirnov/Documents/dev/src/llvm-project/llvm/lib/Transforms/Hello/Hello.cpp:33: error: undefined reference to 'llvm::errs()'
/Users/asmirnov/Documents/dev/src/llvm-project/llvm/lib/Transforms/Hello/Hello.cpp:34: error: undefined reference to 'llvm::errs()'
/Users/asmirnov/Documents/dev/src/llvm-project/llvm/lib/Transforms/Hello/Hello.cpp:34: error: undefined reference to 'llvm::Value::getName() const'
/Users/asmirnov/Documents/dev/src/llvm-project/llvm/lib/Transforms/Hello/Hello.cpp:34: error: undefined reference to 'llvm::raw_ostream::write_escaped(llvm::StringRef, bool)'
/Users/asmirnov/Documents/dev/src/llvm-project/llvm/include/llvm/Support/raw_ostream.h:149: error: undefined reference to 'llvm::raw_ostream::write(unsigned char)'
/Users/asmirnov/Documents/dev/src/llvm-project/llvm/include/llvm/Support/raw_ostream.h:174: error: undefined reference to 'llvm::raw_ostream::write(char const*, unsigned int)'
/Users/asmirnov/Documents/dev/src/llvm-project/llvm/lib/Transforms/Hello/Hello.cpp:45: error: undefined reference to 'llvm::Pass::~Pass()'
/Users/asmirnov/Documents/dev/src/llvm-project/llvm/lib/Transforms/Hello/Hello.cpp:51: error: undefined reference to 'llvm::errs()'
/Users/asmirnov/Documents/dev/src/llvm-project/llvm/lib/Transforms/Hello/Hello.cpp:52: error: undefined reference to 'llvm::errs()'
/Users/asmirnov/Documents/dev/src/llvm-project/llvm/lib/Transforms/Hello/Hello.cpp:52: error: undefined reference to 'llvm::Value::getName() const'
/Users/asmirnov/Documents/dev/src/llvm-project/llvm/lib/Transforms/Hello/Hello.cpp:52: error: undefined reference to 'llvm::raw_ostream::write_escaped(llvm::StringRef, bool)'
/Users/asmirnov/Documents/dev/src/llvm-project/llvm/include/llvm/PassSupport.h:98: error: undefined reference to 'llvm::PassRegistry::getPassRegistry()'
/Users/asmirnov/Documents/dev/src/llvm-project/llvm/include/llvm/PassSupport.h:98: error: undefined reference to 'llvm::PassRegistry::registerPass(llvm::PassInfo const&, bool)'
/Users/asmirnov/Documents/dev/src/llvm-project/llvm/include/llvm/PassSupport.h:98: error: undefined reference to 'llvm::PassRegistry::getPassRegistry()'
/Users/asmirnov/Documents/dev/src/llvm-project/llvm/include/llvm/PassSupport.h:98: error: undefined reference to 'llvm::PassRegistry::registerPass(llvm::PassInfo const&, bool)'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello: error: undefined reference to 'llvm::Pass::~Pass()'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello: error: undefined reference to 'llvm::Pass::getPassName() const'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello: error: undefined reference to 'llvm::Pass::print(llvm::raw_ostream&, llvm::Module const*) const'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello: error: undefined reference to 'llvm::FunctionPass::createPrinterPass(llvm::raw_ostream&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&) const'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello: error: undefined reference to 'llvm::FunctionPass::assignPassManager(llvm::PMStack&, llvm::PassManagerType)'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello: error: undefined reference to 'llvm::Pass::preparePassManager(llvm::PMStack&)'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello: error: undefined reference to 'llvm::FunctionPass::getPotentialPassManagerType() const'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello: error: undefined reference to 'llvm::Pass::getAnalysisUsage(llvm::AnalysisUsage&) const'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello: error: undefined reference to 'llvm::Pass::releaseMemory()'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello: error: undefined reference to 'llvm::Pass::getAdjustedAnalysisPointer(void const*)'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello: error: undefined reference to 'llvm::Pass::getAsImmutablePass()'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello: error: undefined reference to 'llvm::Pass::getAsPMDataManager()'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello: error: undefined reference to 'llvm::Pass::verifyAnalysis() const'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello: error: undefined reference to 'llvm::Pass::dumpPassStructure(unsigned int)'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello2: error: undefined reference to 'llvm::Pass::~Pass()'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello2: error: undefined reference to 'llvm::Pass::getPassName() const'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello2: error: undefined reference to 'llvm::Pass::print(llvm::raw_ostream&, llvm::Module const*) const'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello2: error: undefined reference to 'llvm::FunctionPass::createPrinterPass(llvm::raw_ostream&, std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&) const'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello2: error: undefined reference to 'llvm::FunctionPass::assignPassManager(llvm::PMStack&, llvm::PassManagerType)'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello2: error: undefined reference to 'llvm::Pass::preparePassManager(llvm::PMStack&)'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello2: error: undefined reference to 'llvm::FunctionPass::getPotentialPassManagerType() const'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello2: error: undefined reference to 'llvm::Pass::releaseMemory()'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello2: error: undefined reference to 'llvm::Pass::getAdjustedAnalysisPointer(void const*)'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello2: error: undefined reference to 'llvm::Pass::getAsImmutablePass()'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello2: error: undefined reference to 'llvm::Pass::getAsPMDataManager()'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello2: error: undefined reference to 'llvm::Pass::verifyAnalysis() const'
CMakeFiles/LLVMHello.dir/Hello.cpp.o:Hello.cpp:vtable for (anonymous namespace)::Hello2: error: undefined reference to 'llvm::Pass::dumpPassStructure(unsigned int)'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [lib/LLVMHello.so] Error 1
make[1]: *** [lib/Transforms/Hello/CMakeFiles/LLVMHello.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Am i doing anything wrong? Is it LLVM/Clang bug? Any workaround?
Solution
Yup, this requires some work arounds similar to this. Also use -DLLVM_DEFAULT_TARGET_TRIPLE="armv7a-linux-androideabi"
Answered By - 4ntoine
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.