2

I would like to build a clang source to source translator plugin for cuda language.Unfortunately i am not able to build the clang plugin itself.I have tried the method suggested by google to copy and paste the PrintFunctionNames and build the same and the other one suggested by http://getoffmylawnentertainment.com/blog/2011/10/01/clang-plugin-development-tutorial/ website did not work for me. While building with google method I get:

../../../../Makefile.common:61: ../../../../Makefile.config: No such file or directory ../../../../Makefile.common:69: /Makefile.rules: No such file or directory make: * No rule to make target `/Makefile.rules'. Stop. This did not work for me How to build clang/examples/PrintFunctionNames? I am getting this error when built using cmake:

teddy@ubuntu:~/dev-lib/example/build$ make printer/CMakeFiles/PrintFunctionNames.dir/flags.make:6: * commands commence before first target. Stop. make[1]: * [printer/CMakeFiles/PrintFunctionNames.dir/all] Error 2 make: *** [all] Error 2

I am using ubuntu 10.10 and cmake 2.8.1 to build the clang plugin. Clang Version:3.1 please help me to build the clang plugin... Thank you

Community
  • 1
  • 1
Tanmay J Shetty
  • 197
  • 2
  • 3
  • 9

3 Answers3

2

Building programs that link with Clang can be tricky, especially if you want to do it "out of source" - i.e. in your own source tree, not as part of Clang's.

I'm maintaining a Github repo called llvm-clang-samples that provides samples of linking with LLVM and Clang, and has an example Clang plugin. This repository tries to keep up to date with top-of-tree LLVM & Clang and has branches for earlier released versions.

Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
0

this error is coming because you have plainly copied the contents of CMakeLists.txt. Particularly the LLVM_LIBS and the CLANG_LIBS part. What you have to do is simply put backslashed after every line like this

set( CLANG_LIBS \
libclang    \
clangFrontend  \
..  \
...
)

Or you can bring all the library names to one single line, whichever suits you. hope this helps

A. K.
  • 34,395
  • 15
  • 52
  • 89
-1

First steps are always hard. Created a toy repo on github, which does pin down the build system issues for a clang plugin. Checkout the 'empty' tag.

arrowd
  • 33,231
  • 8
  • 79
  • 110