Install Valgrind on Gentoo Linux

Valgrind is very powerful suite of software for dynamic analysis of binary programs. Valgrind is available in an ebuild on the Gentoo portage tree, but if you want to install valgrind on your Gentoo distribution, there is a problem with the build with the standard library. On Gentoo, the standard C library (glibc) is stripped and Valgrind needs the debug symbols to work. If you try to launch valgrind without the debug symbols, you will get the following error:

valgrind:  Fatal error at startup: a function redirection
valgrind:  which is mandatory for this platform-tool combination
valgrind:  cannot be set up.  Details of the redirection are:
valgrind:  
valgrind:  A must-be-redirected function
valgrind:  whose name matches the pattern:      strlen
valgrind:  in an object with soname matching:   ld-linux-x86-64.so.2
valgrind:  was not found whilst processing
valgrind:  symbols from the object with soname: ld-linux-x86-64.so.2
valgrind:  
valgrind:  Possible fixes: (1, short term): install glibc's debuginfo
valgrind:  package on this machine.  (2, longer term): ask the packagers
valgrind:  for your Linux distribution to please in future ship a non-
valgrind:  stripped ld.so (or whatever the dynamic linker .so is called)
valgrind:  that exports the above-named function using the standard
valgrind:  calling conventions for this platform.
valgrind:  
valgrind:  Cannot continue -- exiting now.  Sorry.

So first, you have to activate the debug symbols for the libraries in your /etc/make.conf:

FEATURES="splitdebug"

Then, you can emerge again the glibc:

sudo emerge glibc

If you already had emerged valgrind, there is no need to emerge it again, it should work now.

And finally, you can emerge valgrind:

sudo emerge valgrind

And everything will work fine.

Related articles

  • Switching to Gentoo Linux
  • Gentoo Tips: Avoid Gnome 3.8 from being emerged automatically
  • budgetwarrior 0.2.1 - Minor changes and Gentoo ebuild
  • Software Reliability Presentation
  • Why and how I completely left Windows for Linux
  • How to profile C++ application with Callgrind / KCacheGrind
  • Comments

    Comments powered by Disqus