qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] configure: Fix error message when C compiler is not working
@ 2024-03-08  6:00 Thomas Huth
  2024-03-08 11:26 ` Peter Maydell
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Thomas Huth @ 2024-03-08  6:00 UTC (permalink / raw)
  To: Paolo Bonzini, Alex Bennée, qemu-devel; +Cc: qemu-stable

If you try to run the configure script on a system without a working
C compiler, you get a very misleading error message:

 ERROR: Unrecognized host OS (uname -s reports 'Linux')

We should rather tell the user that we were not able to use the C
compiler instead, otherwise they will have a hard time to figure
out what was going wrong.

Fixes: 264b803721 ("configure: remove compiler sanity check")
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 configure | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 3cd736b139..a036923dee 100755
--- a/configure
+++ b/configure
@@ -411,7 +411,7 @@ else
   # Using uname is really broken, but it is just a fallback for architectures
   # that are going to use TCI anyway
   cpu=$(uname -m)
-  echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'"
+  echo "WARNING: could not determine host CPU, proceeding with 'uname -m' output '$cpu'"
 fi
 
 # Normalise host CPU name to the values used by Meson cross files and in source
@@ -1000,10 +1000,12 @@ if test -z "$ninja"; then
 fi
 
 if test "$host_os" = "bogus"; then
-    # Now that we know that we're not printing the help and that
-    # the compiler works (so the results of the check_defines we used
-    # to identify the OS are reliable), if we didn't recognize the
-    # host OS we should stop now.
+    # Now that we know that we're not printing the help, we should stop now
+    # if we didn't recognize the host OS (or the C compiler is not working).
+    write_c_skeleton;
+    if ! compile_object ; then
+        error_exit "C compiler \"$cc\" is not usable"
+    fi
     error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
 fi
 
-- 
2.44.0



^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH] configure: Fix error message when C compiler is not working
  2024-03-08  6:00 [PATCH] configure: Fix error message when C compiler is not working Thomas Huth
@ 2024-03-08 11:26 ` Peter Maydell
  2024-03-08 11:32   ` Thomas Huth
  2024-03-18 16:08 ` Thomas Huth
  2024-03-19 13:12 ` Peter Maydell
  2 siblings, 1 reply; 7+ messages in thread
From: Peter Maydell @ 2024-03-08 11:26 UTC (permalink / raw)
  To: Thomas Huth; +Cc: Paolo Bonzini, Alex Bennée, qemu-devel, qemu-stable

On Fri, 8 Mar 2024 at 06:01, Thomas Huth <thuth@redhat.com> wrote:
>
> If you try to run the configure script on a system without a working
> C compiler, you get a very misleading error message:
>
>  ERROR: Unrecognized host OS (uname -s reports 'Linux')
>
> We should rather tell the user that we were not able to use the C
> compiler instead, otherwise they will have a hard time to figure
> out what was going wrong.
>
> Fixes: 264b803721 ("configure: remove compiler sanity check")
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  configure | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/configure b/configure
> index 3cd736b139..a036923dee 100755
> --- a/configure
> +++ b/configure
> @@ -411,7 +411,7 @@ else
>    # Using uname is really broken, but it is just a fallback for architectures
>    # that are going to use TCI anyway
>    cpu=$(uname -m)
> -  echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'"
> +  echo "WARNING: could not determine host CPU, proceeding with 'uname -m' output '$cpu'"
>  fi
>
>  # Normalise host CPU name to the values used by Meson cross files and in source
> @@ -1000,10 +1000,12 @@ if test -z "$ninja"; then
>  fi
>
>  if test "$host_os" = "bogus"; then
> -    # Now that we know that we're not printing the help and that
> -    # the compiler works (so the results of the check_defines we used
> -    # to identify the OS are reliable), if we didn't recognize the
> -    # host OS we should stop now.
> +    # Now that we know that we're not printing the help, we should stop now
> +    # if we didn't recognize the host OS (or the C compiler is not working).
> +    write_c_skeleton;
> +    if ! compile_object ; then
> +        error_exit "C compiler \"$cc\" is not usable"
> +    fi
>      error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
>  fi

Why doesn't it work to check the C compiler works before we
do the "what is the host CPU" test ? Does that make the
--help output not work when there's no C compiler?

thanks
-- PMM


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] configure: Fix error message when C compiler is not working
  2024-03-08 11:26 ` Peter Maydell
