Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

llvm error: Relocation not implemented yet! when running RxCpp in orcjit or lli

I would like to run RxCpp example in llvm's IR interpreter lli.

Unfortunately, running any of the RxCpp examples fails in lli:

git clone https://github.com/Reactive-Extensions/RxCpp.git --depth 1
cd RxCpp/Rx/v2/examples/pythogerian
clang++ -S -emit-llvm -fno-use-cxa-exit -I../../src main.cpp 
lli main.ll

error-message:

Relocation type not implemented yet!
UNREACHABLE executed at llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp:232!

Questions:

What does this error exactly mean ? - what assumptions are made within llvm's orc-jit that are not satisfied ?

Is there a workaround ? - are there any LLVM-IR transformations i can apply to make this work(e.g. through a compiler-flag) ?

What special features is RxCpp using that cause this problem in llvm's orcjit ?

tested on:

clang version 5.0.0 (https://github.com/llvm-mirror/clang.git 6c9e299494de2a5b0425e46bc937f29a05128252) 
clang version 4.0.0-+rc1-1 (tags/RELEASE_400/rc1)
clang version 3.9.0-1 (tags/RELEASE_390/final)
clang version 3.8.1-12 (tags/RELEASE_381/final)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
like image 478
Gaetano Avatar asked Feb 03 '17 12:02

Gaetano


1 Answers

Seems to be an issue with thread_local / __thread.

Replacing #define RXCPP_THREAD_LOCAL __thread in rx-utils.hpp with whitespace "fixes" this issue.

The reason is a failure in the LLVM backend as it does not support TLS yet. This is related to Bug 21431 and the fact that some relocation strategies are missing in llvm's RuntimeDyld.

like image 51
Gaetano Avatar answered Nov 14 '22 11:11

Gaetano