简体   繁体   English

在小牛队中没有llvm opt命令

[英]No llvm opt command in Mavericks

I installed Xcode 5.0.1 on Macosx 10.9 Mavericks and the command line tools (I can use gcc/clang on the command line for instance) but the command opt seems to have disappeared. 我在Macosx 10.9 Mavericks上安装了Xcode 5.0.1和命令行工具(例如我可以在命令行上使用gcc / clang),但命令opt似乎已经消失了。 Was it replaced by something else ? 它被其他东西取代了吗?

Apple never shipped 'base' LLVM tools with its within XCode command line tools, only clang. Apple从来没有在XCode命令行工具中发布“基础”LLVM工具,只有clang。 You need to compile the desired revision / release of LLVM by yourself. 您需要自己编译所需的LLVM修订版本。 You can download the pre-built binaries at http://llvm.org/releases/download.html as well. 您也可以在http://llvm.org/releases/download.html下载预构建的二进制文件。

My strategy (on Mavericks) was to do brew install llvm then symlink: 我的策略(在小牛队)是做brew install llvm然后symlink:

sudo ln -s /usr/local/Cellar/llvm/3.4/bin/opt /usr/bin/opt
sudo ln -s /usr/local/Cellar/llvm/3.4/bin/llc /usr/bin/llc

I got this to work on High Sierra by installing it via Homebrew. 我通过Homebrew安装它,让它在High Sierra上工作。

brew install llvm

Once you're done with that, Homebrew will tell you something like this: 一旦你完成了,Homebrew会告诉你这样的事情:

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

This formula 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 this software first in your PATH run:
  echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile

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


If you need Python to find bindings for this keg-only formula, run:
  echo /usr/local/opt/llvm/lib/python2.7/site-packages >> /usr/local/lib/python2.7/site-packages/llvm.pth

Go ahead and run: 继续运行:

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

to stick that into your .bashrc / .bash_profile . 将其粘贴到.bashrc / .bash_profile

I'll add a solution for El Capitan and Sierra since now it shows the error 我将为El Capitan和Sierra添加一个解决方案,因为它现在显示错误

ln: /usr/bin/opt: Operation not permitted

It's really simple, just go to ~/.bash_source (or the rc file of whatever shell you have) and write alias opt='/usr/local/Cellar/llvm/<llvm_version>/bin/opt' 这很简单,只需转到~/.bash_source (或你所拥有的任何shell的rc文件)并写alias opt='/usr/local/Cellar/llvm/<llvm_version>/bin/opt'

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

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