@ 2024-03-08 11:32   ` Thomas Huth
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas Huth @ 2024-03-08 11:32 UTC (permalink / raw)
  To: Peter Maydell; +Cc: Paolo Bonzini, Alex Bennée, qemu-devel, qemu-stable

On 08/03/2024 12.26, Peter Maydell wrote:
> On Fri, 8 Mar 2024 at 06:01, Thomas Huth <thuth@redhat.com> wrote:
>>
>> If you try to run the configure script on a system without a working
>> C compiler, you get a very misleading error message:
>>
>>   ERROR: Unrecognized host OS (uname -s reports 'Linux')
>>
>> We should rather tell the user that we were not able to use the C
>> compiler instead, otherwise they will have a hard time to figure
>> out what was going wrong.
>>
>> Fixes: 264b803721 ("configure: remove compiler sanity check")
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>>   configure | 12 +++++++-----
>>   1 file changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 3cd736b139..a036923dee 100755
>> --- a/configure
>> +++ b/configure
>> @@ -411,7 +411,7 @@ else
>>     # Using uname is really broken, but it is just a fallback for architectures
>>     # that are going to use TCI anyway
>>     cpu=$(uname -m)
>> -  echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'"
>> +  echo "WARNING: could not determine host CPU, proceeding with 'uname -m' output '$cpu'"
>>   fi
>>
>>   # Normalise host CPU name to the values used by Meson cross files and in source
>> @@ -1000,10 +1000,12 @@ if test -z "$ninja"; then
>>   fi
>>
>>   if test "$host_os" = "bogus"; then
>> -    # Now that we know that we're not printing the help and that
>> -    # the compiler works (so the results of the check_defines we used
>> -    # to identify the OS are reliable), if we didn't recognize the
>> -    # host OS we should stop now.
>> +    # Now that we know that we're not printing the help, we should stop now
>> +    # if we didn't recognize the host OS (or the C compiler is not working).
>> +    write_c_skeleton;
>> +    if ! compile_object ; then
>> +        error_exit "C compiler \"$cc\" is not usable"
>> +    fi
>>       error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
>>   fi
> 
> Why doesn't it work to check the C compiler works before we
> do the "what is the host CPU" test ? Does that make the
> --help output not work when there's no C compiler?

Right, that's the problem: --help would not work when there is no working C 
compiler.

  Thomas




^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] configure: Fix error message when C compiler is not working
  2024-03-08  6:00 [PATCH] configure: Fix error message when C compiler is not working Thomas Huth
  2024-03-08 11:26 ` Peter Maydell
@ 2024-03-18 16:08 ` Thomas Huth
  2024-03-19 13:12 ` Peter Maydell
  2 siblings, 0 replies; 7+ messages in thread
From: Thomas Huth @ 2024-03-18 16:08 UTC (permalink / raw)
  To: Paolo Bonzini, Alex Bennée, qemu-devel
  Cc: qemu-stable, Philippe Mathieu-Daudé

On 08/03/2024 07.00, Thomas Huth wrote:
> If you try to run the configure script on a system without a working
> C compiler, you get a very misleading error message:
> 
>   ERROR: Unrecognized host OS (uname -s reports 'Linux')
> 
> We should rather tell the user that we were not able to use the C
> compiler instead, otherwise they will have a hard time to figure
> out what was going wrong.
> 
> Fixes: 264b803721 ("configure: remove compiler sanity check")
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>   configure | 12 +++++++-----
>   1 file changed, 7 insertions(+), 5 deletions(-)
> 
> diff --git a/configure b/configure
> index 3cd736b139..a036923dee 100755
> --- a/configure
> +++ b/configure
> @@ -411,7 +411,7 @@ else
>     # Using uname is really broken, but it is just a fallback for architectures
>     # that are going to use TCI anyway
>     cpu=$(uname -m)
> -  echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'"
> +  echo "WARNING: could not determine host CPU, proceeding with 'uname -m' output '$cpu'"
>   fi
>   
>   # Normalise host CPU name to the values used by Meson cross files and in source
> @@ -1000,10 +1000,12 @@ if test -z "$ninja"; then
>   fi
>   
>   if test "$host_os" = "bogus"; then
> -    # Now that we know that we're not printing the help and that
> -    # the compiler works (so the results of the check_defines we used
> -    # to identify the OS are reliable), if we didn't recognize the
> -    # host OS we should stop now.
> +    # Now that we know that we're not printing the help, we should stop now
> +    # if we didn't recognize the host OS (or the C compiler is not working).
> +    write_c_skeleton;
> +    if ! compile_object ; then
> +        error_exit "C compiler \"$cc\" is not usable"
> +    fi
>       error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
>   fi
>   

