我在 Macosx 10.9 Mavericks 上安装了 Xcode 5.0.1 和命令行工具(例如,我可以在命令行上使用 gcc/clang),但是命令 opt
似乎消失了。它被替换成其他东西了吗?
我在 Macosx 10.9 Mavericks 上安装了 Xcode 5.0.1 和命令行工具(例如,我可以在命令行上使用 gcc/clang),但是命令 opt
似乎消失了。它被替换成其他东西了吗?
苹果从未在其XCode命令行工具中包含“base”LLVM工具,只有clang。您需要自己编译所需的LLVM修订版/发行版。您也可以在http://llvm.org/releases/download.html下载预构建二进制文件。
我的策略(在Mavericks上)是执行brew install llvm
然后创建符号链接:
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
我通过使用Homebrew在High Sierra上安装它使其工作。
brew install 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"
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
请直接执行:
echo 'export PATH="/usr/local/opt/llvm/bin:$PATH"' >> ~/.bash_profile
将此内容复制到您的 .bashrc
/ .bash_profile
文件中。
~/.bash_source
(或任何您拥有的shell的rc文件)并编写alias opt='/usr/local/Cellar/llvm/<llvm_version>/bin/opt'
。