[Qemu-devel] [PATCH for-2.9] configure: Don't claim 'unsupported host OS' when better message available

Peter Maydell posted 1 patch 7 years ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/1490707129-12622-1-git-send-email-peter.maydell@linaro.org
Test checkpatch passed
Test docker passed
Test s390x passed
configure | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
[Qemu-devel] [PATCH for-2.9] configure: Don't claim 'unsupported host OS' when better message available
Posted by Peter Maydell 7 years ago
The change in commit 898be3e0415c6d which made completely
unrecognized OSes cause an error_exit "Unsupported host OS"
has some unfortunate unintended effects:
 * if you run 'configure --help' on an unsupported host OS
   (eg if intending to use it as a build machine for a
   cross compile to a supported host) then the message
   is printed instead of --help
 * if the C compiler doesn't work or is missing (eg if
   you passed an incorrect --cross-prefix by mistake)
   the message is printed instead of the more useful
   'compiler does not exist or does not work' message

Fix this by postponing the error_exit in this situation
until later, when we have already identified the more
useful cases for this.

The long term fix for this would be to move handling
of --help much further up in the configure script,
and make its output not dependent on checks that configure
runs. However for 2.9 this would be too invasive.

Reported-by: Stefan Weil <sw@weilnetz.de>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 configure | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 82966f7..8820036 100755
--- a/configure
+++ b/configure
@@ -323,6 +323,7 @@ replication="yes"
 
 supported_cpu="no"
 supported_os="no"
+bogus_os="no"
 
 # parse CC options first
 for opt do
@@ -695,7 +696,10 @@ Linux)
   supported_os="yes"
 ;;
 *)
-  error_exit "Unsupported host OS $targetos"
+  # This is a fatal error, but don't report it yet, because we
+  # might be going to just print the --help text, or it might
+  # be the result of a missing compiler.
+  bogus_os="yes"
 ;;
 esac
 
@@ -1461,6 +1465,14 @@ if ! compile_prog ; then
     error_exit "\"$cc\" cannot build an executable (is your linker broken?)"
 fi
 
+if test "$bogus_os" = "yes"; 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.
+    error_exit "Unsupported host OS $targetos"
+fi
+
 # Check that the C++ compiler exists and works with the C compiler
 if has $cxx; then
     cat > $TMPC <<EOF
-- 
2.7.4


Re: [Qemu-devel] [PATCH for-2.9] configure: Don't claim 'unsupported host OS' when better message available
Posted by Stefan Weil 7 years ago
Am 28.03.2017 um 15:18 schrieb Peter Maydell:
> The change in commit 898be3e0415c6d which made completely
> unrecognized OSes cause an error_exit "Unsupported host OS"
> has some unfortunate unintended effects:
>  * if you run 'configure --help' on an unsupported host OS
>    (eg if intending to use it as a build machine for a
>    cross compile to a supported host) then the message
>    is printed instead of --help
>  * if the C compiler doesn't work or is missing (eg if
>    you passed an incorrect --cross-prefix by mistake)
>    the message is printed instead of the more useful
>    'compiler does not exist or does not work' message
>
> Fix this by postponing the error_exit in this situation
> until later, when we have already identified the more
> useful cases for this.
>
> The long term fix for this would be to move handling
> of --help much further up in the configure script,
> and make its output not dependent on checks that configure
> runs. However for 2.9 this would be too invasive.

That's true.

> Reported-by: Stefan Weil <sw@weilnetz.de>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>  configure | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)

Reviewed-by: Stefan Weil <sw@weilnetz.de>
Tested-by: Stefan Weil <sw@weilnetz.de>

Thanks.
Stefan


Re: [Qemu-devel] [PATCH for-2.9] configure: Don't claim 'unsupported host OS' when better message available
Posted by Peter Maydell 6 years, 12 months ago
On 28 March 2017 at 14:18, Peter Maydell <peter.maydell@linaro.org> wrote:
> The change in commit 898be3e0415c6d which made completely
> unrecognized OSes cause an error_exit "Unsupported host OS"
> has some unfortunate unintended effects:
>  * if you run 'configure --help' on an unsupported host OS
>    (eg if intending to use it as a build machine for a
>    cross compile to a supported host) then the message
>    is printed instead of --help
>  * if the C compiler doesn't work or is missing (eg if
>    you passed an incorrect --cross-prefix by mistake)
>    the message is printed instead of the more useful
>    'compiler does not exist or does not work' message
>
> Fix this by postponing the error_exit in this situation
> until later, when we have already identified the more
> useful cases for this.

> +if test "$bogus_os" = "yes"; 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.
> +    error_exit "Unsupported host OS $targetos"
> +fi

Oops, I just noticed I had a minor change here which I forgot
to squash in before sending:

-    error_exit "Unsupported host OS $targetos"
+    error_exit "Unrecognized host OS $targetos"

since this is the case of "we don't know what this is" rather
than "we know what this is but we're planning to remove it".

OK to squash that in when I apply this patch?

thanks
-- PMM

Re: [Qemu-devel] [PATCH for-2.9] configure: Don't claim 'unsupported host OS' when better message available
Posted by Stefan Weil 6 years, 12 months ago
Am 30.03.2017 um 12:17 schrieb Peter Maydell:
> Oops, I just noticed I had a minor change here which I forgot
> to squash in before sending:
>
> -    error_exit "Unsupported host OS $targetos"
> +    error_exit "Unrecognized host OS $targetos"
>
> since this is the case of "we don't know what this is" rather
> than "we know what this is but we're planning to remove it".
>
> OK to squash that in when I apply this patch?
>
> thanks
> -- PMM


Yes, sure.

Thanks
Stefan