*Ping*

Does anybody got some spare minutes to review this? I think it would be nice 
to fix the error message for the 9.0 release...

  Thanks,
   Thomas



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] configure: Fix error message when C compiler is not working
  2024-03-08  6:00 [PATCH] configure: Fix error message when C compiler is not working Thomas Huth
  2024-03-08 11:26 ` Peter Maydell
  2024-03-18 16:08 ` Thomas Huth
@ 2024-03-19 13:12 ` Peter Maydell
  2024-03-20 14:38   ` Thomas Huth
  2 siblings, 1 reply; 7+ messages in thread
From: Peter Maydell @ 2024-03-19 13:12 UTC (permalink / raw)
  To: Thomas Huth; +Cc: Paolo Bonzini, Alex Bennée, qemu-devel, qemu-stable

On Fri, 8 Mar 2024 at 06:01, Thomas Huth <thuth@redhat.com> wrote:
>
> If you try to run the configure script on a system without a working
> C compiler, you get a very misleading error message:
>
>  ERROR: Unrecognized host OS (uname -s reports 'Linux')
>
> We should rather tell the user that we were not able to use the C
> compiler instead, otherwise they will have a hard time to figure
> out what was going wrong.
>
> Fixes: 264b803721 ("configure: remove compiler sanity check")
> Signed-off-by: Thomas Huth <thuth@redhat.com>
> ---
>  configure | 12 +++++++-----
>  1 file changed, 7 insertions(+), 5 deletions(-)
>
> diff --git a/configure b/configure
> index 3cd736b139..a036923dee 100755
> --- a/configure
> +++ b/configure
> @@ -411,7 +411,7 @@ else
>    # Using uname is really broken, but it is just a fallback for architectures
>    # that are going to use TCI anyway
>    cpu=$(uname -m)
> -  echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'"
> +  echo "WARNING: could not determine host CPU, proceeding with 'uname -m' output '$cpu'"
>  fi
>
>  # Normalise host CPU name to the values used by Meson cross files and in source
> @@ -1000,10 +1000,12 @@ if test -z "$ninja"; then
>  fi
>
>  if test "$host_os" = "bogus"; then
> -    # Now that we know that we're not printing the help and that
> -    # the compiler works (so the results of the check_defines we used
> -    # to identify the OS are reliable), if we didn't recognize the
> -    # host OS we should stop now.
> +    # Now that we know that we're not printing the help, we should stop now
> +    # if we didn't recognize the host OS (or the C compiler is not working).
> +    write_c_skeleton;
> +    if ! compile_object ; then
> +        error_exit "C compiler \"$cc\" is not usable"
> +    fi
>      error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
>  fi

I think I would prefer as a structure:

(1) suppress the "unrecognized host CPU" message if "$host_os" == "bogus"
(2) do the "check the C compiler works" test as its own test immediately
    after we print the help message (and not guarded by testing $host_os)
(3) leave the "Unrecognized host OS" check code as it is

