With recent GCC , gcc (actually cc1 , which is run by gcc ) and g++ (actually cc1plus ), etc. for other GCC compilers, for example gfortran or even gdc ....- they share a lot of (source) code: the middle end (where most optimizations happen) and the internal one. The difference lies only in the interface level of the compiler (the only level being the source language), which is less than 30% of the compiler.
You can configure the GCC compiler using plugins or MELT . Your extensions will work with GCC internals (Gimple-s) and will work when compiling C, C ++, Ada, Fortran, etc. Remember that GCC stands for Gnu Compiler Collection today
In fact, gcc can compile C ++ source code (and also g++ can compile C or Fortran code). However, they do not link the same libraries.
Pass the -v flag to the gcc or g++ command to understand that they work.
Here are two (mine) [CC-BY-SA] images - outputting GCC and MELT - illustrating this.
Three layers - front-end, middle-end, back-end compiler:
with your plugin or MELT meta plugin

in simplification: cc1 or cc1plus generate assembler files, which are then translated using as , starting with gcc or g++
and
another kind of internal elements cc1 or cc1plus ,
which generates some assembler code

source share