Errors while static linking of Xenomai
Hi,
when I try to compile Xenomai and link it satically i get some 'undefined reference' errors while compiling the cyclictest programm from the testsuite. I'm using Xenomai 2.4.4 with uclibc and try to compile for a ppc-arch board (Freescale MPC8343 processor).
Heres the line which I use to configure Xenomai:
./configure --host=powerpc-generic-linux-uclibc CC=/opt/powerpc-linux-uclibc/bin/powerpc-generic-linux-uclibc-gcc CXX=/opt/powerpc-linux-uclibc/bin/powerpc-generic-linux-uclibc-g++ LD=/opt/powerpc-linux-uclibc/bin/powerpc-generic-linux-uclibc-ld --enable-shared=no LDFLAGS=--static
And thats the output I get when compiling cyclictest:
Making install in cyclic
make[3]: Entering directory `/home/develop/Download/xenomai-2.4.4/src/testsuite/cyclic'/opt/powerpc-linux-uclibc/bin/powerpc-generic-linux-uclibc-gcc -DHAVE_CONFIG_H -I. -I../../../src/include -I../../../include/posix -O2 -D_GNU_SOURCE -D_REENTRANT -Wall -pipe -D__XENO__ -D__IN_XENO__ -Wstrict-prototypes -DIPIPE_TRACE=1 -I../../../include -MT cyclictest-cyclictest.o -MD -MP -MF .deps/cyclictest-cyclictest.Tpo -c -o cyclictest-cyclictest.o test -f 'cyclictest.c' || echo './'cyclictest.c
mv -f .deps/cyclictest-cyclictest.Tpo .deps/cyclictest-cyclictest.Po/bin/sh ../../../libtool --tag=CC --mode=link /opt/powerpc-linux-uclibc/bin/powerpc-generic-linux-uclibc-gcc -Wl,@/home/develop/Download/xenomai-2.4.4/src/skins/posix/posix.wrappers --static -o cyclictest cyclictest-cyclictest.o ../../skins/posix/libpthread_rt.la -lpthread -lrt
mkdir .libs/opt/powerpc-linux-uclibc/bin/powerpc-generic-linux-uclibc-gcc -Wl,@/home/develop/Download/xenomai-2.4.4/src/skins/posix/posix.wrappers --static -o cyclictest cyclictest-cyclictest.o ../../skins/posix/.libs/libpthread_rt.a -lpthread -lrt /opt/powerpc-linux-uclibc/powerpc-generic-linux-uclibc/sys-root/usr/lib/libpthread.a(pthread.os):(.data.rel+0x3f4): undefined reference to __wrap_pthread_condattr_destroy' /opt/powerpc-linux-uclibc/powerpc-generic-linux-uclibc/sys-root/usr/lib/libpthread.a(pthread.os):(.data.rel+0x3f8): undefined reference to __wrap_pthread_condattr_init' /opt/powerpc-linux-uclibc/powerpc-generic-linux-uclibc/sys-root/usr/lib/libpthread.a(pthread.os):(.data.rel+0x3fc): undefined reference to __wrap_pthread_cond_broadcast' /opt/powerpc-linux-uclibc/powerpc-generic-linux-uclibc/sys-root/usr/lib/libpthread.a(pthread.os):(.data.rel+0x400): undefined reference to __wrap_pthread_cond_destroy' /opt/powerpc-linux-uclibc/powerpc-generic-linux-uclibc/sys-root/usr/lib/libpthread.a(pthread.os):(.data.rel+0x404): undefined reference to __wrap_pthread_cond_init' /opt/powerpc-linux-uclibc/powerpc-generic-linux-uclibc/sys-root/usr/lib/libpthread.a(pthread.os):(.data.rel+0x408): undefined reference to __wrap_pthread_cond_signal' /opt/powerpc-linux-uclibc/powerpc-generic-linux-uclibc/sys-root/usr/lib/libpthread.a(pthread.os):(.data.rel+0x40c): undefined reference to __wrap_pthread_cond_wait' /opt/powerpc-linux-uclibc/powerpc-generic-linux-uclibc/sys-root/usr/lib/libpthread.a(pthread.os):(.data.rel+0x464): undefined reference to __wrap_pthread_cond_timedwait' /opt/powerpc-linux-uclibc/powerpc-generic-linux-uclibc/sys-root/usr/lib/libpthread.a(mutex.os): In function `__pthread_once_fork_child':
mutex.c:(.text+0x1fc): undefined reference to `__wrap_pthread_cond_init'
/opt/powerpc-linux-uclibc/powerpc-generic-linux-uclibc/sys-root/usr/lib/libpthread.a(mutex.os): In function `pthread_once':
mutex.c:(.text+0x490): undefined reference to `__wrap_pthread_cond_wait'
mutex.c:(.text+0x534): undefined reference to `__wrap_pthread_cond_broadcast'
/opt/powerpc-linux-uclibc/powerpc-generic-linux-uclibc/sys-root/usr/lib/libpthread.a(mutex.os): In function `pthread_once_cancelhandler':
mutex.c:(.text+0x58c): undefined reference to `__wrap_pthread_cond_broadcast'
collect2: ld returned 1 exit status
make[3]: *** [cyclictest] Fehler 1
Any hints and/or help to solve this problem is appreciated.
Thanks in advance.
regards,
Christian
Quoted 8 lines · Christian Volk
Hi,
when I try to compile Xenomai and link it satically i get some 'undefined reference' errors while compiling the cyclictest programm from the testsuite. I'm using Xenomai 2.4.4 with uclibc and try to compile for a ppc-arch board (Freescale MPC8343 processor).
Heres the line which I use to configure Xenomai:
./configure --host=powerpc-generic-linux-uclibc CC=/opt/powerpc-linux-uclibc/bin/powerpc-generic-linux-uclibc-gcc CXX=/opt/powerpc-linux-uclibc/bin/powerpc-generic-linux-uclibc-g++ LD=/opt/powerpc-linux-uclibc/bin/powerpc-generic-linux-uclibc-ld --enable-shared=no LDFLAGS=--static
Fully static builds will likely not work with the current Makefiles, I'm afraid. To achieve that, one would have to follow a two-stage linking approach, partial linking with the application and wrappers first, then final linking of the previous object with the standard libs - like libpthread - without wrapping. This has already be done for certain applications and is known to work.
Due to static linking, what happens here is that the linker sees therefore binds pthread_* calls issued from the standard pthread library to Xenomai symbols... which are wrappers shadowing the standard pthread_* calls... Bad idea. The point is that the -Wl,<wrappers> directive should not appear on the link command line for static builds when standard glibc/libpthread are listed here as well.
This said, those errors compiling the Xenomai stack should only happen with POSIX apps from the testsuite because the Makefiles there do not account for fully static builds and wrapping woes, but you can safely ignore them, provided you do two-stage linking for your own apps. This is one of the rare cases where make -k may help...
Signature · 1 line
Philippe.
During the day we found a "workaround" or maybe a fix.
I will post details tomorrow from work.
We used -Wl,"-(" archives -Wl,"-)" so we built a start-group - end-group Construct which fixed all issues.
Thanks for your answer Philippe, this will help me while creating my own apps.
Christian
-----Ursprüngliche Nachricht-----
Von: Philippe Gerum [mailto:[email protected]
Gesendet: Mittwoch, 23. Juli 2008 19:16
An: Christian Volk
Cc: [email protected]
Betreff: Re: [Xenomai-help] Errors while static linking of Xenomai
Quoted 3 lines · Christian Volk
Hi,
when I try to compile Xenomai and link it satically i get some 'undefined
reference' errors while compiling the cyclictest programm from the testsuite.
Quoted 1 line
I'm using Xenomai 2.4.4 with uclibc and try to compile for a ppc-arch
board (Freescale MPC8343 processor).
Quoted 3 lines
Heres the line which I use to configure Xenomai:
./configure --host=powerpc-generic-linux-uclibc
CC=/opt/powerpc-linux-uclibc/bin/powerpc-generic-linux-uclibc-gcc CXX=/opt/powerpc-linux-uclibc/bin/powerpc-generic-linux-uclibc-g++ LD=/opt/powerpc-linux-uclibc/bin/powerpc-generic-linux-uclibc-ld --enable-shared=no LDFLAGS=--static
Quoted 1 line
Fully static builds will likely not work with the current Makefiles, I'm afraid.
To achieve that, one would have to follow a two-stage linking approach, partial
linking with the application and wrappers first, then final linking of the previous object with the standard libs - like libpthread - without wrapping. This has already be done for certain applications and is known to work.
Due to static linking, what happens here is that the linker sees therefore binds
pthread_* calls issued from the standard pthread library to Xenomai symbols...
which are wrappers shadowing the standard pthread_* calls... Bad idea. The point
is that the -Wl,<wrappers> directive should not appear on the link command line
for static builds when standard glibc/libpthread are listed here as well.
This said, those errors compiling the Xenomai stack should only happen with POSIX apps from the testsuite because the Makefiles there do not account for fully static builds and wrapping woes, but you can safely ignore them, provided
you do two-stage linking for your own apps. This is one of the rare cases where
make -k may help...
Signature · 1 line
Philippe.
Quoted 7 lines · Christian Volk
During the day we found a "workaround" or maybe a fix.
I will post details tomorrow from work.
We used -Wl,"-(" archives -Wl,"-)" so we built a start-group - end-group Construct which fixed all issues.Thanks for your answer Philippe, this will help me while creating my own apps.
It would be interesting if we could apply your fix to Xenomai makefiles. Could you give us a little bit more details ?
Signature · 1 line
Gilles.