I'm using Rice to write a C++ extension for a Ruby gem. The extension is in the form of a shared object (.so) file.
This requires 'mkmf-rice' instead of 'mkmf', but the two (AFAIK) are pretty similar.
By default, the compiler uses the flags -g -O2
. Personally, I find this kind of silly, since it's hard to debug with any optimization enabled. I've resorted to editing the Makefile to take out the flags I don't like (e.g., removing -fPIC -shared
when I need to debug using main()
instead of Ruby's hooks).
But I figure there's got to be a better way. I know I can just do
$CPPFLAGS += " -DRICE"
to add additional flags. But how do I remove things without editing the Makefile directly?
A secondary question: what optimizations are safe for shared objects loaded by Ruby? Can I do things like -funroll-loops
? What do you all recommend?
It's a scientific computing project, so the faster the better. Memory is not much of an issue.
Many thanks!