#800614 valgrind: compile with -fPIC for shared libraries

Package:
valgrind
Source:
valgrind
Description:
instrumentation framework for building dynamic analysis tools
Submitter:
Drew Parsons
Date:
2015-10-01 17:33:06 UTC
Severity:
normal
#800614#5
Date:
2015-10-01 17:28:36 UTC
From:
To:
I'm rebuilding PETSc (petsc-dev 3.6.1). During build configuration, it says
that building petsc with valgrind support is HIGHLY recommended, and
they provide simple configuration flags to do so.

petsc with valgrind support switched on compiles successfully but fails on
linking, with the error:

  /usr/bin/ld: /usr/lib/valgrind/libcoregrind-amd64-linux.a(libcoregrind_amd64_linux_a-m_main.o): relocation R_X86_64_32S against `vgPlain_interim_stack' can not be used when making a shared object; recompile with -fPIC
  /usr/lib/valgrind/libcoregrind-amd64-linux.a: error adding symbols: Bad value
  collect2: error: ld returned 1 exit status

The petsc configuration adds the -fPIC flag, so I think the error
indicates that valgrind has not been build with -fPIC.  petsc has an
option to switch off -fPIC, but it refuses to apply that to a shared
library build.

There's some technical reading at http://people.redhat.com/drepper/dsohowto.pdf
which says -fPIC should always be used with shared libraries.

Ought valgrind therefore be built using the -fPIC flag?

Cheers,
Drew