gperftools / gperftools/gperftools
Undefined symbol errors when compiling for cygwin/x64
Open
@alk is already working on this.
Since Aug 23, 2015.
Priority-Medium
Status-New
Type-Defect
- Dominant language
- C++
- Stars
- 9k
- Forks
- 1.5k
- PR merge metrics
- No merged PRs in 30d
Description
Originally reported on Google Code with ID 643
What steps will reproduce the problem?
1. Download & extract sources
2. ./configure --enable-frame-pointers LIBS=-lpthread
3. make
I would expect it to compile when following the instructions in INSTALL. The latter
says to specify --disable-shared because cygwin doesn't support weak symbols... which
I think is not actually true any more (and weak symbols don't work properly with static
linking). The --enable-frame-pointer is needed to avoid errors about missing libunwind.
The LIBS=lpthread allows test cases to compile (otherwise they also fail because pthread
functions are missing). I also had to change casting in maybe_threads.cc to avoid errors
and warnings about differing size of int and pthread_key_t (which is a pointer on cygwin).
The root of the issue seems to lurk in the black magic invoked by maybe_threads.cc
Using gperftools-2.1.1, 64-bit cygwin on Windows 7, gcc-4.8.3
Relevant makefile output:
/bin/sh ./libtool --tag=CXX --mode=link g++ -DNO_TCMALLOC_SAMPLES -DNDEBUG -Wall
-Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -fno-builtin-malloc -fno-builtin-free
-fno-builtin-realloc -fno-builtin-calloc -fno-builtin-cfree -fno-builtin-memalign -fno-builtin-posix_memalign
-fno-builtin-valloc -fno-builtin-pvalloc -Wno-unused-result -fno-omit-frame-pointer
-g -O2 -version-info 5:2:1 -no-undefined -o libtcmalloc_minimal.la -rpath /home/Ryan/apps/gperftools-2.1/lib
libtcmalloc_minimal_la-tcmalloc.lo libtcmalloc_minimal_internal.la
libtool: link: rm -fr .libs/libtcmalloc_minimal.dll.a
libtool: link: g++ -shared -nostdlib /usr/lib/gcc/x86_64-pc-cygwin/4.8.3/crtbegin.o
.libs/libtcmalloc_minimal_la-tcmalloc.o -Wl,--whole-archive ./.libs/libtcmalloc_minimal_internal.a
-Wl,--no-whole-archive -L/usr/lib/gcc/x86_64-pc-cygwin/4.8.3 -L/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../../../lib
-L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-pc-cygwin/4.8.3/../../.. -lstdc++
-lgcc_s -lgcc -lcygwin -ladvapi32 -lshell32 -luser32 -lkernel32 -lgcc_s -lgcc /usr/lib/gcc/x86_64-pc-cygwin/4.8.3/crtend.o
-O2 -o .libs/cygtcmalloc_minimal-4.dll -Wl,--enable-auto-image-base -Xlinker --out-implib
-Xlinker .libs/libtcmalloc_minimal.dll.a
./.libs/libtcmalloc_minimal_internal.a(libtcmalloc_minimal_internal_la-maybe_threads.o):
In function `perftools_pthread_key_create(__pthread_key_t**, void (*)(void*))':
/scratch/gperftools-2.1/src/maybe_threads.cc:83:(.text+0x7): relocation truncated to
fit: R_X86_64_PC32 against undefined symbol `pthread_key_create'
./.libs/libtcmalloc_minimal_internal.a(libtcmalloc_minimal_internal_la-maybe_threads.o):
In function `perftools_pthread_getspecific(__pthread_key_t*)':
/scratch/gperftools-2.1/src/maybe_threads.cc:93:(.text+0x37): relocation truncated
to fit: R_X86_64_PC32 against undefined symbol `pthread_getspecific'
./.libs/libtcmalloc_minimal_internal.a(libtcmalloc_minimal_internal_la-maybe_threads.o):
In function `perftools_pthread_setspecific(__pthread_key_t*, void*)':
/scratch/gperftools-2.1/src/maybe_threads.cc:101:(.text+0x67): relocation truncated
to fit: R_X86_64_PC32 against undefined symbol `pthread_setspecific'
./.libs/libtcmalloc_minimal_internal.a(libtcmalloc_minimal_internal_la-maybe_threads.o):
In function `perftools_pthread_once(pthread_once_t*, void (*)())':
/scratch/gperftools-2.1/src/maybe_threads.cc:131:(.text+0xa3): relocation truncated
to fit: R_X86_64_PC32 against undefined symbol `pthread_once'
collect2: error: ld returned 1 exit status
Makefile:3247: recipe for target 'libtcmalloc_minimal.la' failed
make: *** [libtcmalloc_minimal.la] Error 1
Reported by scovich on 2014-08-18 15:36:57
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.