Error at linking time

I was trying to build my own custom backend (GitHub - MaxBubblegum47/LLVM_13_MBLAZE: This is a fork of LLVM 13.0.1 with the implementation of MBLAZE's support), but I got this strange error:

[ 79%] Linking CXX shared library ../../lib/libLTO.so
/usr/bin/ld: ../../lib/libLLVMMBLAZECodeGen.a(MBLAZEISelDAGToDAG.cpp.o): warning: relocation against `_ZTVN12_GLOBAL__N_118MBLAZEDAGToDAGISelE' in read-only section `.text'
/usr/bin/ld: ../../lib/libLLVMMBLAZECodeGen.a(MBLAZEISelDAGToDAG.cpp.o): in function `(anonymous namespace)::MBLAZEDAGToDAGISel::MBLAZEDAGToDAGISel(llvm::MBLAZETargetMachine&, llvm::CodeGenOpt::Level)':
/home/maxbubblegum/LLVM_13_MBLAZE/llvm/lib/Target/MBLAZE/MBLAZEISelDAGToDAG.cpp:28: undefined reference to `vtable for (anonymous namespace)::MBLAZEDAGToDAGISel'
/usr/bin/ld: ../../lib/libLLVMMBLAZECodeGen.a(MBLAZEISelDAGToDAG.cpp.o): relocation R_X86_64_PC32 against undefined symbol `_ZTVN12_GLOBAL__N_118MBLAZEDAGToDAGISelE' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make[2]: *** [tools/lto/CMakeFiles/LTO.dir/build.make:163: lib/libLTO.so.13] Error 1
make[1]: *** [CMakeFiles/Makefile2:14363: tools/lto/CMakeFiles/LTO.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

I don’t how to manage it, do you have any suggestions to me?
Thanks :slight_smile:

Try passing

-DLLVM_ENABLE_PIC

to your CMake invocation.

1 Like

Thank you so much! I solved the error, was totally my fault because I didn’t handle very well a virtual method :frowning: