tel8618217223380 / gperftools

Automatically exported from code.google.com/p/gperftools
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

Undefined symbol errors when compiling for cygwin/x64 #643

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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_thr
eads.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_thr
eads.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_thr
eads.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_thr
eads.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

Original issue reported on code.google.com by scov...@gmail.com on 18 Aug 2014 at 3:36

GoogleCodeExporter commented 9 years ago
If possible please attach your config.log.

Original comment by alkondratenko on 18 Aug 2014 at 3:57

GoogleCodeExporter commented 9 years ago
Oops, I had a typo in the configure above. It should be:

./configure --enable-frame-pointers LDADD='-pthread'

Two attachments. First, the local changes I made to get as far as I did. 
Second, config.log, as requested.

Let me know if you need anything else, or have something I should try. 

Original comment by scov...@gmail.com on 18 Aug 2014 at 4:43

Attachments:

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Wonder the issue was fixed? I hit the same issue with "gperftools-2.1.1, 64-bit 
cygwin on Windows 7, .gcc 4.9.2"

Original comment by huapengy...@gmail.com on 11 Mar 2015 at 10:42