Makefile question

Sergei Organov osv at topconrd.ru
Thu Nov 25 10:22:11 UTC 2004


"Smith, Gene" <gene.smith at siemens.com> writes:
> Sergei Organov wrote, On 11/24/2004 2:11 PM:
> 
> >> I have a bunch of "modules" each in a separate directory (each is
> >> not necessarily a rtems task). Do you think it is ok to build each
> >> one as a partial link and then in the last build step link each
> >> partial against rtems libraries? That seems reasonable to me.
> > I'd say it's OK, but I indeed don't see any rationale behind it.
> 
> > What's a point in building these partially linked files? For me it'd
> > bring only additional troubles managing subtle problems with linker
> > behavior on partial links. Overall, my advice is: forget about
> > partially linked files unless you really know you need them. If you
> > don't want to just link all the objects from different directories
> > into the final image, make libraries for each component instead.
> 
> Guess I was a little afraid of hitting the linker with thousands of
> .o's all at one time.

AFAIK GNU linker is capable to link huge applications, so I don't think
number of objects could be an issue.

> I did do a non-rtems project with a lot of partials and it worked ok.
> The linker had no problems.

Partial link is somewhat different process than final link, so
effectively you are using two somewhat different linkers, each of which
may have its own usage specific and bugs.

> But you may be right that linking it at once is ok.

My general advice is: make it a simple as possible, -- complications
will come eventually anyway ;)

[...]

> In /opt/rtems-4.6/powerpc/<my-bsp-name>/lib I see
> librtemsbsp.a and librtemscpu.a plus linkcmds and all the no-*.rel's.
> I only see librtemsall.a in rtems 4.5 stuff.

Yeah, that's an old stuff. For newer RTEMSes link in both *.a libraries,
e.g., --start-group -lrtemsbsp -lrtemscpu --end-group.

[...]

> >> (Relating to question 1 and 2, when I watch netdemo build I only
> >> see linking against no-*.rel files.)
> > Didn't you miss "-lsomething" that means link in "libsomething.a"?
> 
> Could debug -d be lying to me?
> Here is what it says is being linked:
> 
> powerpc-rtems-gcc --pipe -B/opt/rtems-4.6/powerpc-rtems/<bspname>/lib/ -specs
> bsp_specs -qrtems -g -Wall -O0 -fno-keep-inline-functions -mcpu=403
> -D_OLD_EXCEPTIONS -Dppc405 -o o-optimize/netdemo.exe o-optimize/init.o
> o-optimize/test.o /opt/rtems-4.6/powerpc-rtems/<bspname>/lib/no-dpmem.rel
> /opt/rtems-4.6/powerpc-rtems/<bspname>/lib/no-msg.rel
> /opt/rtems-4.6/powerpc-rtems/<bspname>/lib/no-mp.rel
> /opt/rtems-4.6/powerpc-rtems/<bspname>/lib/no-part.rel
> /opt/rtems-4.6/powerpc-rtems/<bspname>/lib/no-signal.rel
> /opt/rtems-4.6/powerpc-rtems/<bspname>/lib/no-timer.rel
> /opt/rtems-4.6/powerpc-rtems/<bspname>/lib/no-rtmon.rel

Add -v flag to gcc and see what is actually being linked. Specs file
and/or linker command file may specify more objects/libraries.

-- 
Sergei.




More information about the users mailing list