Topic
IC4NOTICE: developerWorks Community will be offline May 29-30, 2015 while we upgrade to the latest version of IBM Connections. For more information, read our upgrade FAQ.
13 replies Latest Post - ‏2009-10-07T09:04:12Z by kenws
SystemAdmin
SystemAdmin
706 Posts
ACCEPTED ANSWER

Pinned topic Link errors while building Cell SPE program with PDT

‏2009-08-14T10:28:52Z |
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.
Updated on 2009-10-07T09:04:12Z at 2009-10-07T09:04:12Z by kenws
  • SystemAdmin
    SystemAdmin
    706 Posts
    ACCEPTED ANSWER

    Re: Link errors while building Cell SPE program with PDT

    ‏2009-09-03T14:37:43Z  in response to SystemAdmin
    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
    • SystemAdmin
      SystemAdmin
      706 Posts
      ACCEPTED ANSWER

      Re: Link errors while building Cell SPE program with PDT

      ‏2009-09-15T18:39:47Z  in response to SystemAdmin
      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.
      • SystemAdmin
        SystemAdmin
        706 Posts
        ACCEPTED ANSWER

        Re: Link errors while building Cell SPE program with PDT

        ‏2009-09-21T16:07:38Z  in response to SystemAdmin
        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 !
        • SystemAdmin
          SystemAdmin
          706 Posts
          ACCEPTED ANSWER

          Re: Link errors while building Cell SPE program with PDT

          ‏2009-09-21T16:24:01Z  in response to SystemAdmin
          Hi,

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

          Thanks!
          • UziShvadron
            UziShvadron
            3 Posts
            ACCEPTED ANSWER

            Re: Link errors while building Cell SPE program with PDT

            ‏2009-09-25T18:18:15Z  in response to SystemAdmin
            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.
            • SystemAdmin
              SystemAdmin
              706 Posts
              ACCEPTED ANSWER

              Re: Link errors while building Cell SPE program with PDT

              ‏2009-09-26T10:29:39Z  in response to UziShvadron
              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
                UziShvadron
                3 Posts
                ACCEPTED ANSWER

                Re: Link errors while building Cell SPE program with PDT

                ‏2009-09-27T16:06:42Z  in response to SystemAdmin
                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?
                • SystemAdmin
                  SystemAdmin
                  706 Posts
                  ACCEPTED ANSWER

                  Re: Link errors while building Cell SPE program with PDT

                  ‏2009-09-27T21:02:21Z  in response to UziShvadron
                  I have libtrace in /opt/cell/sysroot/usr/spu/lib/trace/.
                  • UziShvadron
                    UziShvadron
                    3 Posts
                    ACCEPTED ANSWER

                    Re: Link errors while building Cell SPE program with PDT

                    ‏2009-09-28T19:16:40Z  in response to SystemAdmin
                    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?
                    • SystemAdmin
                      SystemAdmin
                      706 Posts
                      ACCEPTED ANSWER

                      Re: Link errors while building Cell SPE program with PDT

                      ‏2009-09-28T19:22:05Z  in response to UziShvadron
                      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
                        kenws
                        2 Posts
                        ACCEPTED ANSWER

                        Re: Link errors while building Cell SPE program with PDT

                        ‏2009-10-06T14:16:23Z  in response to SystemAdmin
                        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
                        • SystemAdmin
                          SystemAdmin
                          706 Posts
                          ACCEPTED ANSWER

                          Re: Link errors while building Cell SPE program with PDT

                          ‏2009-10-06T14:31:21Z  in response to kenws
                          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
                            kenws
                            2 Posts
                            ACCEPTED ANSWER

                            Re: Link errors while building Cell SPE program with PDT

                            ‏2009-10-07T09:04:12Z  in response to SystemAdmin
                            Ok, it sounds like the only missing piece was the extern "C" stuff. Does the patch work for you?
                            -ken