通过 Homebrew 安装 ccls 会输出与 libffi 和 llvm 相关的警告消息

Installing ccls through Homebrew outputs caveats messages related to libffi and llvm

我正在尝试设置我的 neovim C++ 开发环境,并想使用 ccls 作为我的 coc 语言服务器。

当我使用 Homebrew 安装 ccls 时,它会安装 libffillvm 作为依赖项。 好像 ccls 安装成功了,但是好像我需要配置 PATH 变量,LDFLAGSCPPFLAGS.

但是我不知道libffillvm是干什么用的,他们提示的LDFLAGSCPPFLAGS不一样,很迷惑。

可以不导出任何变量来使用ccls吗?或者,我应该在 ~/.zshrc 中导出哪个版本?

下面是 brew install ccls 的控制台输出。

❯ brew install ccls
==> Downloading https://homebrew.bintray.com/bottles/libffi-3.3.big_sur.bottle.tar.gz
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/llvm-11.0.0_1.big_sur.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/c8e30903a9a4f695780e1eeeaa2cf4d5a95141a1cac98ab1bbc811817cde39ca?response-content-disposition=attachment%3Bfilename%3D
######################################################################## 100.0%
==> Downloading https://homebrew.bintray.com/bottles/ccls-0.20201219.big_sur.bottle.tar.gz
==> Downloading from https://d29vzk4ow07wi7.cloudfront.net/934fb8fd594d6e7adbfa14b5608f1de14309db34f2cf61a0cb572bdc772b2aa3?response-content-disposition=attachment%3Bfilename%3D
######################################################################## 100.0%
==> Installing dependencies for ccls: libffi and llvm
==> Installing ccls dependency: libffi
==> Pouring libffi-3.3.big_sur.bottle.tar.gz
==> Caveats
libffi 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.

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

==> Summary
  /usr/local/Cellar/libffi/3.3: 17 files, 540.2KB
==> Installing ccls dependency: llvm
==> Pouring llvm-11.0.0_1.big_sur.bottle.tar.gz
==> Caveats
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"' >> ~/.zshrc

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"

==> Summary
  /usr/local/Cellar/llvm/11.0.0_1: 8,922 files, 1.4GB
==> Installing ccls
==> Pouring ccls-0.20201219.big_sur.bottle.tar.gz
  /usr/local/Cellar/ccls/0.20201219: 5 files, 1.5MB
==> Caveats
==> libffi
libffi 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.

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

==> 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"' >> ~/.zshrc

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"

libffi 只是一个图书馆。 llvm 是一个 编译器基础结构 。 而libc++LLVM项目的C++标准库。您可以使用 LLVM 库或 GNU (libstdc++) 库。这取决于您的软件项目(或您的个人喜好)您使用什么库。

由于 macOS 确实已经提供了 llvm 安装,您可以 可选 切换到 brew 作为依赖安装的安装 –这不是必需的。

LDFLAGS 环境变量确实包含编译器(gcc/g++clang/clang++)传递给链接器的附加标志,即添加链接器可以找到的路径然后,如果 required/used,库对象文件将链接到您的二进制文件。

CPPFLAGS做同样的事情,但这次标志直接针对编译器,即为库的头文件添加一个额外的搜索路径。

在您的情况下,您不必从 .zshrc 中导出任何(额外的)变量,ccls 无需定义这些变量即可正常工作。