[PATCH] PKG_CHECK_MODULES: Properly check if $pkg_cv_[]$1[]_LIBS works

H.J. Lu hjl.tools@gmail.com
Tue Jul 28 13:27:25 GMT 2020


On Tue, Jul 28, 2020 at 5:54 AM Mark Wielaard <mark@klomp.org> wrote:
>
> Hi,
>
> On Mon, 2020-07-27 at 12:32 -0700, H.J. Lu via Binutils wrote:
> > diff --git a/config/pkg.m4 b/config/pkg.m4
> > index 13a8890178..45587e97c8 100644
> > --- a/config/pkg.m4
> > +++ b/config/pkg.m4
> > @@ -147,6 +147,12 @@ AC_MSG_CHECKING([for $2])
> >  _PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
> >  _PKG_CONFIG([$1][_LIBS], [libs], [$2])
> >
> > +dnl Check whether $pkg_cv_[]$1[]_LIBS works.
> > +pkg_save_LDFLAGS="$LDFLAGS"
> > +LDFLAGS="$LDFLAGS $pkg_cv_[]$1[]_LIBS"
> > +AC_TRY_LINK([],[return 0;], [pkg_failed=no], [pkg_failed=yes])
> > +LDFLAGS=$pkg_save_LDFLAGS
> > +
> >  m4_define([_PKG_TEXT], [Alternatively, you may set the environment
> > variables $1[]_CFLAGS
> >  and $1[]_LIBS to avoid the need to call pkg-config.
> >  See the pkg-config man page for more details.])
>
> This hunk seems wrong. You are testing whether the $pkg_cv_[]$1[]_LIBS
> flags work, but they might be empty if the library wasn't found
> (pkg_failed=yes). Then the AC_TRY_LINK will obviously succeed, and then
> you set pkg_failed=no. But that indicates that the library was found.
>

This fixes it.

Thanks.

-- 
H.J.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-PKG_CHECK_MODULES-Properly-check-if-pkg_cv_-1-_LIBS-.patch
Type: text/x-patch
Size: 3036 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/binutils/attachments/20200728/edd9ca1f/attachment-0001.bin>


More information about the Binutils mailing list