Also find clang include path based on runtime libclang library path

Authored by mwolff on Apr 14 2019, 9:03 AM.

Description

Also find clang include path based on runtime libclang library path

My KDevelop was compiled against my system libclang v7.0.1, thus
KDEV_CLANG_BUILTIN_DIR points to /usr/lib/clang/7.0.1/include. Now
I compiled clang 8 from sources and put it in a different folder
in my home path and adapted LD_LIBRARY_PATH to make KDevelop pick it
up. This then fails to find the builtin include path, since it tries
to find /usr/lib/clang/8.0.1/include which doesn't exit.

This patch adds another fallback to fix the above scneario: We now
lookup the path of libclang at runtime through dlfcn.h's dladdr,
which we pass a libclang function address, here clang_getClangVersion.
Then on success we deduce the include path by removing the library
name and then instead appending clang/$version/include, which makes
it use /home/milian/projects/compiled/other/lib/clang/8.0.1/include
as required.

Details

Committed
mwolffApr 14 2019, 7:06 PM
Parents
R32:c88bf19be2a6: clang: add new (partially failing) test file for lambdas
Branches
Unknown
Tags
Unknown