changes to pick up correct ruby version#2
changes to pick up correct ruby version#2krgn wants to merge 6 commits intob4winckler:masterfrom krgn:master
Conversation
|
There is another problem with the original patch. I sent the following to the original author (Michael Shapiro) but he never got back to me. Can you fix it? At the top of the patch you set RUBY_PATH regardless whether |
|
Hm true, thats no good. I added a check now whether system ruby is used (either by specifying --with-ruby-command=/usr/bin/ruby explicitly or for the case when no other version of ruby is installed) which leads it to link against the system framework. Could you double check this though? I did test it and I think it does the trick but its good to see if it works right away for you. cheers, |
|
I don't think this works. Around line 6381 there is a test to see if RUBY_PATH is empty, but it is always set at the beginning of the first patch. I haven't got the time to check this carefully right now, so could you please look into it? The way this used to work (before this patch) was that RUBY_CMD was only set if you passed a flag to configure. Maybe something similar should be done with RUBY_PATH, i.e. only set it if --with_ruby_command is used? |
|
What I thought is the easiest for now is to just switch around the check so that RUBY_PATH is checked first for system ruby (RUBY_PATH == /usr/bin), then goes on to using whatever else was specified. I agree this is not as clean as it could be, but like my predecessor I'm no expert at autoconf. But anyways, there it is I think: ./configure --enable-rubyinterp --with-ruby-command=/usr/bin/ruby during linking: gcc -L. -L/usr/local/lib -o Vim objects/buffer.o objects/blowfish.o objects/charset.o objects/diff.o objects/digraph.o objects/edit.o objects/eval.o objects/ex_cmds.o objects/ex_cmds2.o objects/ex_docmd.o objects/ex_eval.o objects/ex_getln.o objects/fileio.o objects/fold.o objects/getchar.o objects/hardcopy.o objects/hashtab.o objects/if_cscope.o objects/if_xcmdsrv.o objects/main.o objects/mark.o objects/memfile.o objects/memline.o objects/menu.o objects/message.o objects/misc1.o objects/misc2.o objects/move.o objects/mbyte.o objects/normal.o objects/ops.o objects/option.o objects/os_unix.o objects/pathdef.o objects/popupmnu.o objects/quickfix.o objects/regexp.o objects/screen.o objects/search.o objects/sha256.o objects/spell.o objects/syntax.o objects/tag.o objects/term.o objects/ui.o objects/undo.o objects/window.o objects/gui.o objects/gui_beval.o objects/pty.o objects/gui_macvim.o objects/MMBackend.o objects/MacVim.o objects/if_ruby.o objects/os_macosx.o objects/os_mac_conv.o objects/netbeans.o objects/version.o -framework Cocoa -framework Carbon -lm -lncurses -liconv -framework Cocoa -framework Ruby I tried the app afterwards and it behaved like I expected (didn't work, because CommandT C extensions will crash it if built with a different ruby version, and, fwiw, it would display 1.8.7 as ruby-version). I think this covers all the cases, but let me know if not! |
|
Hmmm...ok, perhaps this does make it work, but I think it is messy. What happens if Apple decides to move the default ruby binary? If you are able, please try to make a patch like I suggested previously. Otherwise I'll have to take a look myself (I'm not big on autotools myself which is why I was hoping I didn't have to do this). |
|
I think I found the problem in the original configure file. The reason why it doens't in the end pick up the ruby thats in the path is because of this test: returns -lruby.1.9.1 where configure is trying to find a file of the name '-lruby.1.9.1' in the header dir of the ruby installation which never exists, which is why it then switches to checking for the framework: which is always true in the case of OSX dev setups resulting in it linking against this regardless. The fix is obvious. This test: should be changed to do what I think its meant to do as far as I understand, check for the presence of the libs (btw, should it check for static libraries *.a or the .dylib ones?). But the problem with what it will link to remains, as even in the case of the system ruby its possible to link using -lruby thus not producing a UB, right? So somehow we have to add a check for a flag or value (I'd propose 'system' value or similar) that will make it use the framework, specifically, or check whether returns -lruby so that whenever the system ruby is used it will always build with -framework. You decide, I fix it :) |
|
I think I'm following you but in case my answer makes little sense, feel free to explain it to me. As for .dylib or .a, I'd say go for .dylib (everything else does). As for whether to use
|
|
hey, I have checked in a working version of the configure file. It sticks to case 1. you made, i.e. only picks up custom ruby when specifically asked for. Both cases built and worked fine. I do still need to modify the configure.in to reflect the changes though! |
|
hey, do you want to double check this, I've fixed the autoconf script so it'll generate configure properly. one thing I found was that in the configure script in your git repo a particular part is missing which was not commented out in configure.in, the part that checks whether --enable-ruby=dynamic was set and enables this path through the code. for now I have commented out that part in configure.in so it doesn't find its way into configure when being re-generated under the assumption that its intentionally missing. greetings |
|
I have to take a closer look, but I don't think you should hard code paths like Another thing that I just remember is that in Phew. Anyway, I have to look at your patch later. |
|
OK, its no problem to remove it and set it to 'ruby' only with the side effect that if one's ruby in $PATH != /usr/bin/ruby the program will be built with ruby headers different from the libs it will be linked against with -framework, and this is default behavior. The cross-platform argument is really a problem though, I just didn't think this would become a problem since its for macvim :) Any advice welcome! and link.sh: Linked OK Both suggest that its doing the right thing. Hmm... let me know if you have an idea! |
|
The I'm not sure if I'm misunderstanding your comment about I don't have any more comments at this point in time. Note that I still don't fully understand the issues you are trying to overcome here. Maybe explaining the situation on the vim_dev Google Group and asking for help there may work (don't hold your breath though). |
|
The problem is relatively simple: for example, the location of the headers is set using inbuilt ruby config mechanisms. It gets the location of the header files like this: So, when you get the case that the user doesn't specify a particular ruby command explicitly with the --with-ruby-command flag the script would default to just 'ruby', i.e. whatever is in your $PATH, but -- and this is the main problem with this approach -- use the hardcoded -framework switch for linking. The danger is obvious: if you do in fact have a custom ruby installed through ports or homebrew but don't actually know that you have to explicitly specify the ruby command with --with-ruby-command in order to link correctly it will result in using headers obtained like above, but link to the wrong libs. |
|
Thanks for the explanation. Can you make it work the way you suggest and make it so that Actually, can you just make a minimal patch that does things your way and cut the |
|
ok cool, will do. btw: do you actually just take the autoconf scripts the way they ship from upstream or tweak them yourself? I'm asking because there is stuff in src/configure.in that is enabled which is not in src/configure (which suggests that src/configure was edited directly instead of generated using autoconf). |
|
I pull from core Vim, but there are changes in MacVim to configure.in. The configure script itself is sometimes regenerated in upstream and I don't regenerate it myself every time. Maybe that explains the discrepancy? You can always write your patch against the configure.in script that is in upstream. That will make it easier to get it accepted in the upstream source as well. |
|
hi, I've made a patch agains upstream vim. would you like to send it to the dev (i'm not on that one)? you can find it here: |
|
It would be great if you forked b4winckler/vim.git (this is MacVim's upstream) and created a branch with your patch on it. Then I'll take a look at it and afterwards we can send it on to vim_dev. How does that sound? |
|
ok thats cool, see pull request |
|
A quick question: will the following patch (to MacVim's configure.in) work or not? (I don't have a custom Ruby installed to test with.) |
|
no, because libruby arg is a string like this -lruby.1.9.1 to tell the linker to link against this lib (though my understanding of this process is somewhat superficial), so the the test is checking for a file in $rubylibdir with that name, which does not exist. So in order to build it, you need to set RUBY_LIBS="-L$rubylibdir $librubyarg" whcih expands to "-L/path/to/lib/libruby.a -lruby1.9.1" or somethign like that. |
|
I can't comment on the coding/elegance of this solution but I was having problems compiling MacVim against Ruby-1.9.2p136 (under RVM). This branch/patch got me up and running no problem. Many thanks krgn. |
|
I submitted this patch to vim_dev for inclusion in the Vim mainline but I never received a reply. Instead of waiting for this patch to be included in mainline I decided to include it in MacVim for now. Thanks for the patch. |
|
thank you, both, for submitting and eventually including it! |
…t vim managing part is yet broken
hi, as per the discussion here http://vim.1045645.n5.nabble.com/MacVim-Ruby-1-9-1-td1220105.html I re-created the changes made to src/configure and src/configure.in to make it pick up the right ruby version. I was then able to do ./configure --enable-rubyinterp --with-ruby=
which rubyand link against 1.9.2 installed with rvm. thanks to the author of the initial patch!