Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLVM out of source pass build: Loadable modules not supported (on Linux)

I compiled and installed LLVM from trunk on debian wheezy some weeks ago (configure & make) and now tried to out of source compile the llvm-mutate pass. AFAICC, llvm-mutate follows the cmake out of source pass build instructions.

When trying to build llvm-mutate

mkdir build
cd build
cmake -DCMAKE_MODULE_PATH=/usr/local/share/llvm/cmake ../

I get:

-- Mutate ignored -- Loadable modules not supported on this platform.

hmm? opt and the loadable passes (at llvm_trunk/build/Debug+Asserts/lib/xxx.so) are present and work (have been compiled using configure & make, not cmake).

So this problem seems to be related to cmake? Someone else faced such problems, howver on Win using cygwin: here

Any idea? Thx Alex

like image 863
alex Avatar asked Jan 09 '15 15:01

alex


3 Answers

AddLLVM cmake module needs some prerequisites. Add to CMakeLists.txt:

# AddLLVM needs these
set(LLVM_RUNTIME_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin)
set(LLVM_LIBRARY_OUTPUT_INTDIR ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/lib)

include(HandleLLVMOptions) # important: matches compiler flags to LLVM/Clang build
include(AddLLVM)

Some inspiration came from this message.

like image 131
alexei Avatar answered Nov 08 '22 02:11

alexei


Just for the sake of completeness if someone will come across this error. This bug is meanwhile fixed in LLVM 3.8.0 so that you only have to include AddLLVM to build your plugin. The HandleLLVMOption include file is only helpful to get the right compiler flags as stated above in the post.

like image 41
Andi.Hellmund Avatar answered Nov 08 '22 00:11

Andi.Hellmund


Adding to alexei's reply.

You can lso add list(APPEND CMAKE_MODULE_PATH "${LLVM_CMAKE_DIR}") in the CMakeLists.txt file prior to the include(AddLLVM) line and then having in your PATH the LLVM binary directory for llvm-config, invoke cmake as

CXX=clang++ cmake -DLLVM_DIR=$(llvm-config --prefix)/share/llvm/cmake ..
like image 1
compor Avatar answered Nov 08 '22 01:11

compor