[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: creating specialized linking rules?

From: John Wohlbier
Subject: Re: creating specialized linking rules?
Date: Tue, 11 Aug 2009 05:50:47 -0600

On Wed, Aug 5, 2009 at 8:04 PM, John Wohlbier <address@hidden>wrote:

> I'm using libtool in a project where I'm compiling code for the cell
> processor. The cell requires different compilers to be used on sources
> compiled for the PowerPC core (PPU) and the "synergistic processing unit"
> (SPU). I'm building (trying to build) a libtool library for the ppu which
> embeds the spu executable into the library.
> Something that works for embedding "by hand" is to have a rule such as:
> lib%.o: /pathto/spu/lib/%
>     cp /pathto/spu/lib/$* .
>     ${PEMB} ${PEMBFLAGS} $* $* $*-emb.o
>     ${PAR} -qcs $@ $*-emb.o
>     rm $*
> where % refers to a "spucode" compiled executable with a main, and have the
> library link in libspucode.o.
> What this translates to on the compile line (evaluating the variables) is
> ppu-embedspu -m64 spucode spucode spucode-emb.o
> ppu-ar -qcs libspucode.o spucode-emb.o
> However, this doesn't work when making libtool libraries. I'd like to do
> something like
> mylibtoollib_la_LIBADD += libspucode.o
> but libtool (understandably) complains that libspucode.o is not a libtool
> object. What I'm wondering about is how to write the embedding and archiving
> rule using libtool, perhaps to make libspucode.lo.
> Thanks much.
> jgw
A coworker figured this out for me, and I thought I'd post it to the list
for future reference (also posting to automake as it seems relevant to that
list as well).

For embedding an spe program into a ppe program, something like this works:

## ppe test executables that need to link in an spe executable
test_Program_LDADD += lib-root_segment.o

lib-%.o : @SPE_BUILDDIR@/lib/%
        cp @SPE_BUILDDIR@/lib/$* .
        ${PEMB} ${PEMBFLAGS} $* $* $*-emb.o
        ${PAR} -qcs $@ $*-emb.o
        rm $*

where @SPE_BUILDDIR@ is the build path to the spe program.

The real issue, though, was getting the spe program to link into a libtool
library, for which this works:

## special rules for the ppe library to link in the spe executable
libtest_lib_la_LIBADD += \

# make the emb-%.lo files depend on the emb-%.o files
# this triggers the emb-%.o rule which tricks libtool into
# thinking that the object created from embedding is a
# libtool object.
emb-%.lo : emb-%.o
        @echo "Ha! Tricked libtool"

emb-%.o: @SPE_BUILDDIR@/lib/%
        echo "void lotrickdummy() {}" > dummy.c
        $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ dummy.c
        rm $@
        rm dummy.c
        cp @SPE_BUILDDIR@/lib/$* .
        ${PEMB} ${PEMBFLAGS} $* $* emb-$*.o
        rm $*

where again, in my case, the following evaluate as
${PEMB} ${PEMBFLAGS} = ppu-embedspu -m64
${PAR} = ppu-ar

Hope this may help someone out there.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]