jasonroelofs/rbgccxml

CastXML

Closed this issue · 11 comments

arohr commented

Question: Is rbgccxml supposed to work with the GCC-XML replacement CastXML?

My platform Ubuntu 16.04 comes with CastXML and GCC-XML does not support GCC > 4.9.

I've been out of this area of things for quite a while so I was unaware that CastXML even existed. At first glance it will probably work with using the --castxml-gccxml flag. I'll need to take a closer look at the new CastXML output to see how/if it would fit in this library.

arohr commented

I theory CastXML should be compatible with GCC-XML (I believe), but in my case my ruby extension does not build anymore on Ubuntu 16.04 (worked on 14.04). rbgccxml seems to fail using CastXML (the binary /usr/bin/gccxml internally uses /usr/bin/castxml with the --castxml-gccxml flag). The "old" gccxml is still around: /usr/bin/gccxml.real but not is compatible with GCC 5.

I've thrown together changes that use CastXML here #17. Please give it a shot and let me know if you run into anything.

arohr commented

Thank you for your effort! Here my late feedback.

At the moment I see two problems:

  1. Using more than one source file leads the input for castxml renders to i file with C++ include statements of these files. But castxml does not seem to understand this (maybe gccxml did).
  ext.sources [
                '../src/server/server.h',
                '../src/client/client.h'
              ]

leads to castxml input:

#include "../src/server/server.h"
#include "../src/client/client.h"

If only one source files is used, the castxml input is directly this header file, which is OK with castxml. Otherwise the castxml output is an empty file which ultimatively leads to NoMethodError: undefined method 'namespaces' for nil:NilClass because NodeCache.root in SAXParser#parse returns nil (probably because nothing was parsed).

  1. Using just one header source file, castxml (or clang?) complains about error: invalid argument '-std=gnu++98' not allowed with 'C/ObjC'. I don't know how I can avoid this error.
arohr commented

I found out problem 2 can be solved by adding :cxxflags => ['-x c++'], so castxml known we want to parse C++.

arohr commented

Hm, this also seems to solve problem 1. Both header sources seem to be processed by castxml now.

Ah, good catch. Yeah CastXML made it a bit more difficult to figure out if it was trying to parse C or C++. Wonder if that should be a built-in option or if it's something to document?

arohr commented

Now I was able to build my ruby extension. I had to add another flag. Now it looks like this:

              :cxxflags => [
                '-x c++',       # required for castxml
                '-fpermissive'  # required to avoid "error: ‘<::’ cannot begin a template-argument list [-fpermissive]"
              ],

So your PR is fine for me. Thank you very much!

Since RbPlusPlus is about C++ code, I think -x c++ should be built in. With -fpermissive I'm not shure.

Cool, thanks for the confirmation, and I probably should do something with Rb++ in this context then as well. Glad we could get things working for you!

Thanks for your help on all of this! I've released rbgccxml 1.1 and rbplusplus 1.4 to support CastXML. Please give them a try and let me know if it's all working for you.

arohr commented

Yes, it's working with rbgccxml 1.1 and rbplusplus 1.4.
Thank you so much!