diff mbox series

configure: Save PKG_CONFIG_LIBDIR and WINDRES in config.status

Message ID 1536044538-22507-1-git-send-email-thuth@redhat.com
State New
Headers show
Series configure: Save PKG_CONFIG_LIBDIR and WINDRES in config.status | expand

Commit Message

Thomas Huth Sept. 4, 2018, 7:02 a.m. UTC
When cross-compiling QEMU for a target that significantly differs from
the host, the current information in config.status is not enough to
properly re-create the configuration. For example when I try to test
my build with the mingw32 cross-compiler, I regularly get this error
after the build system tried to re-create the configuration with the
config.status file:

ERROR: sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T.
       You probably need to set PKG_CONFIG_LIBDIR
       to point to the right pkg-config files for your
       build target

A similar problem exists for the "windres" tool, where you have to
set the WINDRES variable in case it has a different name.
So let's fix these issues by storing the configuration for these
variables in the config.status file, too.

Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 configure | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Peter Maydell Sept. 4, 2018, 10:35 a.m. UTC | #1
On 4 September 2018 at 08:02, Thomas Huth <thuth@redhat.com> wrote:
> When cross-compiling QEMU for a target that significantly differs from
> the host, the current information in config.status is not enough to
> properly re-create the configuration. For example when I try to test
> my build with the mingw32 cross-compiler, I regularly get this error
> after the build system tried to re-create the configuration with the
> config.status file:
>
> ERROR: sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T.
>        You probably need to set PKG_CONFIG_LIBDIR
>        to point to the right pkg-config files for your
>        build target
>RAND
> A similar problem exists for the "windres" tool, where you have to
> set the WINDRES variable in case it has a different name.
> So let's fix these issues by storing the configuration for theseq
> variables in the config.status file, too.

This is also true if the user set CC or RANLIB or any of a bunch
of other environment variables that configure uses. If we're going
to store those settings in config.status we should consistently
do it for all environment variables we care about, I think.

What does autoconf do for the equivalent situation?

thanks
-- PMM
Daniel P. Berrangé Sept. 4, 2018, 10:43 a.m. UTC | #2
On Tue, Sep 04, 2018 at 09:02:18AM +0200, Thomas Huth wrote:
> When cross-compiling QEMU for a target that significantly differs from
> the host, the current information in config.status is not enough to
> properly re-create the configuration. For example when I try to test
> my build with the mingw32 cross-compiler, I regularly get this error
> after the build system tried to re-create the configuration with the
> config.status file:
> 
> ERROR: sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T.
>        You probably need to set PKG_CONFIG_LIBDIR
>        to point to the right pkg-config files for your
>        build target
> 
> A similar problem exists for the "windres" tool, where you have to
> set the WINDRES variable in case it has a different name.
> So let's fix these issues by storing the configuration for these
> variables in the config.status file, too.

Doh, I sent a patch to fix this problem more broadly years ago now:

  https://lists.nongnu.org/archive/html/qemu-devel/2015-11/msg04157.html

but it appears no maintainer ever merged it !

> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  configure | 6 ++++++
>  1 file changed, 6 insertions(+)
> 
> diff --git a/configure b/configure
> index 58862d2..4d8888f 100755
> --- a/configure
> +++ b/configure
> @@ -7534,6 +7534,12 @@ cat <<EOD >config.status
>  # Compiler output produced by configure, useful for debugging
>  # configure, is in config.log if it exists.
>  EOD
> +if [ -n "$PKG_CONFIG_LIBDIR" ]; then
> +    echo "export PKG_CONFIG_LIBDIR=\"$PKG_CONFIG_LIBDIR\"" >>config.status
> +fi
> +if [ -n "$WINDRES" ]; then
> +    echo "export WINDRES=\"$WINDRES\"" >>config.status
> +fi
>  printf "exec" >>config.status
>  printf " '%s'" "$0" "$@" >>config.status
>  echo ' "$@"' >>config.status

