Bug 102613 - autotools build system could not find expat without pkg-config support on mingw
Summary: autotools build system could not find expat without pkg-config support on mingw
Status: RESOLVED NOTOURBUG
Alias: None
Product: dbus
Classification: Unclassified
Component: core (show other bugs)
Version: git master
Hardware: Other All
: medium normal
Assignee: D-Bus Maintainers
QA Contact: D-Bus Maintainers
URL:
Whiteboard:
Keywords:
Depends on:
Blocks: 102558
  Show dependency treegraph
 
Reported: 2017-09-08 09:04 UTC by Ralf Habacker
Modified: 2017-09-22 19:57 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
build log (67.67 KB, text/plain)
2017-09-08 09:04 UTC, Ralf Habacker
Details
patch (722 bytes, patch)
2017-09-08 09:06 UTC, Ralf Habacker
Details | Splinter Review

Description Ralf Habacker 2017-09-08 09:04:49 UTC
Created attachment 134076 [details]
build log

Trying to cross build git master branch with autotools for mingw fails with the following message: 

[   12s] checking for EXPAT... configure: error: Package requirements (expat) were not met:
[   12s] 
[   12s] No package 'expat' found
[   12s] 
[   12s] Consider adjusting the PKG_CONFIG_PATH environment variable if you
[   12s] installed software in a non-standard prefix.

Building dbus-1.10 with the same environment does not have this issue.

[   12s] Alternatively, you may set the environment variables EXPAT_CFLAGS
[   12s] and EXPAT_LIBS to avoid the need to call pkg-config.
[   12s] See the pkg-config man page for more details.

Because mingw32-expat package does not support pkg-config I set

export EXPAT_CFLAGS=
export EXPAT_LIBS='-L/usr/i686-w64-mingw32/sys-root/mingw/lib -lexpat'

and tried to rebuild with 

 ../dbus-1/configure --cache-file=mingw32-config.cache --host=i686-w64-mingw32 --build=x86_64-suse-linux-gnu --target=i686-w64-mingw32 --prefix=/usr/i686-w64-mingw32/sys-root/mingw --exec-prefix=/usr/i686-w64-mingw32/sys-root/mingw --bindir=/usr/i686-w64-mingw32/sys-root/mingw/bin --sbindir=/usr/i686-w64-mingw32/sys-root/mingw/sbin --sysconfdir=/usr/i686-w64-mingw32/sys-root/mingw/etc --datadir=/usr/i686-w64-mingw32/sys-root/mingw/share --includedir=/usr/i686-w64-mingw32/sys-root/mingw/include --libdir=/usr/i686-w64-mingw32/sys-root/mingw/lib --libexecdir=/usr/i686-w64-mingw32/sys-root/mingw/libexec --localstatedir=/usr/i686-w64-mingw32/sys-root/mingw/var --sharedstatedir=/usr/i686-w64-mingw32/sys-root/mingw/com --mandir=/usr/i686-w64-mingw32/sys-root/mingw/share/man --infodir=/usr/i686-w64-mingw32/sys-root/mingw/share/info --enable-maintainer-mode --disable-static --enable-verbose-mode --enable-embedded-tests --enable-checks --enable-asserts --disable-xml-docs --disable-doxygen-docs '--with-dbus-session-bus-listen-address=autolaunch:scope=*install-path' '--with-dbus-session-bus-connect-address=autolaunch:scope=*install-path;autolaunch:'

