3

I need to write a GCC extension, I am trying to use the GCC Plugins API that is fournished with GCC, but it is poorly documented, and very difficult to use, I can't find any example using the last version of it ...

I read that there are many other ways to create a gcc extension such as GCC Melt, and GCC python plugins, can anyone tell me the benefits/drawbacks of each of them, is there any major difference between the 3 ways of creating plugins ?

artless noise
  • 21,212
  • 6
  • 68
  • 105
Othman Benchekroun
  • 1,998
  • 2
  • 17
  • 36

2 Answers2

4

I have written plugins using both the C++ API and using the Python plugin. I haven't tried MELT, so I can't speak to that.

My preferred approach is to use Python. It is just a lot simpler to get a plugin up and running this way -- no compilation to worry about, the API is well-documented and simple, and, finally, the plugin is very easy to build from scratch (just make).

There are two main drawbacks to using the Python plugin.

The drawback I hit most regularly is that it does not expose all of the useful parts of GCC. This has not been a major problem, though, and in the past I've found it simple to just add the needed functionality to the Python plugin.

The other possible drawback is that a Python plugin may be slower than one written in C++. This has never been an issue for me.

Tom Tromey
  • 21,507
  • 2
  • 45
  • 63
3

According to @Basile, it is easier to develop a plugin using Melt. The benefits are:

1) it can be used to explore the internal representations of the GCC compiler when it is working on your files

2) it uses existing GCC plugin hooks to work on GCC internal middle-end representations

and many more...

linuxqwerty
  • 198
  • 16