All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] lib order fails for xeno-config --posix-ldflags on Blackfin
@ 2009-02-05 16:10 Mike McTernan
  2009-02-06 10:19 ` Philippe Gerum
  0 siblings, 1 reply; 8+ messages in thread
From: Mike McTernan @ 2009-02-05 16:10 UTC (permalink / raw)
  To: xenomai

Hi,

Checking xeno-config.in from 2.4.1, it has the following:

XENO_POSIX_LDFLAGS="-L${staging}${libdir} -lpthread_rt -lpthread -lrt
@XENO_USER_APP_LDFLAGS@"

On Blackfin uClinux 2008R1.5 linking fails with -lpthread_rt and
-lpthread in that order:

bfin-uclinux-gcc -I/usr/xenomai/include -I/usr/xenomai/include/posix
-D_GNU_SOURCE -D_REENTRANT -D__XENO__ -o hello hello.o
-Wl,@/usr/xenomai/lib/posix.wrappers -L/usr/xenomai/lib -lpthread_rt
-lpthread -lrt
/opt/uClinux/bfin-uclinux/bfin-uclinux/runtime/usr/lib/libpthread.a(mute
x.os): In function `__pthread_once_fork_child':
libpthread/linuxthreads.old/mutex.c:357: undefined reference to
`___wrap_pthread_cond_init'
/opt/uClinux/bfin-uclinux/bfin-uclinux/runtime/usr/lib/libpthread.a(mute
x.os): In function `__pthread_once':
libpthread/linuxthreads.old/mutex.c:308: undefined reference to
`___wrap_pthread_cond_wait'
libpthread/linuxthreads.old/mutex.c:325: undefined reference to
`___wrap_pthread_cond_broadcast'
/opt/uClinux/bfin-uclinux/bfin-uclinux/runtime/usr/lib/libpthread.a(mute
x.os): In function `pthread_once_cancelhandler':
libpthread/linuxthreads.old/mutex.c:281: undefined reference to
`___wrap_pthread_cond_broadcast'
collect2: ld returned 1 exit status
make: *** [hello] Error 1

It looks like the uClinux pthread implementation makes use of its own
functions and hence needs the library containing the wrappers specified
after the pthread lib to enable resolving of references, as per the ld
manual:

"Normally, an archive is searched only once in the order that it is
specified on the command line. If a symbol in that archive is needed to
resolve an undefined symbol referred to by an object in an archive that
appears later on the command line, the linker would not be able to
resolve that reference."

I'd have thought there are potentially some circular dependencies
between the pthread and pthread_rt libs.  Would it help portability to
surround these options with -Wl,--start-group <libs> -Wl,--end-group?
i.e.

XENO_POSIX_LDFLAGS="-L${staging}${libdir} -Wl,--start-group -lpthread_rt
-lpthread -Wl,--end-group -lrt @XENO_USER_APP_LDFLAGS@"

I've done this locally and I can build the apps without re-ordering the
libraries.

Regards,

Mike


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-02-09 14:46 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-05 16:10 [Xenomai-help] lib order fails for xeno-config --posix-ldflags on Blackfin Mike McTernan
2009-02-06 10:19 ` Philippe Gerum
2009-02-06 12:48   ` Mike McTernan
2009-02-06 14:21     ` Philippe Gerum
2009-02-06 15:21       ` Mike McTernan
2009-02-06 16:13         ` Philippe Gerum
2009-02-06 18:58           ` Mike McTernan
2009-02-09 14:46             ` Philippe Gerum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.