LLVM Discussion Forums

Create shared object from LLVM file

I have cross compiled LLVM for ARM by giving CMake option as:cmake -G Ninja …/llvm -DLLVM_ENABLE_PROJECTS=mlir -DLLVM_BUILD_EXAMPLES=ON -DLLVM_TARGETS_TO_BUILD=“ARM” -DCMAKE_BUILD_TYPE=Release -DLLVM_ENABLE_ASSERTIONS=ON -DCMAKE_CROSSCOMPILING=True -DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf -DLLVM_ENABLE_RTTI=ON

I have cross compiled clang using
cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DLLVM_BUILD_DOCS=OFF -DCMAKE_INSTALL_PREFIX=/usr/local/cross_armhf_clang_9.0.0 -DCMAKE_CROSSCOMPILING=True -DLLVM_DEFAULT_TARGET_TRIPLE=arm-linux-gnueabihf -DLLVM_TARGET_ARCH=ARM -DLLVM_TARGETS_TO_BUILD=ARM …/llvm

I was able to generate executable for c file using clang .
But when I give .ll file for ex:clang llvm.ll -shared -fPIC -o llvm.so
error: expected ‘)’ at end of argument list
define void @matmul(float* %0, float* %1, i64 %2, i64 %3, i64 %4, i64 %5, i64 %6, float* %7, float* %8, i64 %9, i64 %10, i64 %11, i64 %12, i64 %13, float* %14, float* %15, i64 %16, i64 %17, i64 %18, i64 %19, i64 %20) !dbg !3

If I follow the same steps for X86 its working fine ,but when it comes to ARM I am getting this problem.
How Can I solve the issue?

Thank You

I tried on X86 but it is not working and producinng the same error for X86 also.

I thnk your .ll file is not valid.

If you are beginner try first to look at test cases for desire functionality in llvm/test/.

for example for matmul see https://github.com/llvm/llvm-project/blob/master/llvm/test/CodeGen/ARM/arm-matmul.ll

You may find these two talk helpful for understading LLVM IR and testing infrastructure.
2019 EuroLLVM Developers’ Meeting: V. Bridgers & F. Piovezan “LLVM IR Tutorial - Phis, GEPs …”
2019 LLVM Developers’ Meeting: Homerding & Kruse “Getting Started with the LLVM Testing Infra…”