[flashrom] [PATCH] More robust libpci detection

Idwer Vollering vidwer at gmail.com
Mon Mar 22 13:11:26 CET 2010


2010/3/22 Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>

> On 01.03.2010 16:34, Carl-Daniel Hailfinger wrote:
> > On 28.02.2010 16:30, Idwer Vollering wrote:
> >
> >> 2010/2/26 Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
> >>
> >>
> >>> Idwer reported problems with the current libpci check on
> >>>
> >>> FreeBSD 8.0-RELEASE i386
> >>>
> >>> This is caused by a strict linker. Parsing linker error messages is an
> >>> exercise in futility, so I implemented fallback library detection with
> >>> $CC --print-file-name.
> >>> This fallback will fail on llvm-clang (llvm bug 5137), but such
> machines
> >>> hopefully have a more permissive linker and will never hit that code
> path.
> >>> The fallback will also fail on NetBSD where we should look for
> >>> libpciutils instead, but that hopefully doesn't have a strict linker
> >>> either.
> >>>
> >>> Side note: The configure checks in the Makefile are now so unwieldy
> that
> >>> a separate configure script will definitely improve readability.
> >>>
> >>> Signed-off-by: Carl-Daniel Hailfinger <
> c-d.hailfinger.devel.2006 at gmx.net>
> >>>
> >>>
> >>>
> >> $ gmake
> >> Checking for a C compiler... found.
> >> Checking for libpci headers... found.
> >> Checking for libpci (method 1)... not found.
> >> Checking for dynamic libpci (method 2)... not found.
> >> not found.
> >>
> >> Please install libpci (package pciutils).
> >> See README for more information.
> >>
> >> unavailable.
> >>
> >> Please install libpci (package pciutils).
> >> See README for more information.
> >>
> >>
> >
> > Ouch. Turns out the patch had one error message too many, a missing
> > semicolon and missing LDFLAGS in some CC calls.
> > New version
> > .
> > Idwer reported problems with the current libpci check on
> > FreeBSD 8.0-RELEASE i386
> > This is caused by a strict linker. Parsing linker error messages is an
> > exercise in futility, so I implemented fallback library detection with
> > $CC --print-file-name.
> > This fallback may cause false positives/negatives on llvm-clang (llvm
> > bug 5137), but such machines hopefully have a more permissive linker and
> > will never hit that code path.
> > The fallback will be unreliable on NetBSD where we should look for
> > libpciutils instead, but that hopefully doesn't have a strict linker
> > either. A fix is easy (replace libpci with PCI_LIB_NAME), but outside
> > the scope of this patch.
> > Tested with error injection at various levels.
>
> Turns out that --print-file-name is totally useless for libraries
> outside the standard hardcoded builtin gcc search path. Oh well. Back to
> some really simple code which should even work. Nice benefit is that we
> use the correct libpci on NetBSD for the check.
>
> Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006 at gmx.net>
>

Acked-by: Idwer Vollering <vidwer at gmail.com>

>
> Index: flashrom-libpci_robust_detection/Makefile
> ===================================================================
> --- flashrom-libpci_robust_detection/Makefile   (Revision 964)
> +++ flashrom-libpci_robust_detection/Makefile   (Arbeitskopie)
> @@ -279,26 +279,17 @@
>                 echo "Please install libpci headers (package
> pciutils-devel)."; \
>                echo "See README for more information."; echo;
>    \
>                rm -f .test.c .test.o; exit 1)
> -       @printf "Checking for libpci... "
> -       @$(shell ( echo "#include <pci/pci.h>";            \
> -                  echo "int main(int argc, char **argv)"; \
> -                  echo "{ return 0; }"; ) > .test1.c )
> -       @$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) .test1.c -o .test1 -lpci
> $(LIBS) >/dev/null 2>&1 &&     \
> -               echo "found." || ( echo "not found."; echo;
>             \
> -               echo "Please install libpci (package pciutils).";
>             \
> -               echo "See README for more information."; echo;
>              \
> -               rm -f .test1.c .test1; exit 1)
> -       @printf "Checking if libpci is sufficient... "
> +       @printf "Checking if libpci is present and sufficient... "
>         @printf "" > .libdeps
> -       @$(CC) $(LDFLAGS) .test.o -o .test -lpci $(LIBS) >/dev/null 2>&1 &&
>                             \
> +       @$(CC) $(LDFLAGS) .test.o -o .test $(LIBS) >/dev/null 2>&1 &&
>                     \
>                echo "yes." || ( echo "no.";
>                    \
> -               printf "Checking if libz is present and supplies all needed
> symbols...";        \
> -               $(CC) $(LDFLAGS) .test.o -o .test -lpci -lz $(LIBS)
> >/dev/null 2>&1 &&          \
> +               printf "Checking if libz+libpci are present and
> sufficient..."; \
> +               $(CC) $(LDFLAGS) .test.o -o .test $(LIBS) -lz >/dev/null
> 2>&1 &&                \
>                ( echo "yes."; echo "NEEDLIBZ := yes" > .libdeps ) || ( echo
> "no."; echo;       \
> -               echo "Please install libz.";                    \
> +               echo "Please install libpci (package pciutils) and/or
> libz.";                   \
>                 echo "See README for more information."; echo;
>              \
>                 rm -f .test.c .test.o .test; exit 1) )
> -       @rm -f .test.c .test.o .test .test1.c .test1
> +       @rm -f .test.c .test.o .test
>  else
>  pciutils: compiler
>        @printf "" > .libdeps
>
>
> --
> "I do consider assignment statements and pointer variables to be among
> computer science's most valuable treasures."
> -- Donald E. Knuth
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.flashrom.org/pipermail/flashrom/attachments/20100322/bc714ce2/attachment.html>


More information about the flashrom mailing list