thanks
-- PMM


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] configure: Fix error message when C compiler is not working
  2024-03-19 13:12 ` Peter Maydell
@ 2024-03-20 14:38   ` Thomas Huth
  2024-03-20 14:47     ` Peter Maydell
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas Huth @ 2024-03-20 14:38 UTC (permalink / raw)
  To: Peter Maydell, Paolo Bonzini, qemu-devel; +Cc: Alex Bennée, qemu-stable

On 19/03/2024 14.12, Peter Maydell wrote:
> On Fri, 8 Mar 2024 at 06:01, Thomas Huth <thuth@redhat.com> wrote:
>>
>> If you try to run the configure script on a system without a working
>> C compiler, you get a very misleading error message:
>>
>>   ERROR: Unrecognized host OS (uname -s reports 'Linux')
>>
>> We should rather tell the user that we were not able to use the C
>> compiler instead, otherwise they will have a hard time to figure
>> out what was going wrong.
>>
>> Fixes: 264b803721 ("configure: remove compiler sanity check")
>> Signed-off-by: Thomas Huth <thuth@redhat.com>
>> ---
>>   configure | 12 +++++++-----
>>   1 file changed, 7 insertions(+), 5 deletions(-)
>>
>> diff --git a/configure b/configure
>> index 3cd736b139..a036923dee 100755
>> --- a/configure
>> +++ b/configure
>> @@ -411,7 +411,7 @@ else
>>     # Using uname is really broken, but it is just a fallback for architectures
>>     # that are going to use TCI anyway
>>     cpu=$(uname -m)
>> -  echo "WARNING: unrecognized host CPU, proceeding with 'uname -m' output '$cpu'"
>> +  echo "WARNING: could not determine host CPU, proceeding with 'uname -m' output '$cpu'"
>>   fi
>>
>>   # Normalise host CPU name to the values used by Meson cross files and in source
>> @@ -1000,10 +1000,12 @@ if test -z "$ninja"; then
>>   fi
>>
>>   if test "$host_os" = "bogus"; then
>> -    # Now that we know that we're not printing the help and that
>> -    # the compiler works (so the results of the check_defines we used
>> -    # to identify the OS are reliable), if we didn't recognize the
>> -    # host OS we should stop now.
>> +    # Now that we know that we're not printing the help, we should stop now
>> +    # if we didn't recognize the host OS (or the C compiler is not working).
>> +    write_c_skeleton;
>> +    if ! compile_object ; then
>> +        error_exit "C compiler \"$cc\" is not usable"
>> +    fi
>>       error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
>>   fi
> 
> I think I would prefer as a structure:
> 
> (1) suppress the "unrecognized host CPU" message if "$host_os" == "bogus"
> (2) do the "check the C compiler works" test as its own test immediately
>      after we print the help message (and not guarded by testing $host_os)
> (3) leave the "Unrecognized host OS" check code as it is

Hmm, another idea: Why do we print the --help output that late in the 
configure script at all? Couldn't we move this earlier, to the place where 
we already check for the --cc et al. switches? Then we could get rid of the 
"bogus" stuff completely?

  Thomas



^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] configure: Fix error message when C compiler is not working
  2024-03-20 14:38   ` Thomas Huth
@ 2024-03-20 14:47     ` Peter Maydell
  0 siblings, 0 replies; 7+ messages in thread
From: Peter Maydell @ 2024-03-20 14:47 UTC (permalink / raw)
  To: Thomas Huth; +Cc: Paolo Bonzini, qemu-devel, Alex Bennée, qemu-stable

On Wed, 20 Mar 2024 at 14:38, Thomas Huth <thuth@redhat.com> wrote:
>
> On 19/03/2024 14.12, Peter Maydell wrote:
> > I think I would prefer as a structure:
> >
> > (1) suppress the "unrecognized host CPU" message if "$host_os" == "bogus"
> > (2) do the "check the C compiler works" test as its own test immediately
> >      after we print the help message (and not guarded by testing $host_os)
> > (3) leave the "Unrecognized host OS" check code as it is
>
> Hmm, another idea: Why do we print the --help output that late in the
> configure script at all? Couldn't we move this earlier, to the place where
> we already check for the --cc et al. switches? Then we could get rid of the
> "bogus" stuff completely?

We currently print in the help what the default values for --cc,
--host_cc, etc are -- which means we need to first figure out
those default values. We also print the default target list, and
to figure that out we need to know whether this is Linux or not,
and what the host architecture is. And to figure out the host
architecture we need to run the C compiler.

We could move --help earlier if we were prepared to make its
output more static and less dependent on the host environment,
I guess.

thanks
-- PMM


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2024-03-20 14:49 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-03-08  6:00 [PATCH] configure: Fix error message when C compiler is not working Thomas Huth
2024-03-08 11:26 ` Peter Maydell
2024-03-08 11:32   ` Thomas Huth
2024-03-18 16:08 ` Thomas Huth
2024-03-19 13:12 ` Peter Maydell
2024-03-20 14:38   ` Thomas Huth
2024-03-20 14:47     ` Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).