How to install valgrind on macOS Big Sur?

Viewed 6999

I have recently purchased an M1 MacBook Pro and I am having issues installing valgrind on macOS Big Sur. What I have tried so far is:

  • brew install valgrind which pops the error (brew is updated)

Error: invalid attribute for formula 'valgrind': version (nil)

  • edited head as indicated here
  • download manually from GitHub following all indications listed but I get
Last 15 lines from /Users/homeuser/Library/Logs/Homebrew/valgrind/03.make:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/i386/thread_status.h:254:9: error: unknown type name '_STRUCT_X86_DEBUG_STATE64'
typedef _STRUCT_X86_DEBUG_STATE64 x86_debug_state64_t;
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/i386/thread_status.h:260:9: error: unknown type name '_STRUCT_X86_PAGEIN_STATE'
typedef _STRUCT_X86_PAGEIN_STATE x86_pagein_state_t;
        ^
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/mach/i386/thread_status.h:266:9: error: unknown type name '_STRUCT_X86_INSTRUCTION_STATE'
typedef _STRUCT_X86_INSTRUCTION_STATE x86_instruction_state_t;
        ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make[2]: *** [fixup_macho_loadcmds] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2
  • looked into this older fix that used to work

Unfortunately none of the methods work so I would really appreciate a solve to this problem as I need to use valgrind on a daily basis for university homework.

1 Answers

Definitive answer. See the configure.ac autoconf file for the exact details. Starting from line 5021 [which may change in future versions, obviously] there is a switch on the kernel versions.

The last version of macOS officially supported by Valgrind was 10.13 on Intel. Neither macOS 11/12 (any architecture) nor ARM are supported.

Getting Valgrind to work on macOS 11/12 ARM hardware would require

  • filling in all of the gaps from 10.13 to 11/12
  • ARM assembly code for low level functions like syscalls

There is Linux ARM support, so the second point might not be so difficult. I don't have an ARM based mac, so I'm not vounteering for the moment.

Related