Skip to main content

developerWorks >  Linux  >  Forums  >  Linux for Power Architecture  >  developerWorks

Link errors while building Cell SPE program with PDT    Point your RSS reader here for a feed of the latest messages in this thread


Tags for this thread: 

     

 
 

My developerWorks
 Welcome, Guest
Sign in or register
This question is answered.

Permlink Replies: 13 - Pages: 1 - Last Post: Oct 7, 2009 5:04 AM Last Post By: kenws
bucurb

Posts: 7
Registered: Aug 11, 2009 05:20:14 PM
Link errors while building Cell SPE program with PDT
Posted: Aug 14, 2009 06:28:52 AM
 
Click to report abuse...   Click to reply to this thread Reply
Hello,

I'm trying to build a SPE program with PDT profiling enabled but I get some link errors. Following the samples in IBM documentation, my makefile is:

CC=/opt/cell/toolchain/bin/spu-g++

OBJS=DMABuf.o FVExtraction.o RWBuf.o Base/Matrix.o Base/Memory.o Base/SymSVD.o Base/Vector.o
FILES=DMABuf.cpp FVExtraction.cpp RWBuf.cpp Base/Matrix.cpp Base/Memory.cpp Base/SymSVD.cpp Base/Vector.cpp

CFLAGS=-W -Wno-main -g -I/opt/cell/sysroot/usr/spu/include/trace -Dmain=_pdt_main -Dexit=_pdt_exit -DMFCIO_TRACE -DLIBSYNC_TRACE -I. -I/opt/cell/sdk/usr/spu/include -march=cell -mea32 -mfloat=fast -mdouble=fast -mtune=cell -Winline -Wextra
LFLAGS=-Wl,-N -Wl,-q -L/opt/cell/sysroot/opt/cell/sdk/usr/spu/lib/trace -lsync -L/opt/cell/sysroot/usr/spu/lib/trace -ltrace -L/opt/cell/sysroot/opt/cell/sdk/usr/spu/lib/trace -lsync -L/opt/cell/sysroot/opt/cell/sdk/usr/spu/lib -lsimdmath -lmisc -L.

all: $(OBJS)
$(CC) -O $(OBJS) -o FVExtraction $(CFLAGS) $(LFLAGS)

%.o: %.cpp
$(CC) -O -c $^ $(CFLAGS) -o $@

