clang parser: can libclang be loaded dynamically?

René J.V. Bertin rjvbertin at
Mon Apr 11 09:30:53 UTC 2016


This came up in a discussion on a MacPorts forum, concerning packaging dependencies on a clang/llvm version.

If I understood an earlier exchange about libclang correctly, it is the only dependency on the LLVM toolchain, and that library provides an API that hasn't changed since clang 3.5 (or hardly so).
If so, that suggests it might be possible to build the clang-based parser against one version, and load (dlopen) a the library dynamically (using a configurable location), more or less like how audacity uses the ffmpeg libraries.
I haven't looked at how much work this would represent, I'd first like to know if it's indeed theoretically possible, and not "just theoretically" (i.e. it's feasible or even relatively trivial).

The advantage for packagers would of course be that a KDevelop package doesn't need a hard dependency on a given clang+llvm version, or ship its own libclang. On OS X it might even allow to use the libclang included with Xcode, which cannot be used otherwise (the toolchain misses items required to build against it) and which will probably give better performance as Apple's clang has always out-performed local builds.


More information about the KDevelop-devel mailing list