[cfe-dev] How to use AST Matchers without using ninja?
Meador Inge
meadori at gmail.com
Thu Jul 9 15:58:18 PDT 2015
On Thu, Jul 9, 2015 at 3:15 PM, Eli Bendersky <eliben at google.com> wrote:
> On Thu, Jul 9, 2015 at 12:57 PM, Douglas Katzman <dougk at google.com> wrote:
>>
>> Add more libraries. One thing you can do is build 'clang-tidy' and use
>> what it uses, minus the ones with 'tidy' in the name.
>> These worked for me:
>>
>> g++ -o try try.o -L lib \
>> -lclangTooling \
>> -lclangStaticAnalyzerFrontend -lclangFrontend -lclangDriver \
>> -lclangParse -lLLVMMCParser -lclangSerialization -lclangSema \
>> -lclangEdit -lLLVMBitReader -lLLVMOption -lclangStaticAnalyzerCheckers \
>> -lclangStaticAnalyzerCore -lclangAnalysis -lclangAST -lclangASTMatchers
>> \
>> -lclangToolingCore \
>> -lclangRewrite -lclangLex -lclangBasic -lLLVMCore -lLLVMMC -lLLVMSupport
>> \
>> -lpthread -ldl -lz -ltermcap
>>
>> You may also want to have a look at
>> http://eli.thegreenplace.net/2012/06/08/basic-source-to-source-transformation-with-clang
>> though it seems a bit out-of-date. That makefile doesn't work exactly as-is.
>
>
> The up-to-date source is https://github.com/eliben/llvm-clang-samples -- the
> Makefile in this repo works (repo is kept in sync with LLVM head every week
> or two, and there are branches for LLVM releases). It has both LLVM and
> Clang-linking samples for out-of-tree builds.
I hit exactly this problem last week and raised it on IRC. Knowing which LLVM
libraries to use is a bit easier b/c of `llvm-config`. For the Clang
libraries you
just have to manually sort it out. On IRC I raised the idea of maybe having a
`clang-config`, but there was some objection to that b/c it was seen to be a one
off solution to a problem that pkg-config solves (i.e. write proper
pkg-config config
files for LLVM and Clang).
I am familiar with using pkg-config in Unix & Linux land, but I have no idea
how that translates to Windows. As such, I wasn't completely convinced
that a pkg-config solution would be a good fit for all our main platforms.
In any case, I do think that knowing which libraries to link against is a
significant barrier for people developing out-of-tree tools for the first
time and something better is needed here. Given `llvm-config`, extending
that or developing `clang-config` seems reasonable to me, but there maybe
be major downsides that I am not aware of.
-- Meador
More information about the cfe-dev
mailing list