Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Thanks, and a bit of feedback. #106

Closed
dkorolev opened this issue Jan 23, 2018 · 7 comments
Closed

Thanks, and a bit of feedback. #106

dkorolev opened this issue Jan 23, 2018 · 7 comments

Comments

@dkorolev
Copy link

Hi @jasonroelofs,

Thanks for Rice! I've spent a few days befriending it with C++11, and wrote a bit of feedback, as well as open-sourced an example that passes a Semaphore test.

A follow-up to my Ruby + Rice troubles: I made it work on virgin Ubuntu EC2 boxes, as well as on Semaphore.

The test project of the complexity of "1 + 1 = 2" is open sourced, via the link below.

Problems I still see that, I believe, are to be fixed by the Rice team (I will work around them, as fixing would require deep knowledge):

1) Doesn't work on OS X out of the box for C++11 code.
2) Generally, the `create_makefile` function is too rigid.
3) Compilation warnings on Ubuntu.
4) The `using namespace Rice` construct is just ugly.
5) For obvious reasons, YouCompleteMe doesn't work, and even highlights part of the source file in red.

Re. (2), I believe operations such as the following ...

a) Change g++ into clang++.
b) Add compilation flags such -std=c++11.
c) Remove compilation flags such as "-g".

... should be easy to perform from within the Makefile-generating Ruby code.

My today's solution to work around them is `sed -i` on the resulting `Makefile`. Would appreciate a hint if there's a better one.

CC @jaymzh -- cleaning up and open-sourcing my demo snippet is the most I could have done in the past two days.

Thanks,
Dima

CC @AlexZaytsav, @idej

@jasonroelofs
Copy link
Collaborator

Thanks for the feedback!

1) Doesn't work on OS X out of the box for C++11 code.

Can you provide more details? Rice has had support for C++11 and later for quite a while, and while I've seen one other report that there may be problems here I haven't been able to get a reproducible example.

2) Generally, the create_makefile function is too rigid.

What are you finding difficult to do?

3) Compilation warnings on Ubuntu.

I can understand this concern. As it stands, Rice is effectively in maintenance mode and I am not a daily user of the library. I'm happy to review suggestions or a PR for removing / reducing some of these warnings.

4) The using namespace Rice construct is just ugly.

I'm not sure what to say here, as this is a personal preference thing. This construct is not required for Rice to function.

5) For obvious reasons, YouCompleteMe doesn't work, and even highlights part of the source file in red.

This isn't obvious to me. Rice is a complicated code base that makes very heavy use of templates which could be tripping up auto-complete and highlighting tools. Do you have an example to share here?

a) Change g++ into clang++.

Rice does not force you into any specific compiler, but will try to use the compiler that Ruby was compiled with. You can set $CC and/or $CXX explicitly before you call create_makefile to force a specific compiler.

b) Add compilation flags such -std=c++11.

This can be done by setting $CXXFLAGS, but I'm open to discussion on if this should be applied globally.

c) Remove compilation flags such as "-g".

This is added only if the compiler is g++ but this is a good suggestion as there is no way to not set / unset it otherwise.

@dkorolev
Copy link
Author

dkorolev commented Jan 25, 2018

Hi Jason,

Thanks a log for circling back! My personal e-mail is dmitry.korolev@gmail.com in case anything you'd like to follow up with is best to be kept private.

  1. Doesn't work on OS X out of the box for C++11 code.
    Can you provide more details?

The TL;DR is that the -std=c++11 flag is missing. The sad irony is that due to the incompatibility between the behavior of sed on Linux and OS X, my sed-based script became a Ruby script in our prod just yesterday, thanks you our CTO spending a few hours with me late at night (instead of giving his girlfriend he's fond of the attention she well deserves -- I literally rewrote the .sh script into an .rb one to replace CPP and CXX lines of the Makefile Rice outputs by the ones that include -std=c++11.

  1. Generally, the create_makefile function is too rigid.
    What are you finding difficult to do?

The shortest and the most self-explanatory way to use Rice was to use ruby -e from my own, C++-native, Makefile to invoke ruby -e 'require "mkmf-rice"; create_makefile("${<:.cc=}")' from within the native/%.${SO}: %.cc make target (where ${SO} stands for so or bundle for Linux and OS X respectively).

If only create_makefile was capable of accepting more parameters, such as "don't add -g", or " please add -std=c++11 to the gcc/g++-invoking Makefile lines", I'd happily use them, and not look back.

Moreover, had I spoke Ruby at least a quarter as well as I speak C++, or at least half as well as I speak JS or Python, I would have extended the implementation of the create_makefile method (function?) to be more fune-tunable to the degree that the changes I actually had to make would obviously have been Rice changes instead of sed/ruby-powered [post-factum] Makefile changes within my own project.

Design-wise, it all boils down to me not knowing how to pass "variable-typed" parameters in Ruby. In Python those are named parameter, in C++ the convention I stick with is the so-called "dot notation", ex. RiceMakefileGenerationParameters().DefaultCompilationFlags("-std=c++11").RemoveDebugSymbols()); (where RemoveDebugSymbols() removes -g). Within Ruby, I know neither how to best add them, nor how to best test them.


The remaining points of my comment are derivative; I'd be happy to go into more details, but that would be pointless given Rice is effectively in maintenance mode.

It's not my first day in open source, and I understand, acknowledge, and comprehend well how busy you are with your main project(s). No matter what the result of this exchange would be, thanks for getting back to me, Rice still rocks compared to the alternatives I've considered, we'll most likely use it in prod next week, for which here come my warmest thanks and thumbs up.

With the above in mind, if there's anything I, as a non-Ruby-speaker, could help with, that would enable me (us, CC @AlexZaytsav, @idej) to get rid of the ugly sed (well, actually, .rb with two .gsub()-s) in favor of a new version of Rice, please do let me know how could I best help.

Thanks!
Dima

PS: Please excuse me for the possible typos, it's 1am and we just had a corp party. I swear that, should you have the desire to invest a few dozen minutes into straightening out the above, I'll be available in your time zone for as long as it's necessary to get the right things fixed the right way.

@tyrfig
Copy link

tyrfig commented Jul 14, 2018

"This can be done by setting $CXXFLAGS" ...

Do you mean manually editing the Makefile or setting the environment to running rake compile ?

@dkorolev
Copy link
Author

dkorolev commented Jul 15, 2018

Manually editing the resulting Makefile.

Semi-manually, in fact -- I have a script now that does it. A middle step, if you wish, between Rice generating the Makefile and make invoking it.

@tyrfig
Copy link

tyrfig commented Jul 15, 2018

Thanks!

@jasonroelofs
Copy link
Collaborator

It should also work to set CXXFLAGS as an environment variable.

@ankane
Copy link
Contributor

ankane commented Oct 28, 2019

Can confirm $CXXFLAGS works the same way as with Ruby's mkmf.

$CXXFLAGS << " -std=c++11"

Example

@cfis cfis closed this as completed Apr 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants