M1 Mac how to install llvm
Asked Answered
S

4

9

I have done everything possible to install eo-learn but it is not working using Conda won't work closest I got to making it work was with pip but I get stuck while trying to install numba

steps taken

brew install llvm

export LLVM_CONFIG=/opt/homebrew/opt/llvm/bin/llvm-config

LLVM_CONFIG=/opt/homebrew/opt/llvm/bin/llvm-config pip install numba

LLVM_CONFIG=/opt/homebrew/opt/llvm/bin/llvm-config pip install llvmlite which is the major dependency breaking for now

brew link llvm 
Warning: Refusing to link macOS provided/shadowed software: llvm
If you need to have llvm first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc

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

I have added the flags

brew link -force llvm
Warning: Refusing to link macOS provided/shadowed software: llvm
If you need to have llvm first in your PATH, run:
  echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc

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

I have done everything I know someone please help me

can some tell me how I can get the installer to recognise it

Seymourseys answered 17/5, 2021 at 10:32 Comment(2)
I googled the first error message and found this blog posting and this SO question.Marilumarilyn
Is the end goal to use Tensorflow. Because it seems I just got that working.Beccafico
S
17

I was able to install llvmlite on my m1 with the following steps:

arch -arm64 brew install llvm@11
LLVM_CONFIG="/opt/homebrew/Cellar/llvm@11/11.1.0_4/bin/llvm-config" arch -arm64 pip install llvmlite

It's important to:

  • specify version 11 of llvm (or check if higher llvm version still compatible with your llvmlite).
  • make sure you're installing both with the same arch arm64.
  • make sure your LLVM_CONFIG value is correct for your system (in my case it's under **/11.1.0_4/) you may have a newer version or even in completly different PATH.
Stand answered 24/2, 2022 at 8:48 Comment(1)
I think one can safely remove the arch -arm64 parts, that should be the default. The reason llvm@11 (and not the latest, 14 version) is needed is because the most recent llvmlite version (0.37.0) requires it.Ayotte
J
3

Check out this link. https://embeddedartistry.com/blog/2017/02/24/installing-llvm-clang-on-osx/

Adding Homebrew llvm/clang to path worked for me.

echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile
Joshuajoshuah answered 9/9, 2021 at 22:6 Comment(0)
S
2

I was experiencing the pain of clangd not handling M1 threads well: https://github.com/clangd/clangd/issues/1119

That issue is fixed in llvm 15, which is released as an rc1, but Brew does not currently install that version. Installing via brew install --HEAD llvm has never worked for me because the build fails and I'm not sure how to address this.

In case it's helpful to others, I was able to install llvm 15 pretty easily via the clang+llvm-15.0.0-rc1-arm64-apple-darwin21.0.tar.xz release artifact found in the github release folder here:

https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.0-rc1

Note that you'll want to use the arm64 version if you have an M1 Mac, not the x86_64 version. The latter would be useful for people with older Intel Macs.

LLVM Release Artifact Install Steps

Here are the steps I used to install LLVM via their release artifacts on an M1 Mac:

  1. Download and untar the arm64 release artifact from the llvmorg-15.0.0-rc1 release page to some path in your home directory: clang+llvm-15.0.0-rc1-arm64-apple-darwin21.0.tar.xz
  2. Update your PATH variable to point to the resulting clang+llvm-15.0.0-rc1-arm64-apple-darwin21.0/bin directory.
  3. Verify that clangd works by running clangd --version. You should see output verifyin 15.0.0. For me, running clangd initially failed due to the binary not being able to find a libzstd shared object. brew install zstd installed the dependency. You may need to install other dependencies.

Once all dependencies are resolved and your PATH is updated, you should see this (again, verify the version to make sure you are picking up the expected clangd, not the system, Brew, or other version on your system):

$  clangd --version                                           
clangd version 15.0.0
Features: mac+xpc
Platform: arm64-apple-darwin21.6.0

Now clang, clangd, etc. should be used via your PATH. I needed this updated clangd for my coc-nvim plugin, for which I explicitly point to clangd for nvim via my coc-settings.json file:

$ cat ~/.config/nvim/coc-settings.json                       
{
  "clangd.arguments": ["-j=4"],
  "clangd.path": "/<some_path>/clang+llvm-15.0.0-rc1-arm64-apple-darwin21.0/bin/clangd"
}
Septuplicate answered 4/8, 2022 at 22:1 Comment(0)
B
-1

The clang+llvm-14.0.5-x86_64-apple-darwin.tar.xz build in github can work on M1

Bilicki answered 13/6, 2022 at 7:41 Comment(1)
Someone with an M1 Mac will surely want the arm64 version, not the x86_64 version.Septuplicate

© 2022 - 2024 — McMap. All rights reserved.