make fails while installing Valgrind
Asked Answered
E

4

23

I'm trying to install Valgrind on a Mac with Snow Leopard but am getting an error. This is what I'm typing into Terminal.

$ curl -O http://valgrind.org/downloads/valgrind-3.8.1.tar.bz2
$ md5sum valgrind-3.8.1.tar.bz2
$ tar -xjvf valgrind-3.8.1.tar.bz2
$ cd valgrind-3.8.1
$ ./configure
$ make

This is the error I get.

Making all in coregrind
make[2]: *** No rule to make target `/usr/include/mach/mach_vm.defs', needed by `m_mach/mach_vmUser.c'.  Stop.
make[1]: *** [all-recursive] Error 1
make: *** [all] Error 2

How can I correct this error?

Eulalia answered 16/11, 2012 at 17:39 Comment(6)
Do you have Xcode installed?Resentment
I do not have Xcode as it is particularly difficult to get for Snow Leopard.Eulalia
See my answer below. I believe it will solve your issue.Perfuse
The final state of this problem is explained in a comment under @Volte's answer.Eulalia
@N0un Volte's answer would not have solved the problem I had.Eulalia
I understand, and it's impossible to reproduce but it solves mine and the accepted one is not enough.Shackleford
P
86

Make sure to install the command line tools.

xcode-select --install
Perfuse answered 27/5, 2015 at 1:28 Comment(5)
Correct, this is the recommended fix from the Valgrind developers. The alternatives above are brittle and not guaranteed to work with future Xcode releases.Festival
This worked perfectly for me. This should be the accepted answer.Footcloth
The computer I was using at the time of this question has already gone through the chipper but, even if it was around, I doubt that this answer would have worked given the nature of my specific issue. Due to a business decision that Apple admitted was misguided, a specific version of Snow Leopard could not get Xcode without paying the full developer fee. The pay wall was removed in the next version, but was never taken off that one version; the version I had. My solution was to dual boot Ubuntu and continue my project.Eulalia
I am using using Mavericks and XCode 6. After I ran the xcode-select --install, it was still asking for the defs file mentioned above as the makefile is looking for them in the directory /usr/include. one can softlink by doing ln -s /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOS10.9.sdk/usr/include include so the makefile can find the relevant files.Nombril
This didn't work for me, but this did: https://mcmap.net/q/196518/-make-fails-while-installing-valgrindWhitewing
S
5

The best way to get valgrind compiled properly is to use the 'xcode-select --install' command as mentioned in the above answer. However, as sub-optimal hack, you can get it compiled by downloading the following files from OSX /mach source into /usr/include/mach (create this directory):

mach_vm.defs    
task.defs
thread_act.defs
vm_map.defs

It's a slightly dirty hack, but it should get you going if you really don't want to download/install the large Xcode original files.

Saturniid answered 3/1, 2016 at 12:5 Comment(0)
B
3

Apparently, to compile on a Macintosh, valgrind needs the file /usr/include/mach/mach_vm.defs to be present. While I haven't been able to find specific references to mach_vm.defs being part of XCode specifically, it seems that most of the usual contents of /usr/include/mach are installed when XCode is.

If for some reason you can't install XCode on your machine, you can get most of the source files for that particular directory from this part of apple's open source website.

Brundisium answered 16/11, 2012 at 22:53 Comment(4)
This was the problem. Unfortunately, I ran into another problem. If I can't solve it, I'll post a new question.Eulalia
Had a similar issue. This answer helped, but so did some of the comments on this page. calvinx.com/2014/05/04/valgrind-on-mac-os-x-10-9-mavericks Location of xcode install for /usr/include/mach = /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/includeBolzano
This issue arises again as in the new El Capitan OS not even sudo can create the directory '/usr/include'Partible
Scroll down and use the other answer! It is better.Eschar
H
2

Ever since the System Integrity Protection system was put in place on OSX, the user, not even as root, can modify /usr. Thus, modifying /usr/include/mach to add the necessary files becomes impossible. The only alternative is now to edit the makefile itself.

The Makefile at hand should be located at coregrind/Makefile, and the mach files should be located near /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/ (replace MacOSX10.12.sdk with the appropriate version of OSX).

There should be a symbol named am__append_17 defined around line 160 or so (might be elsewhere for different versions).

It should look something like this:

am__append_17 = \
    /usr/include/mach/mach_vm.defs \
    /usr/include/mach/task.defs \
    /usr/include/mach/thread_act.defs \
    /usr/include/mach/vm_map.defs

Replace each instance of /usr/include with /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/, so that it looks like:

am__append_17 = \
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/mach/mach_vm.defs \
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/mach/task.defs \
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/mach/thread_act.defs \
    /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk/usr/include/mach/vm_map.defs

After this, valgrind should compile properly

Hasin answered 27/5, 2018 at 3:36 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.