darcs patch: Warn if C dependencies not found (kind of fixes #262)

Duncan Coutts duncan.coutts at worc.ox.ac.uk
Thu Jan 29 07:36:35 EST 2009


On Mon, 2009-01-26 at 21:03 +0200, gleb.alexeev at gmail.com wrote:
> Mon Jan 26 20:58:32 EET 2009  gleb.alexeev at gmail.com
>   * Warn if C dependencies not found (kind of fixes #262)
>   
>   This is just a basic check - generate a sample program and check if
> it compiles and links with relevant flags. Error messages (warning
> messages, actually) could use some improvement.

I think this is basically ok. There are some further improvements we
will need to make, but we can do that on top of what we've got now so
I'm pushing your patch now. It also makes it easier for other people to
report how well it works in practise.

One is that we'll have to do the check in a slightly different place for
packages that use ./configure scripts since the post-conf action is
where configure runs and it drops a .buildinfo file. I can do that bit.

We can improve the error messages as you suggested.

I suspect that we will need to include all the headers and link all the
libs in one go, at least in the first go. That is because on many
systems, some headers cannot be included without other headers being
included first. Similarly static libraries can have dependencies on
other static libs, so linking to just one may fail.

Of course then the tricky part is if it fails, which header or lib do
blame? If we do the compilation and link steps separately then
distinguishing the headers from libs is easy. Now for the tricky bit. We
do not know the dependencies between the headers or libs, however we do
know that they have been listed in dependency order. So if we try all
prefixes in sequence then we should eventually hit the one that fails,
but in each case where we try a new one we're also using its
dependencies.

For example if we have:

includes: foo.h bar.h baz.h

and it so happens that bar.h and baz.g needs foo.h to be included first.
So we try:

foo.h bar.h baz.h

Now if that fails, we try:

foo.h
foo.h bar.h
foo.h bar.h baz.h

And at some point one of those will fail and we can report that the
extra one is the cause of the problem. So it does mean we cannot report
more than one problem accurately, but never mind.

So we should generalise the test function to take a list of headers and
libs.


Duncan



More information about the cabal-devel mailing list