Skip to content

[BUILD] Improve CMake to allow specify llvm-config #1200

@sergei-grechanik

Description

@sergei-grechanik

Hello, I'm trying to build tvm with LLVM support. I use LLVM 6.0 from Ubuntu 18.04. However, after
building tvm and importing it in python I get the following:

$ export LD_LIBRARY_PATH=/path-to-tvm-build-dir/:$LD_LIBRARY_PATH
$ export PYTHONPATH=/path-to-tvm-src-dir/python:${PYTHONPATH}
$ python -c 'import tvm'
: CommandLine Error: Option 'help-list' registered more than once!
LLVM ERROR: inconsistency in registered CommandLine options

After googling for a little while I found out that this problem comes from linking against llvm libs
twice. And indeed, while building tvm's .so files, it links against a bunch of libLLVMBlahBlah.a
files and also against libLLVM-6.0.so.1. Manually removing the latter seems to fix the problem. A quick and dirty workaround is to put list(REMOVE_ITEM LLVM_LIBS LLVM) after
llvm_map_components_to_libnames(LLVM_LIBS all) in CMakeLists.txt. (Actually, there is already a
line removing LTO from the same list, not sure what it is, may be another workaround?)

Honestly, I'm not sure what would be a proper workaround, may be calling the llvm-config
executable.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions