Closed GoogleCodeExporter closed 9 years ago
} In 1.1, linking both statically worked great
Well, it "worked" in that it didn't give any errors, but if I understand right,
the
profiler didn't actually get linked in. (See
http://groups.google.com/group/google-perftools/browse_thread/thread/1ff9b500430
90d9d/21e43120107d6494?lnk=gst&q=static#21e43120107d6494)
This is probably why you didn't get any multiple-defined-symbols errors.
I'll ask the linker experts around here if there's any way to resolve this.
Original comment by csilv...@gmail.com
on 12 May 2009 at 4:09
What was the reason for switching to 'ld -r' instead of just 'ar' to put the
.o's
together in 1.2? Is there a way to add a ./configure option, perhaps, to link
differently?
Original comment by mrab...@gmail.com
on 12 May 2009 at 11:44
The reason to move from ar to 'ld -r' is for the reason I had mentioned
earlier: with
ar, the resulting .a files would ignore HEAP_CHECK and HEAPPROFILE and
CPUPROFILE.
With 'ld -r', it respects those. So I think the 'ld -r' solution is a strict
improvement. That said, if you don't need it for you needs, feel free to edit
the
Makefile to go back to 'ar'. In fact, all you should need to do is to comment
out
the actions for libtcmalloc.o and libprofiler.o, so they're no-ops.
I believe there is a way to keep 'ld -r' but resolve the problem you're having
with
linking in both .a's -- though this is more a matter of faith than anything,
since I
haven't found it yet. :-) But I still expect to have that for the next release.
Original comment by csilv...@gmail.com
on 13 May 2009 at 1:17
OK, I have the following proposed fix:
In the Makefile, look for the lines like this:
cp -f "$@" .libs/libprofiler.a
cp -f "$@" .libs/libtcmalloc.a
replace those lines with this:
objcopy --weaken "$@" .libs/libprofiler.a
objcopy --weaken "$@" .libs/libtcmalloc.a
You'll have to do a 'make clean' and 'make' to rebuild after that (actually,
doing
'rm lib*.o && make' should work fine).
Let me know how that works for you. I plan on using this solution (with a lot
of
configure-time checking to go along with it!) for the next release.
Original comment by csilv...@gmail.com
on 13 May 2009 at 3:38
I ended up fixing this a different way: I now (as of perftools 1.3) have a
library:
libtcmalloc_and_profiler.a, that you can use to link both in statically. The
stuff
with objcopy just turned out to be too fragile and difficult to use properly.
Original comment by csilv...@gmail.com
on 10 Jun 2009 at 2:01
Original issue reported on code.google.com by
mrab...@gmail.com
on 12 May 2009 at 3:47