range-analysis in Function Pass on Eclipse with CMake

Hello,

I currently write my own LLVM (function) pass and intend to use the
following project to enable the use of range analysis information in my
code: Google Code Archive - Long-term storage for Google Code Project Hosting..

Since I use Eclipse (with CMake) to build LLVM I did the following:

1. Provide each subfolder with a CMakeLists.txt (add_llvm_loadable_module).
2. Re-create the CMake config (cmake ../llvm -G "Eclipse CDT4 - Unix
Makefiles"), re-open it in Eclipse.
4. Fix some minor issues with range-analysis (some symbols were renamed
in newer LLVM releases).
5. Add the necessary code to my own pass, almost verbatim from
Google Code Archive - Long-term storage for Google Code Project Hosting..

Everything compiles fine, but loading the pass in LLVM gives me the
following error:

/opt/llvm/bin/opt: symbol lookup error: ./build/lib/RangeAnalysis.so: undefined symbol: _ZN4llvm13ConstantRangeC1ENS_5APIntES1_
error: unable to interface with target machine

I use LLVM 3.4svn on Ubuntu x64.

Do I miss a specific library?

Regards

dw <dw.dev.mailing@gmail.com> writes:

[snip]

Everything compiles fine, but loading the pass in LLVM gives me the
following error:

/opt/llvm/bin/opt: symbol lookup error: ./build/lib/RangeAnalysis.so: undefined symbol: _ZN4llvm13ConstantRangeC1ENS_5APIntES1_
error: unable to interface with target machine

I use LLVM 3.4svn on Ubuntu x64.

Do I miss a specific library?

$ c++filt _ZN4llvm13ConstantRangeC1ENS_5APIntES1_
llvm::ConstantRange::ConstantRange(llvm::APInt, llvm::APInt)

IIRC ConstantRange is defined in libLLVMSupport. That library is at the
core of the dependency graph. Do you provide a list of LLVM libraries at
all for your RangeAnalysis library?

24.09.2013 12:43, Óscar Fuentes writes:

[snip]

IIRC ConstantRange is defined in libLLVMSupport. That library is at the
core of the dependency graph. Do you provide a list of LLVM libraries at
all for your RangeAnalysis library?

Thanks. Adding "target_link_libraries(RangeAnalysis LLVMSupport)" to the
corresponding CMakeLists.txt solves the issue.