Multiple definition of vfork() when linking statically

Waldemar Brodkorb wbx at openadk.org
Fri Aug 29 13:33:19 UTC 2014


Hi Thomas,
Thomas Petazzoni wrote,

> Hello,
> 
> When doing static linking, vfork() is defined in both libc.a and
> libpthread.a, causing a build failure such as:
> 
> aserver.c:(.text.startup+0x464): warning: gethostbyname is obsolescent, use getnameinfo() instead.
> /home/test/autobuild/instance-1/output/host/usr/sh4-buildroot-linux-uclibc/sysroot/usr/lib/libc.a(vfork.os): In function `vfork':
> (.text+0x0): multiple definition of `__vfork'
> /home/test/autobuild/instance-1/output/host/usr/sh4-buildroot-linux-uclibc/sysroot/usr/lib/libpthread.a(pt-vfork.os):(.text+0x0): first defined here
> collect2: error: ld returned 1 exit status
> 
> This happens with uClibc 0.9.33.2 + the set of patches visible at
> http://git.buildroot.net/buildroot/tree/package/uclibc/0.9.33.2?id=2014.05-rc1.

21 /* libpthread used to have its own vfork implementation that differed
22    from libc's only in having a pointless micro-optimization.  There
23    is no longer any use to having a separate copy in libpthread, but
24    the historical ABI requires it.  For static linking, there is no
25    need to provide anything here--the libc version will be linked in.
26    For shared library ABI compatibility, there must be __vfork and
27    vfork symbols in libpthread.so.  */
28
29 #if (SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_20) \
30      || SHLIB_COMPAT (libpthread, GLIBC_2_1_2, GLIBC_2_20))
31
32 #include <vfork.S>
33
34 #endif
35
36 #if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_20)
37 compat_symbol (libpthread, __libc_vfork, vfork, GLIBC_2_0);
38 #endif
39
40 #if SHLIB_COMPAT (libpthread, GLIBC_2_1_2, GLIBC_2_20)
41 strong_alias (__libc_vfork, __vfork_compat)
42 compat_symbol (libpthread, __vfork_compat, __vfork, GLIBC_2_1_2);
43 #endif

Any volunteers to come up with a patch for uClibc mimic the
changes of glibc for pt-vfork.S?

best regards
 Waldemar


More information about the uClibc mailing list