clean:
rm -f FVExtraction
rm -f *.o
rm -f Base/*.o

The errors I get are:

/home/bucurb/workspace/cell/FVExtraction/DMABuf.cpp:263: undefined reference to `trace_interval_entry(short, unsigned int)'
DMABuf.o: In function `trace_mfc_read_tag_status':
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:26: undefined reference to `trace_interval_entry(short, unsigned int)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:26: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:30: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
FVExtraction.o: In function `InitFVE(unsigned long long, unsigned long long)':
/home/bucurb/workspace/cell/FVExtraction/FVExtraction.cpp:120: undefined reference to `trace_event(short, int, trace_payload_t*, char const*, unsigned int)'
/home/bucurb/workspace/cell/FVExtraction/FVExtraction.cpp:120: undefined reference to `trace_event(short, int, trace_payload_t*, char const*, unsigned int)'
/home/bucurb/workspace/cell/FVExtraction/FVExtraction.cpp:121: undefined reference to `trace_interval_entry(short, unsigned int)'
FVExtraction.o: In function `trace_mfc_read_tag_status':
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:26: undefined reference to `trace_interval_entry(short, unsigned int)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:26: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:30: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
FVExtraction.o: In function `InitFVE(unsigned long long, unsigned long long)':
/home/bucurb/workspace/cell/FVExtraction/FVExtraction.cpp:123: undefined reference to `trace_event(short, int, trace_payload_t*, char const*, unsigned int)'
/home/bucurb/workspace/cell/FVExtraction/FVExtraction.cpp:130: undefined reference to `trace_event(short, int, trace_payload_t*, char const*, unsigned int)'
/home/bucurb/workspace/cell/FVExtraction/FVExtraction.cpp:130: undefined reference to `trace_interval_entry(short, unsigned int)'
FVExtraction.o: In function `trace_mfc_read_tag_status':
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:26: undefined reference to `trace_interval_entry(short, unsigned int)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:26: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:30: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
FVExtraction.o: In function `InitFVE(unsigned long long, unsigned long long)':
/home/bucurb/workspace/cell/FVExtraction/FVExtraction.cpp:133: undefined reference to `trace_event(short, int, trace_payload_t*, char const*, unsigned int)'
/home/bucurb/workspace/cell/FVExtraction/FVExtraction.cpp:140: undefined reference to `trace_event(short, int, trace_payload_t*, char const*, unsigned int)'
/home/bucurb/workspace/cell/FVExtraction/FVExtraction.cpp:140: undefined reference to `trace_interval_entry(short, unsigned int)'
FVExtraction.o: In function `trace_mfc_read_tag_status':
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:26: undefined reference to `trace_interval_entry(short, unsigned int)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:26: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:30: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
FVExtraction.o: In function `InitFVE(unsigned long long, unsigned long long)':
/home/bucurb/workspace/cell/FVExtraction/FVExtraction.cpp:143: undefined reference to `trace_event(short, int, trace_payload_t*, char const*, unsigned int)'
/home/bucurb/workspace/cell/FVExtraction/FVExtraction.cpp:150: undefined reference to `trace_event(short, int, trace_payload_t*, char const*, unsigned int)'
/home/bucurb/workspace/cell/FVExtraction/FVExtraction.cpp:150: undefined reference to `trace_interval_entry(short, unsigned int)'
FVExtraction.o: In function `trace_mfc_read_tag_status':
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:26: undefined reference to `trace_interval_entry(short, unsigned int)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:26: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:30: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
FVExtraction.o: In function `spu_mfcdma64':
/opt/cell/toolchain/lib/gcc/spu/4.1.1/include/spu_internals.h:2910: undefined reference to `trace_event(short, int, trace_payload_t*, char const*, unsigned int)'
FVExtraction.o: In function `InitFVE(unsigned long long, unsigned long long)':
/home/bucurb/workspace/cell/FVExtraction/FVExtraction.cpp:194: undefined reference to `trace_event(short, int, trace_payload_t*, char const*, unsigned int)'
/home/bucurb/workspace/cell/FVExtraction/FVExtraction.cpp:194: undefined reference to `trace_interval_entry(short, unsigned int)'
FVExtraction.o: In function `trace_mfc_read_tag_status':
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:26: undefined reference to `trace_interval_entry(short, unsigned int)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:26: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:30: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
FVExtraction.o: In function `spu_mfcdma64':
/opt/cell/toolchain/lib/gcc/spu/4.1.1/include/spu_internals.h:2910: undefined reference to `trace_event(short, int, trace_payload_t*, char const*, unsigned int)'
FVExtraction.o: In function `InitFVE(unsigned long long, unsigned long long)':
/home/bucurb/workspace/cell/FVExtraction/FVExtraction.cpp:212: undefined reference to `trace_event(short, int, trace_payload_t*, char const*, unsigned int)'
/home/bucurb/workspace/cell/FVExtraction/FVExtraction.cpp:212: undefined reference to `trace_interval_entry(short, unsigned int)'
FVExtraction.o: In function `trace_mfc_read_tag_status':
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:26: undefined reference to `trace_interval_entry(short, unsigned int)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:26: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:30: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
FVExtraction.o: In function `trace_spu_write_out_mbox':
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:76: undefined reference to `trace_interval_entry(short, unsigned int)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:76: undefined reference to `trace_interval_entry(short, unsigned int)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:76: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:78: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:76: undefined reference to `trace_interval_entry(short, unsigned int)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:76: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h:78: undefined reference to `trace_interval_exit(void*, int, trace_payload_t*, char const*)'
/opt/cell/sysroot/usr/spu/lib/trace/libtrace.a(spe_main.o): In function `main':
spe_main.c:(.text+0x1ec): undefined reference to `_pdt_main'

So apparently it behaves like it does not find the libs, but they are there, with the proper paths. Do you have any idea of what is wrong ? Thanks in advance.

jensi

Posts: 2
Registered: Sep 03, 2009 10:32:59 AM
Re: Link errors while building Cell SPE program with PDT
Posted: Sep 03, 2009 10:37:43 AM   in response to: bucurb in response to: bucurb's post
 
Click to report abuse...   Click to reply to this thread Reply
Hello Bogdan,

what architecture are you trying to build this on ? I.e is this a cross-build ?
what SDK and what distro are you using ?

Jens
bucurb

Posts: 7
Registered: Aug 11, 2009 05:20:14 PM
Re: Link errors while building Cell SPE program with PDT
Posted: Sep 15, 2009 02:39:47 PM   in response to: jensi in response to: jensi's post
 
Click to report abuse...   Click to reply to this thread Reply
Hi,

I'm compiling it on x86 Linux Fedora 9, targetting the Cell SPE. I am using the toolchain that comes with the Cell SDK v.3.1 devel.

Thanks.

jensi

Posts: 2
Registered: Sep 03, 2009 10:32:59 AM
Re: Link errors while building Cell SPE program with PDT
Posted: Sep 21, 2009 12:07:38 PM   in response to: bucurb in response to: bucurb's post
 
Click to report abuse...   Click to reply to this thread Reply
Can you please provide a small code sample (incl. all the necessary components needed to build) which shows the problems
and attach it here ?

Thanks !
bucurb

Posts: 7
Registered: Aug 11, 2009 05:20:14 PM
Re: Link errors while building Cell SPE program with PDT
Posted: Sep 21, 2009 12:24:01 PM   in response to: jensi in response to: jensi's post
 
Click to report abuse...   Click to reply to this thread Reply
Attachment FVExtraction.rar (17.2 KB)
Hi,

I have attached all necessary source files. My makefile is in the first post.

Thanks!
UziShvadron

Posts: 14
Registered: Aug 24, 2006 01:33:12 PM
Re: Link errors while building Cell SPE program with PDT
Posted: Sep 25, 2009 02:18:15 PM   in response to: bucurb in response to: bucurb's post
 
Click to report abuse...   Click to reply to this thread Reply
These functions are defined as extern and are staticly linked. Do you have anything in /opt/cell/sysroot/opt/cell/sdk/usr/spu/lib/trace ? if not none trace files are taken from /opt/cell/sysroot/opt/cell/sdk/usr/spu/lib.
bucurb

Posts: 7
Registered: Aug 11, 2009 05:20:14 PM
Re: Link errors while building Cell SPE program with PDT
Posted: Sep 26, 2009 06:29:39 AM   in response to: UziShvadron in response to: UziShvadron's post
 
Click to report abuse...   Click to reply to this thread Reply
Yes, I have libsync.a in /opt/cell/sysroot/opt/cell/sdk/usr/spu/lib/trace. I know that it looks like the linker is not using the proper libraries, but I get the same errors even if the profiler libs are given with full paths to gcc.
UziShvadron

Posts: 14
Registered: Aug 24, 2006 01:33:12 PM
Re: Link errors while building Cell SPE program with PDT
Posted: Sep 27, 2009 12:06:42 PM   in response to: bucurb in response to: bucurb's post
 
Click to report abuse...   Click to reply to this thread Reply
Only libync? You need libtrace as well. It seems that the trace library is not installed properly. Can someone point to the current location of the tracing facility?
bucurb

Posts: 7
Registered: Aug 11, 2009 05:20:14 PM
Re: Link errors while building Cell SPE program with PDT
Posted: Sep 27, 2009 05:02:21 PM   in response to: UziShvadron in response to: UziShvadron's post
 
Click to report abuse...   Click to reply to this thread Reply
I have libtrace in /opt/cell/sysroot/usr/spu/lib/trace/.
UziShvadron

Posts: 14
Registered: Aug 24, 2006 01:33:12 PM
Re: Link errors while building Cell SPE program with PDT
Posted: Sep 28, 2009 03:16:40 PM   in response to: bucurb in response to: bucurb's post
 
Click to report abuse...   Click to reply to this thread Reply
I am a little confused then...
I get:
sysroot/usr/spu/lib/trace]$ nm libtrace.a | grep trace_interval_entry
00000000 T trace_interval_entry
so it is there.
Do you get the same?
Also (might not be listed in the first post), do you have missing include file(s) when you compile?
bucurb

Posts: 7
Registered: Aug 11, 2009 05:20:14 PM
Re: Link errors while building Cell SPE program with PDT
Posted: Sep 28, 2009 03:22:05 PM   in response to: UziShvadron in response to: UziShvadron's post
 
Click to report abuse...   Click to reply to this thread Reply
Yes, I know the functions are there, I have them too. But this is my problem, although the functions are in the libraries and I tell gcc to use the profile libraries, it behaves as if it ignores them. I have no compile errors, just link errors, as pasted in the first post.

Were you actually able to successfully compile the source code I attached in a previous post?

Thanks!
kenws

Posts: 33
Registered: Mar 05, 2009 09:26:50 AM
Re: Link errors while building Cell SPE program with PDT
Posted: Oct 06, 2009 10:16:23 AM   in response to: bucurb in response to: bucurb's post
 
Click to report abuse...   Click to reply to this thread Reply
Hi,

It seems the linker prints the missing symbols in its demangled form. From the error message, they do look like the symbols of the trace lib, but in fact they aren't part of it. You can check this with spu-nm or spu-readelf -s on your object files. They got mangled because some of the trace headers aren't C++ safe. That can be fixed by making the headers C++ safe (see attached patch). I also fixed the places where void* was implicetely converted to trace_payload_t* which works with C but not with C++. In addition, the two globals _current_mask and _update_type shouldn't be defined in a header file (/opt/cell/sysroot/usr/spu/include/trace/trace_spu_mfcio.h), in my opinion. If two or more cpp files are using mfc_get/mfc_put functions, the header file is pulled in and the linker will throw an error at the final link step because there are two identical symbols in different object files. Using C, they will go into the common section, but using C++ they do not and thus collide. A solution would be to declare them extern and define them somewhere in the trace lib (or in your code as a workaround).

-ken
bucurb

Posts: 7
Registered: Aug 11, 2009 05:20:14 PM
Re: Link errors while building Cell SPE program with PDT
Posted: Oct 06, 2009 10:31:21 AM   in response to: kenws in response to: kenws's post
 
Click to report abuse...   Click to reply to this thread Reply
Hi,

Thank you, indeed I fixed the void* to trace_payload_t* conversion myself in the headers and also defined the _current_mask and _update_type globals in my code in order to compile it; that's how I managed to only get linker errors. Thank you for the patch.
kenws

Posts: 33
Registered: Mar 05, 2009 09:26:50 AM
Re: Link errors while building Cell SPE program with PDT
Posted: Oct 07, 2009 05:04:12 AM   in response to: bucurb in response to: bucurb's post
 
Click to report abuse...   Click to reply to this thread Reply
Ok, it sounds like the only missing piece was the extern "C" stuff. Does the patch work for you?
-ken
 Tags
Help

Use the search field to find all types of content in My developerWorks with that tag.

Use the slider bar to see more or fewer tags.

Popular tags shows the top tags for this particular type of content or application that you're viewing.

My tags shows your tags for this particular type of content or application that you're viewing.

 

MoreLess 


Point your RSS reader here for a feed of the latest messages in all forums