[GCC-XML] gccxml newbie, some questions

Brad King brad.king at kitware.com
Thu Aug 26 07:28:33 EDT 2004


Wolfgang Draxinger wrote:
> When I compiled GCCXML I saw, that there is a lot of code in the patched 
> GCC from which I think, that it is not needed for GCCXML, e.g. the whole 
> stuff that is generating the binary code. Wouldn't it be possible, to 
> strip such code away? All code files that are not touched at all when 
> compiling the C++ preprocessor could be safely striped away, along with 
> all not needed header files.

The original GCC source tree is much larger than that included with 
GCC-XML.  Some effort was made to reduce the size of the source, but 
there was not enough time to really dig into the source to separate it. 
  You'd be surprised how interconnected the parsing and code generation 
seem to be in GCC.  Just build it with profiling enabled, run an xml 
dump, and look how many of the source files are touched.  The problem is 
that parsing C++ actually requires some knowledge of the back end that 
will generate code because things like sizeof(some_type) can be used in 
instantiating a template.

> Also I wonder, if it would be possible to make a library from GCCXML that 
> instead of producing XML Output is providing some intermediate interface, 
> that then another programm uses to generate the XML output. I ask this, 
> because this would make it possible for other 3rd party programms, that 
> need to parse C++ to include this library w/o having to parse the 
> generated XML because the output of the parser library would be 
> sufficient. XML parsing is simple, but not parsing at all is yet simpler.

Yes, it would be possible to make it a library, but with a catch.  The 
GCC parser is distributed under the GPL.  If you link to it in a library 
form then your program must also be distributed under the GPL.  This is 
why GCC-XML is implemented as two executables.  The "gccxml_cc1plus" 
executable has all the GPL-ed code.  The "gccxml" front-end driver 
program has all our own code and is not bound by the GPL.  This 
front-end executable never sees the parse tree, though.  It just 
configures gccxml_cc1plus to work with a particular compiler and then 
runs it.

-Brad



More information about the gccxml mailing list