If llvm is not installed in default location, or there are multiple installations on the system, then specify LLVM_DIR alone is not suffice
llvm-config path
cmake searches LLVM-Config.cmake under LLVM_DIR. However, current CMakeLists.txt relies on llvm-config to give proper compile/link flags, and llvm-config is still gonna be searched in default locations. The result it, -I and -L will refer to different LLVM build.
If LLVM_DIR and default LLVM installation on the system have different versions/build flags etc., it will throw all kinds of weird linking errors
To solve this problem, LLVM_TOOLS_BINARY_DIR not only has to be added to llvm-config search path, but also must have higher precedence.
Another thing is -Werror fails compilation because of warnings emitted from LLVM header files. To solve this, LLVM header files should be considered as SYSTEM header
Because hobbes replies on RTTI, so LLVM it self must be built with RTTI support, that is not default for LLVM
If no-rtti, linking llvm with hobbes will give errors like
/usr/bin/ld: libhobbes.a(jitcc.C.o):(.data.rel.ro._ZTIN6hobbes8LenWatchE[_ZTIN6hobbes8LenWatchE]+0x10): undefined reference to `typeinfo for llvm::JITEventListener'
/usr/bin/ld: libhobbes.a(jitcc.C.o):(.data.rel.ro._ZTIN6hobbes5jitmmE[_ZTIN6hobbes5jitmmE]+0x10): undefined reference to `typeinfo for llvm::SectionMemoryManager
to sum up
To work with custom LLVM location
LLVM must be built with an extra -DLLVM_ENABLE_RTTI=ON
If llvm is not installed in default location, or there are multiple installations on the system, then specify
LLVM_DIR
alone is not sufficellvm-config path
cmake searches
LLVM-Config.cmake
underLLVM_DIR
. However, currentCMakeLists.txt
relies onllvm-config
to give proper compile/link flags, andllvm-config
is still gonna be searched in default locations. The result it,-I
and-L
will refer to different LLVM build.If
LLVM_DIR
and default LLVM installation on the system have different versions/build flags etc., it will throw all kinds of weird linking errorsTo solve this problem,
LLVM_TOOLS_BINARY_DIR
not only has to be added tollvm-config
search path, but also must have higher precedence.warnings from LLVM header
Another thing is
-Werror
fails compilation because of warnings emitted from LLVM header files. To solve this, LLVM header files should be considered asSYSTEM
headerno-rtti
Because hobbes replies on RTTI, so LLVM it self must be built with RTTI support, that is not default for LLVM
If no-rtti, linking llvm with hobbes will give errors like
to sum up
To work with custom LLVM location
LLVM must be built with an extra
-DLLVM_ENABLE_RTTI=ON
hobbes must be built with an extra
-DLLVM_TOOLS_BINARY_DIR