building the example plugin "PrintFunctionNames"

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

building the example plugin "PrintFunctionNames"

Kristof Beyls via cfe-dev
Hi everyone,

For a project in the university we decided to build a plugin for
Clang. For this I tried to build the example plugin
"PrintFunctionNames".

https://clang.llvm.org/docs/ClangPlugins.html
This tutorial in the website builds the plugin I mentioned which is
on: https://github.com/llvm/llvm-project/tree/master/clang/examples/PrintFunctionNames

Both the github readme and the tutorial mentions "make" to build the
plugin as a first step, but there is no makefile in the folder and I'm
confused about how to build the project.

When I run cmake for the folder it doesn't work because things like
"add_llvm_library" are not defined.

When I install Clang with CMake and make install, I again didn't see a
".so" file as mentioned in the tutorials.

We want to build and run this plugin so we can modify its working
build files to create our project. So general advice for building a
plugin can be useful too.

thanks,
Onur Kulaksizoglu
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: building the example plugin "PrintFunctionNames"

Kristof Beyls via cfe-dev
Hi Onur,

On Wed, 6 Nov 2019 at 09:32, Onur Kulaksizoglu via cfe-dev
<[hidden email]> wrote:
> Both the github readme and the tutorial mentions "make" to build the
> plugin as a first step, but there is no makefile in the folder and I'm
> confused about how to build the project.

They assume you've already run CMake, since that's what's used to
build all of LLVM & Clang.

> When I run cmake for the folder it doesn't work because things like
> "add_llvm_library" are not defined.

Similarly, they assume you've run CMake in a "normal" manner, as none
of the CMakeLists.txt files are self-contained. Eventually they're all
relative to llvm's top-level file.

> When I install Clang with CMake and make install, I again didn't see a
> ".so" file as mentioned in the tutorials.

Yes, examples don't get installed normally since they're not for
end-user consumption. However, you are very close; if you've built
Clang you should have a "PrintFunctionNames" target for make (i.e. you
can run "make PrintFunctionNames"). For me that creates
lib/PrintFunctionNames.so in the build directory.

Cheers.

Tim.
_______________________________________________
cfe-dev mailing list
[hidden email]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev