Build gperftools correctly

Review 1210 by @mlucy
Merge branch 'next' into sam_alt