configure: improve multiarch support for pkgconfig
PATCH 1/1 configure: improve multiarch support for pkgconfig
This will improve the multi-arch compilation for hosts using gcc. configurations using clang won't see an improvement, but also won't see a regression.
--- configure | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
configure +14 -0
@@ -1759,6 +1759,20 @@ if ! has "$pkg_config_exe"; then fi ########################################## +# pkg-config multi-arch probe + +if $cc -print-multiarch >/dev/null 2>&1; then + mlibdir=$($cc -print-multiarch $QEMU_CFLAGS) +fi +if test -z "${mlibdir}"; then + mlibdir=$($cc --print-multi-os-directory $QEMU_CFLAGS) +fi + +if [ -n "${mlibdir}" ] && [ -d "/usr/lib/${mlibdir}/pkgconfig" ]; then + export PKG_CONFIG_LIBDIR="/usr/lib/${mlibdir}/pkgconfig" +fi + +########################################## # NPTL probe if test "$linux_user" = "yes"; then
Signature · 1 line
2.1.0
Quoted 19 lines · John Snow
This will improve the multi-arch compilation for hosts using gcc. configurations using clang won't see an improvement, but also won't see a regression.
Signed-off-by John Snow <[email protected]>--- configure | 14 ++++++++++++++ 1 file changed, 14 insertions(+)configure +2
-0@@ -1759,6 +1759,20 @@ if ! has "$pkg_config_exe"; then fi ########################################## +# pkg-config multi-arch probe +
configure if ! has "$pkg_config_exe"; then · line 1773
Quoted 10 lines
configure +10
-0+if $cc -print-multiarch >/dev/null 2>&1; then + mlibdir=$($cc -print-multiarch $QEMU_CFLAGS) +fi +if test -z "${mlibdir}"; then + mlibdir=$($cc --print-multi-os-directory $QEMU_CFLAGS) +fi + +if [ -n "${mlibdir}" ] && [ -d "/usr/lib/${mlibdir}/pkgconfig" ]; then + export PKG_CONFIG_LIBDIR="/usr/lib/${mlibdir}/pkgconfig" +fi
This is not enough. It doesn't work unfortunately for cross compilers.
I would replace the third "if" with something like:
orig_libdir=`$pkgconfig --variable pc_path pkg-config`
if [ -n "$orig_libdir" ]; then
export PKG_CONFIG_LIBDIR=$(echo $orig_libdir | sed \
-e "s,???/pkgconfig:,???/${mlibdir}/pkgconfig:," -e t \
-e "s,???/pkgconfig$,???/${mlibdir}/pkgconfig,g")
export PKG_CONFIG_LIBDIR
else
echo Some warning about an old version of pkg-config?
# proceed without setting PKG_CONFIG_LIBDIR then
fiThe ??? are because for multiarch you probably should match /lib/pkgconfig, but for multilib you cannot because it wouldn't match /usr/lib64/pkgconfig. So probably it needs two completely different sed invocations.
Paolo
Quoted 5 lines
configure +1
-0+########################################## # NPTL probe if test "$linux_user" = "yes"; then
Quoted 3 lines · John Snow
This will improve the multi-arch compilation for hosts using gcc. configurations using clang won't see an improvement, but also won't see a regression.
The commit description does not explain what this patch "improves". Please add this explanation (or something equivalent) when merging:
32-bit compilation on 64-bit hosts is broken because pkgconfig isn't multi-arch aware and selects the 64-bit glibconfig.h header file. That file assumes the LP64 data model so guint64 is defined as unsigned long. This does not work for 32-bit builds where sizeof(unsigned long) == 4 bytes.
This patch makes "./configure --extra-cflags=-m32" just work by pointing pkgconfig at the correct .pc files.
Quoted 18 lines
Signed-off-by John Snow <[email protected]>--- configure | 14 ++++++++++++++ 1 file changed, 14 insertions(+)configure +5
-0@@ -1759,6 +1759,20 @@ if ! has "$pkg_config_exe"; then fi ########################################## +# pkg-config multi-arch probe + +if $cc -print-multiarch >/dev/null 2>&1; then + mlibdir=$($cc -print-multiarch $QEMU_CFLAGS) +fi
configure if ! has "$pkg_config_exe"; then · line 1776
Quoted 10 lines
configure +9
-0+if test -z "${mlibdir}"; then + mlibdir=$($cc --print-multi-os-directory $QEMU_CFLAGS) +fi + +if [ -n "${mlibdir}" ] && [ -d "/usr/lib/${mlibdir}/pkgconfig" ]; then + export PKG_CONFIG_LIBDIR="/usr/lib/${mlibdir}/pkgconfig" +fi + +########################################## # NPTL probe
Quoted 5 lines · Stefan Hajnoczi
Quoted 3 lines · John Snow
This will improve the multi-arch compilation for hosts using gcc. configurations using clang won't see an improvement, but also won't see a regression.
Quoted 8 lines
The commit description does not explain what this patch "improves". Please add this explanation (or something equivalent) when merging:
32-bit compilation on 64-bit hosts is broken because pkgconfig isn't multi-arch aware and selects the 64-bit
glibconfig.hheader file. That file assumes the LP64 data model so guint64 is defined as unsigned long. This does not work for 32-bit builds where sizeof(unsigned long) == 4 bytes.
Is this actually a fix for multiarch (which is the Debian/Ubuntu approach where everything is split into /lib/i386-linux-gnu and /lib/x86_64-linux-gnu and so on) or for the RedHat setup with /lib and /lib64? (I forget the name of the latter, maybe multilib?)
-- PMM
Quoted 15 lines · Peter Maydell
Quoted 5 lines · Stefan Hajnoczi
Quoted 3 lines · John Snow
This will improve the multi-arch compilation for hosts using gcc. configurations using clang won't see an improvement, but also won't see a regression.
Quoted 8 lines
The commit description does not explain what this patch "improves". Please add this explanation (or something equivalent) when merging:
32-bit compilation on 64-bit hosts is broken because pkgconfig isn't multi-arch aware and selects the 64-bit
glibconfig.hheader file. That file assumes the LP64 data model so guint64 is defined as unsigned long. This does not work for 32-bit builds where sizeof(unsigned long) == 4 bytes.
Quoted 7 lines
Is this actually a fix for multiarch (which is the Debian/Ubuntu approach where everything is split into
/lib/i386-linux-gnuand/lib/x86_64-linux-gnuand so on) or for the RedHat setup with /lib and /lib64? (I forget the name of the latter, maybe multilib?)-- PMM
It should apply to both, AFAIK. (Testing welcome ...!)
I wasn't very confident with the fix (I've been sitting on it for a while ...), but there's some good feedback, so I'll respin.
Thanks everyone.
--js
Hi,
Quoted 5 lines
32-bit compilation on 64-bit hosts is broken because pkgconfig isn't multi-arch aware and selects the 64-bit
glibconfig.hheader file. That file assumes the LP64 data model so guint64 is defined as unsigned long. This does not work for 32-bit builds where sizeof(unsigned long) == 4 bytes.
... there are more effects, like stuff being enabled because 64bit devel lib is installed even when the 32bit devel lib isn't.
IMO it is fine to expect users set PKG_CONFIG_LIBDIR accordingly in that case. It would be very nice though to record this variable (in config.status maybe?) so it doesn't get lost in case make figures it should re-run configure because it was changed.
cheers,
Gerd
Quoted 8 lines · Gerd Hoffmann
Hi,Quoted 5 lines
32-bit compilation on 64-bit hosts is broken because pkgconfig isn't multi-arch aware and selects the 64-bit
glibconfig.hheader file. That file assumes the LP64 data model so guint64 is defined as unsigned long. This does not work for 32-bit builds where sizeof(unsigned long) == 4 bytes.
Quoted 8 lines
... there are more effects, like stuff being enabled because 64bit devel lib is installed even when the 32bit devel lib isn't.
IMO it is fine to expect users set
PKG_CONFIG_LIBDIRaccordingly in that case. It would be very nice though to record this variable (in config.status maybe?) so it doesn't get lost in case make figures it should re-run configure because it was changed.
I'm not sure I follow you. What would be wrong with configure re-polling for the correct setting in that case?
Unless, perhaps, you are discussing the possibility of losing a user override from the first time they ran configure with PKG_CONFIG_LIBDIR already set to some custom value.
Quoted 4 lines
cheers,
Gerd
Quoted 19 lines · John Snow
Quoted 8 lines · Gerd Hoffmann
Hi,Quoted 5 lines
32-bit compilation on 64-bit hosts is broken because pkgconfig isn't multi-arch aware and selects the 64-bit
glibconfig.hheader file. That file assumes the LP64 data model so guint64 is defined as unsigned long. This does not work for 32-bit builds where sizeof(unsigned long) == 4 bytes.Quoted 8 lines
... there are more effects, like stuff being enabled because 64bit devel lib is installed even when the 32bit devel lib isn't.
IMO it is fine to expect users set
PKG_CONFIG_LIBDIRaccordingly in that case. It would be very nice though to record this variable (in config.status maybe?) so it doesn't get lost in case make figures it should re-run configure because it was changed.
Quoted 6 lines
I'm not sure I follow you. What would be wrong with configure re-polling for the correct setting in that case?
Unless, perhaps, you are discussing the possibility of losing a user override from the first time they ran configure with
PKG_CONFIG_LIBDIRalready set to some custom value.
Yes, we lose a user override of PKG_CONFIG_LIBDIR today. We should not. Fixing that makes -m32 builds alot less painful already.
Trying to automatically set PKG_CONFIG_LIBDIR correctly for -m32 (but as paolo already mentioned only in case it isn't set already) would be sugar on top, no objections to that, but IMO we should get the basics right first.
cheers,
Gerd
Quoted 19 lines · John Snow
This will improve the multi-arch compilation for hosts using gcc. configurations using clang won't see an improvement, but also won't see a regression.
Signed-off-by John Snow <[email protected]>--- configure | 14 ++++++++++++++ 1 file changed, 14 insertions(+)configure +2
-0@@ -1759,6 +1759,20 @@ if ! has "$pkg_config_exe"; then fi ########################################## +# pkg-config multi-arch probe +
configure if ! has "$pkg_config_exe"; then · line 1773
Quoted 10 lines
configure +10
-0+if $cc -print-multiarch >/dev/null 2>&1; then + mlibdir=$($cc -print-multiarch $QEMU_CFLAGS) +fi +if test -z "${mlibdir}"; then + mlibdir=$($cc --print-multi-os-directory $QEMU_CFLAGS) +fi + +if [ -n "${mlibdir}" ] && [ -d "/usr/lib/${mlibdir}/pkgconfig" ]; then + export PKG_CONFIG_LIBDIR="/usr/lib/${mlibdir}/pkgconfig" +fi
IIUC, this overrides any setting of PKG_CONFIG_LIBDIR that the developer may have set themselves before running configure. Please only set this, if PKG_CONFIG_LIBDIR is not already present in the environment.
Regards,
Daniel
Signature · 4 lines
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|