public inbox for ecos-discuss@sourceware.org
 help / color / mirror / Atom feed
From: Bart Veer <bartv@redhat.com>
To: andrew.lunn@ascom.ch
Cc: ecos-discuss@sourceware.cygnus.com
Subject: Re: [ECOS] dependancies on libextras.a extras.o
Date: Wed, 05 Jul 2000 11:48:00 -0000	[thread overview]
Message-ID: <200007051848.TAA11569@sheesh.cygnus.co.uk> (raw)
In-Reply-To: <200007051742.TAA05137@biferten.ma.tech.ascom.ch>

>>>>> "Andrew" == Andrew Lunn <andrew.lunn@ascom.ch> writes:

    Andrew> It seems that the tests have a dependancy on libextras.a.
    Andrew> Now the tests don't link with libextras.a, they link with
    Andrew> extras.o.

    Andrew> I've been using one of the build trees clever facilities.
    Andrew> If you put a copy of a source file into the work tree it
    Andrew> will compile that instead of the one in the repository.
    Andrew> I've been playing with an ethernet device driver. When
    Andrew> this is compiled its put into libextras.a. To save some
    Andrew> build time i've being running the make from a couple of
    Andrew> levels down in the work tree, so it only looks at the
    Andrew> sources i've changed. I type make and then make test and
    Andrew> as expected it relinks the test programs. After a lot of
    Andrew> head scratching and disassembling object files, libraries
    Andrew> and applications i figured out i was missing something
    Andrew> obvious. When you make from the root of the work tree it
    Andrew> runs the linker on libextras.a to make extras.o. I was
    Andrew> missing this stage when making in the subtree so the tests
    Andrew> were linking with the old object code! Arrg.

    Andrew> Please can you remove the dependancy on libextras.a. If
    Andrew> anybody else makes the same mistake in the future its will
    Andrew> be a lot more obvious whats going on when the tests are
    Andrew> not relinked because what the realy depend on has not
    Andrew> changed.

To explain what is going on here:

At link time the device drivers need to be in an object file, not in a
library. Typically device driver functions are not called directly,
only indirectly after a name lookup, so the linker decides that the
functions are never used and discards them.

But you cannot directly build a single object file from multiple
source files.

So the build system creates a library libextras.a as the various
packages are processed, and at the end it turns the whole library into
a single object file by a strange linker invocation. This can only
happen at the end of a build, hence it is done from the toplevel
makefile. The actual work happens elsewhere, currently in the common
HAL package although conceivably it might have to happen in
architecture-specific HALs in some cases. A custom build step is used,
which means that the configuration tools do not actually have any
built-in knowledge of extras.o

I do agree that not rebuilding the tests at all in these circumstances
would be better than rebuilding them incorrectly, but since a makefile
$(wildcard ) is used that is not easy. Tests should definitely be
rebuilt if libtarget.a changes. A better approach is to have an
explicit rule in each package's makefile (possibly via rules.mak) of
the form:

$(PREFIX)/lib/extras.o: $(PREFIX)/lib/libextras.a
    make -C $(BUILD_TREE) $(PREFIX)/lib/extras.o

That should cause just the right number of rebuilds. However the
actual rule for rebuilding extras.o is not in the toplevel makefile,
it is currently in the common HAL, so it would have to be:

    make -C $(BUILD_TREE)/hal/common/current $(PREFIX)/lib/extras.o

But that does not work either because rules.mak does not know which
package is responsible for building extras.o (in fact right now it
does not even know that extras.o exists), or which version of that
package is being used. So things get yet more convoluted, and I am not
sure that there is a quick solution.

In any specific installation you can add a suitable rule to rules.mak
which will work for the time being, but it may suffer bit rot over
time.

The medium/long term intention is to switch to a single makefile
approach rather than per-package makefiles (you would still have the
latter so that you can rebuild just one package's test cases, but they
would invoke the toplevel makefile with a suitable target). A single
makefile should be faster then the current approach, and provide much
better support for parallel builds. Getting it right will involve
quite a bit of work, and I am not sure when it is going to happen.

Bart

      reply	other threads:[~2000-07-05 11:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-07-05 10:42 Andrew Lunn
2000-07-05 11:48 ` Bart Veer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200007051848.TAA11569@sheesh.cygnus.co.uk \
    --to=bartv@redhat.com \
    --cc=andrew.lunn@ascom.ch \
    --cc=ecos-discuss@sourceware.cygnus.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).