【问题标题】:How to install Valgrind on macOS Catalina (10.15) with Homebrew?如何使用 Homebrew 在 macOS Catalina (10.15) 上安装 Valgrind?
【发布时间】:2020-02-10 02:14:42
【问题描述】:

我尝试使用命令“brew install valgrind”安装 Valgrind,但收到一条消息:

“valgrind:由于上游不兼容,此公式在比 Sierra 更新的 macOS 版本上无法编译或按预期运行。错误:未满足的要求使此构建失败。”

我还尝试“brew edit valgrind”并在代码的 head 部分用“git://sourceware.org/git/valgrind.git”替换“sourceware.org/git/valgrind.git”,然后写在 Iterm "brew install --HEAD valgrind" 上,但它给了我:

Last 15 lines from /Users/m/Library/Logs/Homebrew/valgrind/02.configure:
checking for gcc-ar... no
checking for perl... /usr/bin/perl
checking for gdb... /no/gdb/was/found/at/configure/time
checking dependency style of clang... none
checking for diff -u... yes
checking for clang option to accept ISO C99... none needed
checking for a supported version of gcc... ok (clang-11.0.0)
checking build system type... x86_64-pc-darwin
checking host system type... x86_64-pc-darwin
checking for a supported CPU... ok (x86_64)
checking for a 64-bit only build... yes
checking for a 32-bit only build... no
checking for a supported OS... ok (darwin)
checking for the kernel version... unsupported (19.0.0)
configure: error: Valgrind works on Darwin 10.x, 11.x, 12.x, 13.x, 14.x, 15.x, 16.x and 17.x (Mac OS X 10.6/7/8/9/10/11 and macOS 10.12/13)

READ THIS: https://docs.brew.sh/Troubleshooting

【问题讨论】:

    标签: macos homebrew valgrind macos-catalina memory-leak-detector


    【解决方案1】:

    https://github.com/LouisBrunner/valgrind-macos/

    尝试一下

    brew tap LouisBrunner/valgrind
    brew install --HEAD LouisBrunner/valgrind/valgrind
    

    或者从源码编译,如果上面的方法不行的话。 (不过他们最近应该有fixed上面的方法。)

    git clone https://github.com/LouisBrunner/valgrind-macos.git
    cd valgrind-macos
    ./autogen.sh
    ./configure --prefix=/where/you/want/it/installed --enable-only64bit
    make 
    sudo make install
    

    享受吧!

    【讨论】:

    • 今天来自github的版本似乎有一些改进。我根据此处的说明构建了它,并进行了一些更改:1. 不需要第 5 步。 2. 在第 3、4 和 6 步不需要 sudo。到目前为止,它似乎在 Catalina 10.15.4 上运行良好.
    • 此版本在每个程序上都返回泄漏:==54507== definitely lost: 11,928 bytes in 127 blocks
    • 现在不行了得到libmpiwrap.c:736:39: error: expected expression if (ty == MPI_LB || ty == MPI_UB)
    • 感谢您为此付出了一些努力。非常感谢。
    • Catalina 10.15.6,这个版本总是报内存泄漏。
    【解决方案2】:

    https://github.com/sowson/valgrind

    brew install --HEAD https://raw.githubusercontent.com/sowson/valgrind/master/valgrind.rb
    

    MacOS Catalina (10.15.4),我可以确认操作了。

    【讨论】:

    • 安装成功但每个程序都会导致非法硬件指令
    • 刚刚尝试过,但在 MacOS Catalina (10.15.5) 上失败了。普通程序在启动时中止。
    • 在 github 链接上打开一个 issue 并访问是个好主意。我刚刚构建并测试了它。