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

Difficulty finding the right LLVM... #380

Open
pmetzger opened this issue May 1, 2017 · 11 comments
Open

Difficulty finding the right LLVM... #380

pmetzger opened this issue May 1, 2017 · 11 comments

Comments

@pmetzger
Copy link

pmetzger commented May 1, 2017

Howdy! Building the irony server on macOS Sierra, I'm having trouble getting the thing to find my locally installed copy of LLVM. In particular, when I run this (either manually or via irony-install-server):

cmake -DCMAKE_INSTALL_PREFIX=/Users/perry/.emacs.d/irony/ /Users/perry/.emacs.d/elpa/irony-20170427.1601/server && cmake --build . --use-stderr --config Release --target install

it finds my XCode version of LLVM (which doesn't include libclang) but not my locally installed version of LLVM 4.0 which I've verified is earlier in my path.

Suggestions?

@ikirill
Copy link

ikirill commented May 1, 2017

I don't know if this helps you, but here is the command I use to use homebrew's llvm (on OSX 10.11). cmake might be ignoring some of your environment variables, or something trivial like that.

cmake -DCMAKE_CXX_COMPILER=/opt/brew/opt/llvm/bin/clang++ -DCMAKE_PREFIX_PATH=/opt/brew/opt/llvm -DCMAKE_INSTALL_RPATH=/opt/brew/opt/llvm -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE -DCMAKE_INSTALL_PREFIX=/Users/kirill/.emacs.d/irony/ /Users/kirill/.emacs.d/elpa/irony-20170427.1601/server && cmake --build . --use-stderr --config Release --target install

@pmetzger
Copy link
Author

pmetzger commented May 1, 2017

Cool. I did a direct equivalent and it worked. BUT, either the instructions on README should be updated to explain how to build manually, or possibly the automation needs to be fixed to do such things for the user. I wouldn't have figured that out on my own as I'm not familiar with CMake (though I admit I should be.)

As an aside, @ikirill, do you put your homebrew stuff in /opt/brew/opt? I didn't know that would work without trouble.

@ikirill
Copy link

ikirill commented May 1, 2017

Yes, my homebrew is in /opt/brew. /opt/brew/opt is the path under homebrew where all the packages go that collide with native OSX stuff (like clang, which would collide with the system clang). It works fine.

If I remember correctly, the only tricky part of that is "CMAKE_INSTALL_RPATH_USE_LINK_PATH", which took me some time to find.

@ikirill
Copy link

ikirill commented May 1, 2017

Yeah, I agree, it would be nice to just put the whole command in the readme, so that it can be copy-pasted (almost) directly, especially since tracking down the right cmake options can take some time when you don't remember them by heart.

@Sarcasm
Copy link
Owner

Sarcasm commented May 2, 2017

I would be glad to do automatically the right thing on macOS, if only it was 100% clear what is right.
For example, the instructions in this issue are new to me.
Right now, my conclusion with the various feedback is that there is NO One True Method.

There is a wiki page regarding macOS with various instructions:

@ikirill
Copy link

ikirill commented May 2, 2017

I think the command that would work for normal setups is this:

cmake -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++ -DCMAKE_PREFIX_PATH=/usr/local/opt/llvm -DCMAKE_INSTALL_RPATH=/usr/local/opt/llvm -DCMAKE_INSTALL_RPATH_USE_LINK_PATH=TRUE -DCMAKE_INSTALL_PREFIX=~/.emacs.d/irony/ ~/.emacs.d/elpa/irony-20170427.1601/server && cmake --build . --use-stderr --config Release --target install

Maybe it's worth including it in the readme, just as an example, so that people can substitute their own paths without thinking too much?

Also, I want to point out that the fix using install_name_tool is really quite awkward, because it's the sort of thing cmake normally handles without any trouble, so invoking anything other than cmake with the right flags is a little unreasonable.

Also, I wouldn't agree the llvm package is broken, OSX just expects linking to be done in a certain way.

@pmetzger
Copy link
Author

pmetzger commented May 3, 2017

Autoconfiguration shouldn't be too hard, because if llvm is in the path, then llvm-config is in the path, and you can ask it to tell you where to find all the LLVM bits. I would say that is the safest method, and the most reasonable. If you're not familiar, llvm-config spits out the path to all the various llvm bits that you might want to find or link against. See the manual for details.

However, barring that, as @ikirill notes, the README could point at the wiki and the wiki could give some examples, or the the README itself could give examples.

@diasbruno
Copy link

diasbruno commented May 10, 2017

Hi all, this is a small script that works for now.

gist/diasbruno/irony-mode.sh

Hope it helps.

@pmetzger
Copy link
Author

That script has hard-coded paths in it. It would be nice to use llvm-config instead to do that. llvm-config is a command that will be in the path for any LLVM user and which can be asked to print out the paths to any of LLVM's components.

@diasbruno
Copy link

diasbruno commented May 10, 2017

Yes, it's just to workaround.
I used that in 2 installations, so i thought it might be useful. :)

@diasbruno
Copy link

diasbruno commented May 10, 2017

[macos with homebrew]
When I was installing irony-mode I've used the hardcoded path because it was easier, but now trying to exec brew link llvm:

Warning: llvm is keg-only and must be linked with --force
Note that doing so can interfere with building software.

If you need to have this software first in your PATH instead consider running:
  echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile

And brew link llvm --force does move things in the right place, then you can:

LIBCLANG_LIBRARY=`llvm-config --libdir`/libclang.dylib
LIBCLANG_INCLUDE=`llvm-config --includedir`

Thanks, @pmetzger.

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

4 participants