irony-mode icon indicating copy to clipboard operation
irony-mode copied to clipboard

checking environment variable to find libclang

Open little-big-h opened this issue 8 years ago • 8 comments

little-big-h avatar Sep 28 '16 14:09 little-big-h

Where is the LLVM_ROOT environment variable used? I can't find a real reference to it in the LLVM source code.

Sarcasm avatar Sep 30 '16 17:09 Sarcasm

I don't know that it is used in LLVM but it seems a (loose) convention in cmake modules. Boost uses BOOST_ROOT, GTest uses GTEST_ROOT, dart uses DART_ROOT, ...

little-big-h avatar Sep 30 '16 18:09 little-big-h

For now I prefer to recommend using -DLIBCLANG_LIBRARY=<path> and -DLIBCLANG_INCLUDE_DIR=<path>.

Ideally at some point we would have one variable to locate the LLVM root in one place but this variable would be the llvm-config executable path.

Sarcasm avatar Sep 30 '16 18:09 Sarcasm

ideally, you would use the cmake files that come with llvm

little-big-h avatar Sep 30 '16 18:09 little-big-h

that's right ;)

Sarcasm avatar Sep 30 '16 18:09 Sarcasm

Oddly, even using

   -DCLANG_INSTALL_PREFIX=/usr/lib/llvm-3.8
   -DLibclang_LIBRARY=/usr/lib/llvm-3.8/lib/libclang-3.8.so.1
   -DLibclang_INCLUDE_DIR=/usr/lib/llvm-3.8/include

as mentioned above to force the use of LLVM/Clang 3.8, it still somehow ended up using LLVM 8 (with -I/usr/lib/llvm-8/include being the telltale sign) until I physically broke the LLVM8 install by renaming the directory with a trailing underscore, then it used my preferred version.

Trying the suggested patch now.

Any idea why this woulldn't work? I also had LLVM_ROOT set in my environment at the time (something I always do when configuring CMake projects).

greyblue9 avatar Mar 21 '21 12:03 greyblue9

Why prefer LLVM 3.8 to LLVM 8? LLVM 8 is more recent, more featureful. If you set -DLibclang_INCLUDE_DIR=/usr/lib/llvm-3.8/include explicitly, it's weird though, it should be the one that get picked up, disabling auto-detection.

Sarcasm avatar Mar 21 '21 17:03 Sarcasm

Why prefer LLVM 3.8 to LLVM 8?

Only because I mistakenly thought that was the recommended version and didn't want two LLVM's taking up space. :) It's working now though, thank you!

greyblue9 avatar Apr 12 '21 17:04 greyblue9