简体   繁体   English

M1 Mac如何安装llvm

[英]M1 Mac how to install llvm

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我已尽一切可能安装 eo-learn 但它无法使用 Conda 无法正常工作 我最接近的方法是使用 pip 但我在尝试安装 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有人可以告诉我如何让安装程序识别它

I was able to install llvmlite on my m1 with the following steps:我可以通过以下步骤在我的 m1 上安装 llvmlite:

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).指定 llvm 的 11 版(或检查更高的 llvm 版本是否仍与您的 llvmlite 兼容)。
  • make sure you're installing both with the same arch arm64 .确保您使用相同的 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.确保您的 LLVM_CONFIG 值对于您的系统是正确的(在我的情况下它在**/11.1.0_4/下),您可能有一个更新的版本,甚至是完全不同的 PATH。

Check out this link.看看这个链接。 https://embeddedartistry.com/blog/2017/02/24/installing-llvm-clang-on-osx/ https://embeddedartistry.com/blog/2017/02/24/installing-llvm-clang-on-osx/

Adding Homebrew llvm/clang to path worked for me.将 Homebrew llvm/clang 添加到路径对我有用。

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

The clang+llvm-14.0.5-x86_64-apple-darwin.tar.xz build in github can work on M1 github 中的 clang+llvm-14.0.5-x86_64-apple- darwin.tar.xz构建可以在 M1 上运行

I was experiencing the pain of clangd not handling M1 threads well: https://github.com/clangd/clangd/issues/1119我正在经历clangd不能很好地处理M1线程的痛苦: 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.该问题已在 llvm 15 中得到修复,该版本作为 rc1 发布,但 Brew 目前并未安装该版本。 Installing via brew install --HEAD llvm has never worked for me because the build fails and I'm not sure how to address this.通过brew install --HEAD llvm对我来说从来没有用过,因为构建失败,我不知道如何解决这个问题。

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:如果它对其他人有帮助,我可以通过在 github 发布文件夹中找到的clang+llvm-15.0.0-rc1-arm64-apple-darwin21.0.tar.xz发布工件轻松安装 llvm 15:

https://github.com/llvm/llvm-project/releases/tag/llvmorg-15.0.0-rc1 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.请注意,如果您使用的是 M1 Mac,则需要使用arm64版本,而不是 x86_64 版本。 The latter would be useful for people with older Intel Macs.后者对使用较旧英特尔 Mac 的人很有用。

LLVM Release Artifact Install Steps LLVM 发布工件安装步骤

Here are the steps I used to install LLVM via their release artifacts on an M1 Mac:以下是我在 M1 Mac 上通过其发布工件安装 LLVM 的步骤:

  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.xzllvmorg-15.0.0-rc1发布页面下载 arm64 发布工件并将其解压到主目录中的某个路径: 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.更新您的PATH变量以指向生成的clang+llvm-15.0.0-rc1-arm64-apple-darwin21.0/bin目录。
  3. Verify that clangd works by running clangd --version .通过运行clangd --version验证clangd是否工作。 You should see output verifyin 15.0.0 .您应该在15.0.0中看到 output 验证。 For me, running clangd initially failed due to the binary not being able to find a libzstd shared object.对我来说,由于二进制文件无法找到libzstd共享的 object,运行clangd最初失败。 brew install zstd installed the dependency. brew install zstd安装了依赖项。 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):一旦解决了所有依赖项并更新了您的PATH ,您应该会看到这一点(再次验证版本以确保您选择的是预期的clangd ,而不是系统、Brew 或系统上的其他版本):

$  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 .现在clangclangd等应该通过你的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:我的coc-nvim插件需要这个更新的clangd ,为此我通过我的coc-settings.json文件明确指向clangd的 clangd:

$ 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"
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM