[RUNTIME][LLVM] _cc.create_shared error while run tune_simple_template


#1

Hi I face a error while runing the tutorials/autotvm/tune_simple_template.py script. as following:

No: 1 GFLOPS: 0.00/0.00 result: MeasureResult(costs=(RuntimeError(‘Except caught from RPC call: TVMCall CFunc Error:\nTraceback (most recent call last):\n File “/home/dladmin/Repositoir/Pub/tvm/python/tvm/_ffi/_ctypes/function.py”, line 56, in cfun\n rv = local_pyfunc(*pyargs)\n File “/home/dladmin/Repositoir/Pub/tvm/python/tvm/rpc/server.py”, line 51, in load_module\n m = _load_module(path)\n File “/home/dladmin/Repositoir/Pub/tvm/python/tvm/module.py”, line 223, in load\n _cc.create_shared(path + “.so”, files)\n File “/home/dladmin/Repositoir/Pub/tvm/python/tvm/contrib/cc.py”, line 33, in create_shared\n _linux_shared(output, objects, options, cc)\n File “/home/dladmin/Repositoir/Pub/tvm/python/tvm/contrib/cc.py”, line 59, in _linux_shared\n raise RuntimeError(msg)\nRuntimeError: Compilation error:\n/usr/bin/ld: /tmp/tmpah3cflh5/lib.o: relocation R_X86_64_32S against `.rodata.cst16’ can not be used when making a shared object; recompile with -fPIC\n/tmp/tmpah3cflh5/lib.o: error adding symbols: Bad value\ncollect2: error: ld returned 1 exit status\n\n’,),), error_no=4, all_cost=0.3922765254974365, timestamp=1540458625.9476259) [(‘tile_y’, [64, 8]), (‘tile_x’, [32, 16])],None,43

My tvm is builld from source and with llvm manually set to llvm-7.0 (ubuntu 16.04), and also change the gcc to 7.3.0 with

sudo add-apt-repository ppa:ubuntu-toolchain-r/test
sudo apt-get update
sudo apt-get install gcc-7 g+±7

it seems that /usr/bin/ld complains about relocation R_X86_64_32S against .rodata.cst16 and suggest add the -fPIC flag.
is it because g++ not compatible with object file created by llvm? or any other ideas about this situation?

(from https://github.com/dmlc/tvm/issues/1985 thread)


#2

What part of your setup is built with gcc?


#3

Hi

I change my ubuntu default gcc/g++ to gcc-7, so everything build with gcc is with gcc-7. for tvm, it should be that every library(libnnvm_compiler.so/libtvm_runtime.so/libtvm.so/libtvm_topi.so/libvta.so) is build with gcc-7.

This is because I need a higher version of llvm(llvm-7) to generate AMDGPU code. and if I continue to use the gcc-5.4(default version of ubuntu-16.04), the ABI is different hence i can not do “import tvm”


#4

Same problem, have you found the solution?


#5

If you use llvm 7.0, then this problem will happen. Try to use llvm 4.0


#6

Hi.

Yes you’re right. I tested on llvm 6.0.1 and everything goes OK. It seemd other people also faced with this problem. Maybe the LLVM-7.0 create object file breaks some compatibility in PIC reloc mode.