5

I want to use clang's LibTooling on Mac OS X Yosemite. Clang's docs only shows how to build clang and llvm, but what I need is LibTooling, not whole clang (xcode has already provided clang and llvm). How to build LibTooling without building another clang?

wing
  • 141
  • 1
  • 5

2 Answers2

3

Building a tool with clang LibTooling, it is not hard.

First, you should git clone <llvm-project> into somewhere local.

Second, using one of the building tools, e.g., CMake, ninja, make, etc, to generate clang configuration files.

Then, write down your own code in clang/tools/ or clang-tools-extra/ and modify relating cMakeLists.txt to let the building tool know how to build your own tool.

For more specific information, you can refer to How To Setup Clang Tooling For LLVM.

I hope this answer will be helpful.

Da Li
  • 53
  • 6
  • 1
    I had a heck of a time getting a project going out of the llvm source tree. Is there a guide on this now officially on their site? I was hacking away and so did not document my steps along the way unfortunately. – Justin Nov 27 '19 at 23:39
0

libTooling basically gives you an access to all of the Clang's internals. This means that there is no such separate thing as Clang libTooling (only an internal library inside of Clang). This being said, building libTooling is equal to building another Clang.

Valeriy Savchenko
  • 1,524
  • 8
  • 19