在 OS X 上构建 valgrind

Building valgrind on OS X

我试图在 macOS Sierra(版本 10.12.6)上安装 valgrind。 运行 ./configure.sh 时出现此错误:

checking for a supported version of gcc... Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 no (applellvm-8.1.0) configure: error: please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0

所以,我检查了我的 gcc 和 clang 版本。回复如下:

Ankits-MacBook-Air:valgrind ankitshubham$ gcc --version

Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/usr/include/c++/4.2.1 Apple LLVM version 8.1.0 (clang-802.0.42) Target: x86_64-apple-darwin16.7.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Ankits-MacBook-Air:valgrind ankitshubham$ clang --version

Apple LLVM version 8.1.0 (clang-802.0.42) Target: x86_64-apple-darwin16.7.0 Thread model: posix InstalledDir: /Library/Developer/CommandLineTools/usr/bin

我不知道如何检查 icc>=13.0

这里有什么问题?

对于像这样的任何流行的跨平台包,使用 Homebrew 这样的包管理器安装通常会更容易。然后你 brew install valgrind 就完成了。

另请注意,clang 和 Apple 开发人员工具已经具有类似的有用调试工具,尤其是 clang 的地址清理器和 malloc 调试工具 - 这可以从 Xcode 的项目设置中轻松访问:

但如果需要,您也可以从命令行使用它。

您 运行 遇到的问题已在当前开发库中得到解决。

如果你确实想构建 valgrind 而不是仅仅使用包管理器,请克隆开发 repo(说明如下)。我假设您不是在寻找特定版本的 valgrind,下面的说明将在 post.

日期构建版本 3.14

我假设您刚刚下载了 release 压缩包。 如果您改为克隆 repository page 上列出的 git 存储库,它将在 Mac 10.12.6

上正常构建

来自 valgrind 存储库页面。

To clone code from the current repository (anonymous, read-only git access), do this:

git clone git://sourceware.org/git/valgrind.git To build the cloned code, follow the instructions in the README file that the clone should give you. Alternatively, the following should work:

  cd valgrind
  ./autogen.sh
  ./configure --prefix=...
  make
  make install

截至日期,上述步骤在 post 运行 MacOS 10.12.6 上运行良好,安装了以下版本的 clang。

    clang --version
Apple LLVM version 9.0.0 (clang-900.0.37)
Target: x86_64-apple-darwin16.7.0
Thread model: posix
InstalledDir: ...

按照以下步骤操作:

git clone git://sourceware.org/git/valgrind.git &&
cd valgrind &&
./autogen.sh &&
./configure &&
make &&
make install