Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to install LLVM for Mac?

How do I install LLVM on macOS Sierra? I've tried brew install llvm but when trying to use an llvm command like lli I get a command not found error.

like image 317
user12345 Avatar asked Mar 11 '17 01:03

user12345


People also ask

Does Mac Have LLVM?

All of Apple's operating systems, iOS, macOS, tvOS and watchOS, are built with LLVM technologies.

Where is LLVM installed Mac?

Your LLVM will be installed in /usr/local/opt/llvm .


3 Answers

homebrew does not link llvm to /usr/local/bin because it may conflict with the system one, causing all kinds of nasty bugs. Instead, you should use the full path to invoke them, such as /usr/local/opt/llvm/bin/lli.

In fact there's a Caveat that's now listed which spells this out...

==> Caveats
==> llvm

To use the bundled libc++ please add the following LDFLAGS:
LDFLAGS="-L/usr/local/opt/llvm/lib -Wl,-rpath,/usr/local/opt/llvm/lib"

llvm is keg-only, which means it was not symlinked into /usr/local, because macOS already provides this software and installing another version in parallel can cause all kinds of trouble.

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

For compilers to find llvm you may need to set:
export LDFLAGS="-L/usr/local/opt/llvm/lib"
export CPPFLAGS="-I/usr/local/opt/llvm/include"

like image 88
Siyuan Ren Avatar answered Sep 21 '22 00:09

Siyuan Ren


You can also add /usr/local/opt/llvm/bin/ to your $PATH environment variable:

echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile

This way you can call other llvm commands such as llvm-config. A list of llvm can be found here.

like image 45
maiquynhtruong Avatar answered Sep 19 '22 00:09

maiquynhtruong


Remember to source .bash_profile! I wasted a lot of time due to the silly problem.

like image 26
hhhiddleston Avatar answered Sep 18 '22 00:09

hhhiddleston