2008-05-23 16:50:59 Werd Linking Problem
Cameron Barfield (UNITED STATES)
Message: 56227
I'm trying to port a project to the Blackfin.
I've got it running great on my desktop linux distro.
When I cross-compile for the blackfin, I get some odd behavior. For instance, gethostid() and getpid() fail. The caller just kind of hangs forever. If I run strace, I see that the caller is fetching the host name, but then ends up getting a suspend signal. The weird part? If I remove the -lasound flag during linking, the binary size increases and the call starts working.
Here's the compile and link lines:
bfin-linux-uclibc-gcc -pipe -Wall -O3 -ffast-math -mfast-fp -mcpu=bf537-0.2 -W -Wall -Wbad-function-cast -Wmissing-prototypes -DHAVE_CONFIG_H -DHIDE_SOURCE_STRINGS -DSASR -I/home/cameron/src/blackfin/svn/uClinux-dist.2008/user/cyberdata/rat/local/include/common -I/home/cameron/src/blackfin/svn/uClinux-dist.2008/include -I/home/cameron/src/blackfin/svn/uClinux-dist.2008/linux/include -I/home/cameron/src/blackfin/svn/uClinux-dist.2008/staging/usr/include -c main_engine.c
bfin-linux-uclibc-gcc -pipe -Wall -O3 -ffast-math -mfast-fp -mcpu=bf537-0.2 -W -Wall -Wbad-function-cast -Wmissing-prototypes -DHAVE_CONFIG_H -DHIDE_SOURCE_STRINGS -DSASR -I/home/cameron/src/blackfin/svn/uClinux-dist.2008/user/cyberdata/rat/local/include/common -I/home/cameron/src/blackfin/svn/uClinux-dist.2008/include -I/home/cameron/src/blackfin/svn/uClinux-dist.2008/linux/include -I/home/cameron/src/blackfin/svn/uClinux-dist.2008/staging/usr/include main_engine.o libuclaudio.a libuclcodec.a libuclsndfile.a -L/home/cameron/src/blackfin/svn/uClinux-dist.2008/user/cyberdata/rat/local -luclmmbase -L/home/cameron/src/blackfin/svn/uClinux-dist.2008/staging/usr/lib/ -lasound -ldl -lm -o rat-4.4.01-media
I've stripped everything down to one source file (attached) that just does the call to gethostid() and getpid().
I'm probably just missing something stupid simple in this cross-compile, but I can't seem to find it. Any ideas?
config_unix.h
strace.txt
main_engine.c
QuoteReplyEditDelete
2008-05-23 17:07:51 Re: Werd Linking Problem
Mike Frysinger (UNITED STATES)
Message: 56229
can you drop the linking of the lib*.a archives as well as the -ldl and -lm and see if that makes a difference
i would also remove the -O3 -ffast-math -mfast-fp -mcpu=bf537-0.2 and make sure it still fails
QuoteReplyEditDelete
2008-05-23 17:39:37 Re: Werd Linking Problem
Cameron Barfield (UNITED STATES)
Message: 56231
Still have the same results without the lib*.a, -ldl, -lm -O3, -ffast-math, -mfast, -mcpu=bf537-0.2
bfin-linux-uclibc-gcc -pipe -W -Wall -Wbad-function-cast -Wmissing-prototypes -DHAVE_CONFIG_H -DHIDE_SOURCE_STRINGS -DSASR -I/home/cameron/src/blackfin/svn/uClinux-dist.2008/user/cyberdata/rat/local/include/common -I/home/cameron/src/blackfin/svn/uClinux-dist.2008/include -I/home/cameron/src/blackfin/svn/uClinux-dist.2008/linux/include -I/home/cameron/src/blackfin/svn/uClinux-dist.2008/staging/usr/include -c main_engine.c
bfin-linux-uclibc-gcc -pipe -W -Wall -Wbad-function-cast -Wmissing-prototypes -DHAVE_CONFIG_H -DHIDE_SOURCE_STRINGS -DSASR -I/home/cameron/src/blackfin/svn/uClinux-dist.2008/user/cyberdata/rat/local/include/common -I/home/cameron/src/blackfin/svn/uClinux-dist.2008/include -I/home/cameron/src/blackfin/svn/uClinux-dist.2008/linux/include -I/home/cameron/src/blackfin/svn/uClinux-dist.2008/staging/usr/include main_engine.o -L/home/cameron/src/blackfin/svn/uClinux-dist.2008/user/cyberdata/rat/local -luclmmbase -L/home/cameron/src/blackfin/svn/uClinux-dist.2008/staging/usr/lib/ -lasound -o rat-4.4.01-media
QuoteReplyEditDelete
2008-05-23 17:54:30 Re: Werd Linking Problem
Mike Frysinger (UNITED STATES)
Message: 56232
just making sure ... less variables to take into account
the next step ... produce a preprocessed source file to compile so that we only have 1 thing to mess around with without worrying about system header differences
just take the compile line and change "-c" to "-E -o main_engine.i"
then take the link line and replace "main_engine.o" with "main_engine.i"
if that fails, post the main_engine.i as an attachment
you could also try adding -lpthread after -lasound and see if that makes a difference
QuoteReplyEditDelete
2008-05-23 17:59:30 Re: Werd Linking Problem
Cameron Barfield (UNITED STATES)
Message: 56233
Well, I'm lazy so I tried adding -lpthread first. That worked.
I'm also curious, so I'll probably mess around with the other option after the weekend and try to figure out why.
Thanks, Mike.
QuoteReplyEditDelete
2008-05-23 18:08:23 Re: Werd Linking Problem
Mike Frysinger (UNITED STATES)
Message: 56234
then you've probably hit a pthread bug that i fixed earlier that has to do with indirect access to libpthread
you can just link -lpthread directly and avoid the issue ... it shouldnt cause any sort of degradation as libpthread is already being pulled in unconditionally via -lasound