Regards,
Daniel
Thomas Huth Sept. 4, 2018, 10:53 a.m. UTC | #3
On 2018-09-04 12:35, Peter Maydell wrote:
> On 4 September 2018 at 08:02, Thomas Huth <thuth@redhat.com> wrote:
>> When cross-compiling QEMU for a target that significantly differs from
>> the host, the current information in config.status is not enough to
>> properly re-create the configuration. For example when I try to test
>> my build with the mingw32 cross-compiler, I regularly get this error
>> after the build system tried to re-create the configuration with the
>> config.status file:
>>
>> ERROR: sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T.
>>        You probably need to set PKG_CONFIG_LIBDIR
>>        to point to the right pkg-config files for your
>>        build target
>> RAND
>> A similar problem exists for the "windres" tool, where you have to
>> set the WINDRES variable in case it has a different name.
>> So let's fix these issues by storing the configuration for theseq
>> variables in the config.status file, too.
> 
> This is also true if the user set CC or RANLIB or any of a bunch
> of other environment variables that configure uses. If we're going
> to store those settings in config.status we should consistently
> do it for all environment variables we care about, I think.

Ok, never mind, forget about WINDRES (and the other tools like RANLIB),
that's not required, I just noticed that I simply forgot to specify
"--cross-prefix=i686-w64-mingw32-" when running configure. With that
option, i686-w64-mingw32-windres is properly used, and the pkg-config
problem also goes away since i686-w64-mingw32-pkg-config is used instead.

But still, I think at least the PKG_CONFIG_LIBDIR part could be useful,
since the same problem e.g. also occurs when trying do a 32-bit build on
a 64-bit host, i.e. when running configure with "--extra-cflags=-m32".
Or is there also another configure switch that can help to get
PKG_CONFIG_LIBDIR right here?

 Thomas
Thomas Huth Sept. 4, 2018, 10:58 a.m. UTC | #4
On 2018-09-04 12:43, Daniel P. Berrangé wrote:
> On Tue, Sep 04, 2018 at 09:02:18AM +0200, Thomas Huth wrote:
>> When cross-compiling QEMU for a target that significantly differs from
>> the host, the current information in config.status is not enough to
>> properly re-create the configuration. For example when I try to test
>> my build with the mingw32 cross-compiler, I regularly get this error
>> after the build system tried to re-create the configuration with the
>> config.status file:
>>
>> ERROR: sizeof(size_t) doesn't match GLIB_SIZEOF_SIZE_T.
>>        You probably need to set PKG_CONFIG_LIBDIR
>>        to point to the right pkg-config files for your
>>        build target
>>
>> A similar problem exists for the "windres" tool, where you have to
>> set the WINDRES variable in case it has a different name.
>> So let's fix these issues by storing the configuration for these
>> variables in the config.status file, too.
> 
> Doh, I sent a patch to fix this problem more broadly years ago now:
> 
>   https://lists.nongnu.org/archive/html/qemu-devel/2015-11/msg04157.html
> 
> but it appears no maintainer ever merged it !

This certainly eases some configurations ... could you refresh the patch
and post it again?

 Thomas
Peter Maydell Sept. 4, 2018, 12:12 p.m. UTC | #5
On 4 September 2018 at 11:53, Thomas Huth <thuth@redhat.com> wrote:
> But still, I think at least the PKG_CONFIG_LIBDIR part could be useful,
> since the same problem e.g. also occurs when trying do a 32-bit build on
> a 64-bit host, i.e. when running configure with "--extra-cflags=-m32".
> Or is there also another configure switch that can help to get
> PKG_CONFIG_LIBDIR right here?

Personally I think the neatest way to handle 32-bit-build-on-64-bit-host
is to treat it like any other non-native build, ie have the distro
ship compiler, pkg-config, etc so that --cross-prefix=i686-linux-gnu-
works :-)

thanks
-- PMM
diff mbox series

Patch

diff --git a/configure b/configure
index 58862d2..4d8888f 100755
--- a/configure
+++ b/configure
@@ -7534,6 +7534,12 @@  cat <<EOD >config.status
 # Compiler output produced by configure, useful for debugging
 # configure, is in config.log if it exists.
 EOD
+if [ -n "$PKG_CONFIG_LIBDIR" ]; then
+    echo "export PKG_CONFIG_LIBDIR=\"$PKG_CONFIG_LIBDIR\"" >>config.status
+fi
+if [ -n "$WINDRES" ]; then
+    echo "export WINDRES=\"$WINDRES\"" >>config.status
+fi
 printf "exec" >>config.status
 printf " '%s'" "$0" "$@" >>config.status
 echo ' "$@"' >>config.status