Re: [PATCH 2/3] perf: Allow strong and weak functions in LIB_OBJS

From: Ian Munsie
Date: Sun Nov 28 2010 - 19:53:25 EST


Hi Arnaldo,

Excerpts from Arnaldo Carvalho de Melo's message of Sat Nov 27 08:18:36 +1100 2010:
> After I applied this patch I got this on a x86_64 Fedora 14 box:
>
> LINK /home/acme/git/build/perf/perf
> /usr/lib64/libpthread_nonshared.a(pthread_atfork.oS): In function `pthread_atfork':
> (.text+0x0): multiple definition of `__pthread_atfork'
> /usr/lib64/libpthread_nonshared.a(pthread_atfork.oS):(.text+0x0): first defined here
> /usr/lib64/libpthread_nonshared.a(pthread_atfork.oS): In function `pthread_atfork':
> (.text+0x0): multiple definition of `pthread_atfork'
> /usr/lib64/libpthread_nonshared.a(pthread_atfork.oS):(.text+0x0): first defined here
> /usr/lib64/libpthread_nonshared.a(pthread_atfork.oS): In function `pthread_atfork':
> (.text+0x0): multiple definition of `__pthread_atfork'
> /usr/lib64/libpthread_nonshared.a(pthread_atfork.oS):(.text+0x0): first defined here
> /usr/lib64/libpthread_nonshared.a(pthread_atfork.oS): In function `pthread_atfork':
> (.text+0x0): multiple definition of `pthread_atfork'
> /usr/lib64/libpthread_nonshared.a(pthread_atfork.oS):(.text+0x0): first defined here
> /usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../lib64/libiberty.a(choose-temp.o): In function `choose_temp_base':
> (.text+0x57): warning: the use of `mktemp' is dangerous, better use `mkstemp'
> /usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../lib64/libiberty.a(strerror.o): In function `errno_max':
> (.text+0x151): warning: `sys_nerr' is deprecated; use `strerror' or `strerror_r' instead
> /usr/lib/gcc/x86_64-redhat-linux/4.5.1/../../../../lib64/libiberty.a(xstrdup.o): In function `xstrdup':
> (.text+0x0): multiple definition of `xstrdup'
> /home/acme/git/build/perf/libperf.a(wrapper.o):/media/tbs/acme/git/linux/tools/perf/util/wrapper.c:15: first defined here
> collect2: ld returned 1 exit status
> make: *** [/home/acme/git/build/perf/perf] Error 1
> make: Leaving directory `/media/tbs/acme/git/linux/tools/perf'
> [acme@felicio linux]$
>
> - Arnaldo

I'm not seeing any of those warnings or errors on either of the systems
I have been testing on (x86_64 + PPC64), but it looks like the linker is
trying to pull in too much from the system libraries.

Can you test the below patch to see if the messages go away - it only
applies the whole-archive flag to libperf.a, whereas before I was also
applying it to pthread, libelf, etc.

Cheers,
-Ian