Valgrind and macOS Big Sur

Viewed 9175

I'm having troubles installing Valgrind on the macOS Big Sur through the Homebrew. In the terminal I have tried

$ brew install valgrind

After Homebrew's autoupdate, I got the following message:

valgrind: Linux is required for this software.
Error: An unsatisfied requirement failed this build.

Is there a way I can install Valgrind?

4 Answers

Roughly your only hope is here, a work in progress.

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

I’d say Valgrind is a lost cause on macOS. Try looking into Address/Leak Sanitizer. Note that Apple Clang does not support leak checking, so you’ll have to grab llvm off Brew instead. If you use -fsanitize=address, you’ll also have to prepend ASAN_OPTIONS=detect_leaks=1 on macOS.

Valgrind is not supported by Big Sur, but you can try this

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

or a better option in Preferences | Build, Execution, Deployment | CMake -> Cmake options use

-DCMAKE_BUILD_TYPE=ASAN -DCMAKE_CXX_COMPILER=/usr/local/opt/llvm/bin/clang++

and enter image description here

You can try leaks. I don't know how it compares to valgrind in terms of features, but it's enough for me rn.

leaks -atExit -- ./path/to/binary
Related