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

Search for llvm-config on OSX using brew #3247

Closed
wants to merge 1 commit into from
Closed

Search for llvm-config on OSX using brew #3247

wants to merge 1 commit into from

Conversation

joelparkerhenderson
Copy link

On Mac OSX, this command fails: ruby-install rbx.

The reason is that the OSX LLVM does not show up as expected.

Many OSX developers install an additional LLVM by using the brew package manager: brew install llvm.

The brew manager does not replace the existing system LLVM because that would cause problems with other OSX software, for example XCode. Any approach that uses brew link is potentially dangerous on OSX.

Therefore, this patch adds a search for llvm-config: if the system is Darwin, and the system says that brew is installed, and brew says the formula for LLVM is installed, then the code searches for the llvm-config file.

I expect this code will solve the ruby-install rbx issue for the majority of OSX brew users.

If this code is accepted, then subsequent improvements could add logging, advice, and corner cases such as multiple brew LLVM installations.

@jc00ke
Copy link
Member

jc00ke commented Dec 19, 2014

I think your indentation is off. Are you short-circuiting the elsif @darwin by accident?

@joelparkerhenderson
Copy link
Author

@jc00ke Yes, thanks, fixed.

elsif @darwin
if `command -v brew`.chomp != ""
if `brew list --versions llvm`.chomp != ""
config = `brew list llvm | grep '/llvm-config$'`.chomp
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joelparkerhenderson In theory, config may still equal "" (if brew list llvm doesn't output anything that matches the regex). So why not remove the two ifs above, call this regardless, and then handle the ""? Or better yet, check $?.success? instead.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good, I'll do your suggestions.

@Roman2K
Copy link

Roman2K commented Dec 19, 2014

@joelparkerhenderson You should also squash the initial commit + the indentation fix into a single commit so as to not to pollute the Git history.

@yorickpeterse
Copy link
Contributor

Personally I oppose adding a patch like this as it's a slippery slope down a path where we'll end up with dozens of specific version/command checks, scripts to check for package managers, etc, etc. What happens if somebody is using Macports/Fink/ which in turn has its own ways of naming things? Do we also add checks for all that? What if this then varies between package manager and/or OS versions? I feel this sort of logic really belongs in Ruby version managers, not in Rubinius itself.

Users can already specify an alternative llvm-config using the option --llvm-config. This isn't ideal but it spares us from the above. I believe ruby-install supports this in the form of ruby-install rbx -- --llvm-config=llvm-config-something.

@yorickpeterse
Copy link
Contributor

As an extra note: configure is already a mess in my opinion, we shouldn't further complicate it unless absolutely necessary.

@jc00ke
Copy link
Member

jc00ke commented Dec 20, 2014

I'm also not a fan. I think the detection should happen in ruby-install not in ./configure.

ps: @yorickpeterse I've been wanting to refactor ./configure for a while. Hopefully soon.

@yorickpeterse
Copy link
Contributor

@jc00ke Most likely part of that will happen when we move the VM into Titanius, or earlier if @brixen gets frustrated enough. I looked into it in the past but I don't dare to venture into the depths of configure more than I need to.

On Mac OSX, this command fails: `ruby-install rbx`.

The reason is that the OSX LLVM does not show up as expected.

Many OSX developers install an additional LLVM by using the `brew` package manager: `brew install llvm`.

The `brew` manager does not replace the existing system LLVM because that would cause problems with other OSX software, for example XCode. Any approach that uses `brew link` is potentially dangerous on OSX.

Therefore, this patch adds a search for llvm-config: if the system is Darwin, and the system says that `brew` is installed, and `brew` says the formula for LLVM is installed, then the code searches for the `llvm-config` file.

I expect this code will solve the `ruby-install rbx` issue for the majority of OSX brew users.

If this code is accepted, then subsequent improvements could add logging, advice, and corner cases such as multiple brew LLVM installations.
end
else
@log.write "not found"
end
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@joelparkerhenderson lol, you did the polar opposite of what I suggested, I meant:

elsif @darwin
  out = `brew list llvm | grep '/llvm-config$'`  # regardless of whether `brew` or the llvm formula are present
  config = out.chomp if $?.success?
else
  # ...

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ha! Your way is definitely terser - I like it. When I read more of the configure code I saw a bunch of logging that shows whether pieces are found or not, so I then tried to use the existing code's approach. Seems potentially useful. Any implementation is fine with me - I just want it to work for my team.

@postmodern
Copy link
Contributor

@jc00ke adding OS specific workarounds to ruby-install are expressly forbidden. I don't want Rubinius to become dependent on ruby-install. We can workaround this homebrew issue via configure or pressure homebrew to fix how they symlink llvm-config. Luckily, Rubinius choose to use Ruby for it's ./configure instead of autoconf (wince), making it much more manageable.

@joelparkerhenderson
Copy link
Author

we'll end up with dozens of specific version/command checks

Yes. The existing configure code has these.

IMHO it's a cost/benefit tradeoff. Complexity can be borne once in code, or borne by every person who hits the issue and then has to figure out how to solve it.

Users can already specify an alternative llvm-config using the option --llvm-config.

The troubleshooting cost is high and is O(N) whereas the patch cost is low and O(1).

@brixen
Copy link
Member

brixen commented Dec 20, 2014

Generally, an application doesn't take care of installing dependencies. Indeed, we don't install any other dependencies. At the same time, I'm forced to vendor zlib to be able to run psych on Heroku to install gems. So, sometimes we have to make exceptions. Since LLVM is so important, we probably need to make an exception.

I'd prefer a patch that identifies the platform, discovers the package manager, and checks for the package. This will be fairly easy to extend in the future. Right now, ruby-install does a pretty nice job of that. We can probably crib some code.

There's no point in refactoring configure unless someone wants to write it in shell. I'm removing the Ruby dependency to build so that we can make it easier to package Rubinius.

The best way to avoid all these problems is to get Rubinius into the major package systems. The easiest way for anyone to test out Rubinius will be to install the package. They can easily uninstall if they don't like it. Given a typical package system (even on brew), Rubinius would conflict with MRI but that temporary conflict is resolved by uninstalling. We (collectively) have been pushing the Ruby switchers so much, but the typical user is not going to be using multiple Rubies. If anyone wants to help move Rubinius adoption ahead significantly, help us package it for the major distros.

@brixen brixen closed this in a360a9e Jan 7, 2015
@brixen
Copy link
Member

brixen commented Jan 7, 2015

@joelparkerhenderson thanks for working on the patch. I applied @Roman2K's because it was simple and provides an easy way to extend the conditional for other platforms if needed.

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

Successfully merging this pull request may close these issues.

None yet

6 participants