which fails too. Appended build log is from https://build.opensuse.org/package/show/home:rhabacker:branches:windows:mingw:win32:personal/mingw32-dbus-1 repository openSUSE_Leap_42.2
Comment 1 Ralf Habacker 2017-09-08 09:06:01 UTC
Created attachment 134077 [details] [review]
patch
Comment 2 Simon McVittie 2017-09-08 11:31:52 UTC
(In reply to Ralf Habacker from comment #0)
> [   12s] Alternatively, you may set the environment variables EXPAT_CFLAGS
> [   12s] and EXPAT_LIBS to avoid the need to call pkg-config.
> [   12s] See the pkg-config man page for more details.

This is arguably a bug in the pkg-config macros, although it's easy to work around. The pkg-config macro does this:

if test -n "$EXPAT_CFLAGS"; then
    pkg_cv_EXPAT_CFLAGS="$EXPAT_CFLAGS"
 elif test -n "$PKG_CONFIG"; then
...

if test -n "$EXPAT_LIBS"; then
    pkg_cv_EXPAT_LIBS="$EXPAT_LIBS"
 elif test -n "$PKG_CONFIG"; then
...

where arguably it should be using 'if test -n "${EXPAT_CFLAGS+set}"' so that it is distinguishing between set vs. unset, rather than between (set && non-empty) vs. (unset || empty).

In your case this logic fails because EXPAT_CFLAGS is set, but happens to be set to an empty value.

Please try setting EXPAT_CFLAGS to a value that is non-empty but will otherwise have no effect:

export EXPAT_CFLAGS=' '
export EXPAT_LIBS='-L/usr/i686-w64-mingw32/sys-root/mingw/lib -lexpat'

or give it a non-trivial CFLAG:

export EXPAT_CFLAGS='-I/usr/i686-w64-mingw32/sys-root/mingw/include'
export EXPAT_LIBS='-L/usr/i686-w64-mingw32/sys-root/mingw/lib -lexpat'
Comment 3 Simon McVittie 2017-09-08 11:38:08 UTC
Comment on attachment 134077 [details] [review]
patch

Review of attachment 134077 [details] [review]:
-----------------------------------------------------------------

I would prefer not to be working around pkg-config in our build system like this. We should aim for our use of build toolchain stuff like pkg-config to be as "boring and ordinary" as possible. We should either fix the pkg-config issue in pkg-config itself, or raise the workaround up a level into your spec file or equivalent so it's done in a way that would work equally for any pkg-config-using module. (Or both.)

If we do work around it like this, it should be using AS_IF instead of plain shell if, and the commit message should explain what we're working around. But, again, I'd prefer not to.
Comment 4 Simon McVittie 2017-09-08 11:42:55 UTC
(In reply to Ralf Habacker from comment #0)
> Because mingw32-expat package does not support pkg-config

That's a shame. If it doesn't install a pkg-config .pc file to /usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig or similar, please report that to the publisher of your mingw32-expat package as a bug. Expat added pkg-config metadata in version 2.1.0 (2012!) so it's not like this is something new...

From your log it looks like you're already doing the right things to make pkg-config search /usr/i686-w64-mingw32/sys-root/mingw/lib/pkgconfig and /usr/i686-w64-mingw32/sys-root/mingw/share/pkgconfig.
Comment 5 Simon McVittie 2017-09-08 11:51:41 UTC
(In reply to Simon McVittie from comment #2)
> This is arguably a bug in the pkg-config macros

Bug #102622
Comment 6 Ralf Habacker 2017-09-09 00:57:56 UTC
(In reply to Simon McVittie from comment #4)

> Expat added pkg-config metadata in version 2.1.0 (2012!) so it's 
> not like this is something new...
Recent mingw32-expat packages is version 2.0.1 (https://build.opensuse.org/package/show/windows:mingw:win32/mingw32-expat), which explains missing pkg-config support.
Comment 7 Simon McVittie 2017-09-11 12:18:01 UTC
(In reply to Ralf Habacker from comment #6)
> Recent mingw32-expat packages is version 2.0.1
> (https://build.opensuse.org/package/show/windows:mingw:win32/mingw32-expat),
> which explains missing pkg-config support.

That version is over 10 years old. Please talk to its maintainer about updating it. It doesn't seem to include any security patches, which means it suffers from CVE-2009-3720, CVE-2009-3560, CVE-2012-0876, CVE-2012-1147, CVE-2012-1148, CVE-2015-1283, CVE-2016-0718, CVE-2016-4472, CVE-2016-5300, CVE-2012-6702, CVE-2017-9233, CVE-2016-9063, CVE-2017-11742 and 10 years' worth of non-CVE bugs.

(These are probably not relevant to dbus' use of expat, because we only use expat to parse trusted configuration files - but other users of expat are likely to be vulnerable.)
Comment 8 Ralf Habacker 2017-09-22 13:01:49 UTC
(In reply to Simon McVittie from comment #7)
> (In reply to Ralf Habacker from comment #6)
> > Recent mingw32-expat packages is version 2.0.1
> > (https://build.opensuse.org/package/show/windows:mingw:win32/mingw32-expat),
> > which explains missing pkg-config support.
> 
> That version is over 10 years old. Please talk to its maintainer about
> updating it. 

Thanks for this pointer, the above mentioned package has been updated to 2.2.4.
Comment 9 Simon McVittie 2017-09-22 19:57:32 UTC
I think this is NOTOURBUG, then. possible solutions: use a more modern expat; or solve Bug #102622 in pkg-config and use the documented EXPAT_CFLAGS= EXPAT_LIBS=-lexpat; or work around Bug #102622 with EXPAT_CFLAGS=" " EXPAT_LIBS=lexpat.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.