Saturday, May 31, 2014

Recompile a debian package (valgrind) from testing to stable (wheezy)

Valgrind 3.7 as supplied Debian does not support the avx2 instructions the gcc 4.7 from debian supports if one uses gcc -march=native -mtune=native on a more-or-less recent processor.
01af@debian:~/bench1$ valgrind ./bench1
==26780== Memcheck, a memory error detector
==26780== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==26780== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==26780== Command: ./bench1
==26780== 
vex amd64->IR: unhandled instruction bytes: 0xC5 0xF9 0xEF 0xC0 0x66 0xF 0x1F 0x44
==26780== valgrind: Unrecognised instruction at address 0x40156e.
==26780==    at 0x40156E: main (memblock.cc:120)
==26780== Your program just tried to execute an instruction that Valgrind
==26780== did not recognise.  There are two possible reasons for this.
==26780== 1. Your program has a bug and erroneously jumped to a non-code
==26780==    location.  If you are running Memcheck and you just saw a
==26780==    warning about a bad jump, it's probably your program's fault.
==26780== 2. The instruction is legitimate but Valgrind doesn't handle it,
==26780==    i.e. it's Valgrind's fault.  If you think this is the case or
==26780==    you are not sure, please let us know and we'll try to fix it.
==26780== Either way, Valgrind will now raise a SIGILL signal which will
==26780== probably kill your program.
==26780== 
==26780== Process terminating with default action of signal 4 (SIGILL)
==26780==  Illegal opcode at address 0x40156E
==26780==    at 0x40156E: main (memblock.cc:120)
Since current valgrind 4.9 does support these instructions, I asked myself how to I upgrade this peculiar package.
Using an instructions how to rebuild a debian package, one needs to install the build tools
apt-get install build-essential fakeroot dpkg-dev
Since valgrind is supported by debian testing one can get source from https://packages.debian.org/source/jessie/valgrind. i.e.
git clone git://anonscm.debian.org/collab-maint/valgrind.git
Start build dpkg-buildpackage -rfakeroot -b. And add the missing dependencies to the systems. Start again until all dependencies are fulfilled
Afterwards the freshly packages are in ... Use
dpkg -i valgrind_3.9.0-5_amd64.deb valgrind-dbg_3.9.0-5_amd64.deb
to upgrade the package. And it works now as expected.



No comments:

Post a Comment