Topic
  • 3 replies
  • Latest Post - ‏2010-05-25T02:04:12Z by jadamcze
RagingAvatar
RagingAvatar
11 Posts

Pinned topic Linking C++ HelloWorld for SPU error?

‏2010-05-23T20:50:06Z |
Hey guys,

I'd really appreciate some help.
I wrote a simple HelloWorld app:

#include <iostream>

int main()
{
std::cout << "HelloWorld!" << std::endl;
return 0;
}

Which is obviously the most simple c++ app ever written.
I try and compile/link this for spu and I get the following errors:

/usr/lib/gcc/spu/4.1.1/../../../../spu/bin/ld: .text exceeds local store range
/usr/lib/gcc/spu/4.1.1/crtbegin.o: In function `__do_global_dtors_aux':
+crtstuff.c:(.text+0xc): relocation truncated to fit: SPU_REL16 against `.bss'+
+crtstuff.c:(.text+0x34): relocation truncated to fit: SPU_REL16 against `.data'+
+crtstuff.c:(.text+0x3c): relocation truncated to fit: SPU_REL16 against `.data'+
+crtstuff.c:(.text+0x54): relocation truncated to fit: SPU_REL16 against `.bss'+
/usr/lib/gcc/spu/4.1.1/crtbegin.o: In function `frame_dummy':
+crtstuff.c:(.text+0x80): relocation truncated to fit: SPU_ADDR18 against `.jcr'+
+crtstuff.c:(.text+0x84): relocation truncated to fit: SPU_REL16 against `.jcr'+
+/usr/lib/gcc/spu/4.1.1/crtbegin.o:(.fini+0x0): relocation truncated to fit: SPU_REL16 against `__do_global_dtors_aux'+
/usr/lib/gcc/spu/4.1.1/crtend.o: In function `__do_global_ctors_aux':
+crtstuff.c:(.text+0x8): relocation truncated to fit: SPU_ADDR18 against `.ctors'+
+/usr/lib/gcc/spu/4.1.1/crtend.o:(.init+0x0): relocation truncated to fit: SPU_REL16 against `__do_global_ctors_aux'+
/usr/lib/gcc/spu/4.1.1/../../../../spu/lib/crt1.o: In function `_start':
+(.text+0x0): relocation truncated to fit: SPU_REL16 against symbol `__ea_local_store' defined in COMMON section in /usr/lib/gcc/spu/4.1.1/../../../../spu/lib/crt1.o+
/usr/lib/gcc/spu/4.1.1/../../../../spu/lib/crt1.o: In function `_start':
+(.text+0x28): additional relocation overflows omitted from the output+
+/usr/lib/gcc/spu/4.1.1/libstdc++.a(basic_file.o): In function `std::__basic_file<char>::sys_open(int, std::_Ios_Openmode)':+
+/home/sur/jordics/sdk3.1/src/redhat/BUILD/spu-gcc-4.1.1/obj-spu/spu/libstdc++-v3/src/basic_file.cc:212: undefined reference to `fdopen'+
collect2: ld returned 1 exit status

Now, I don't believe for a second that that app is going to exceed the local store.
What's going on? Any ideas?

I've been working my way through Scarpino's book, I'm running Fedora 9 on a PS3.
(I'm not some kid who is just using PS3 Linux for fun - I'm a Cell developer at work. I just don't get what is going on here!)
Updated on 2010-05-25T02:04:12Z at 2010-05-25T02:04:12Z by jadamcze
  • andhp
    andhp
    48 Posts

    Re: Linking C++ HelloWorld for SPU error?

    ‏2010-05-23T22:11:37Z  
    Yes, it does exceed the local store. Check out the last couple of posts from this thread:

    https://www.ibm.com/developerworks/forums/thread.jspa?threadID=262816&start=15&tstart=0

    The "C/C++ Language Extensions for Cell Broadband Engine Architecture" document has some information about which parts of the C++ standard library should be available on the SPU.
  • RagingAvatar
    RagingAvatar
    11 Posts

    Re: Linking C++ HelloWorld for SPU error?

    ‏2010-05-24T22:29:20Z  
    • andhp
    • ‏2010-05-23T22:11:37Z
    Yes, it does exceed the local store. Check out the last couple of posts from this thread:

    https://www.ibm.com/developerworks/forums/thread.jspa?threadID=262816&start=15&tstart=0

    The "C/C++ Language Extensions for Cell Broadband Engine Architecture" document has some information about which parts of the C++ standard library should be available on the SPU.
    Wow, I really made a fool of myself here didn't I!

    Thanks very much for the help andhp. I was foolish to not listen to the linker!

    I was wondering though, if I create a simple sample of 'HelloWorld' using printf instead of cout - it works - cout presumably can't because of the large overhead of the whole iostream part of the C++ std library..? I see that the iostream sections of the library aren't included anyway.

    How does the SPU actually print 'HelloWorld' using printf? How can it possibly get access to the console?
    The section 'Debug printf()' in the 'C/C++ Language Extensions for Cell Broadband Engine Architecture' isn't very informative about it..
  • jadamcze
    jadamcze
    219 Posts

    Re: Linking C++ HelloWorld for SPU error?

    ‏2010-05-25T02:04:12Z  
    Wow, I really made a fool of myself here didn't I!

    Thanks very much for the help andhp. I was foolish to not listen to the linker!

    I was wondering though, if I create a simple sample of 'HelloWorld' using printf instead of cout - it works - cout presumably can't because of the large overhead of the whole iostream part of the C++ std library..? I see that the iostream sections of the library aren't included anyway.

    How does the SPU actually print 'HelloWorld' using printf? How can it possibly get access to the console?
    The section 'Debug printf()' in the 'C/C++ Language Extensions for Cell Broadband Engine Architecture' isn't very informative about it..
    SPU programs use newlib to provide C library functions (like printf) and syscalls. Many of these newlib functions will pass the arguments (or a pointer to the arguments) to a callback function provided by libspe2, stop the SPU and wait for it to be restarted when the function call has been completed.

    The SPU doesn't have "access to the console" as such, but it knows someone who does ;)