From 91de4878f7936ddf539f67ca6db3bd60c4fa5fd3 Mon Sep 17 00:00:00 2001 From: Peter Maydell Date: Fri, 9 Mar 2018 12:25:12 -0500 Subject: [PATCH] configure: Don't claim 'unsupported host OS' when better message available 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. Backports commit fb59dabd4fa7e6586824ac3012073b943fc8dc79 from qemu --- qemu/configure | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/qemu/configure b/qemu/configure index 87b8d5cf..2558d477 100755 --- a/qemu/configure +++ b/qemu/configure @@ -180,6 +180,7 @@ avx2_opt="no" supported_cpu="no" supported_os="no" +bogus_os="no" # parse CC options first for opt do @@ -462,7 +463,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 @@ -701,6 +705,14 @@ else error_exit "\"$cc\" either does not exist or does not work" 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 "Unrecognized host OS $targetos" +fi + gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits" gcc_flags="-Wformat-security -Wformat-y2k -Winit-self -Wignored-qualifiers $gcc_flags" gcc_flags="-Wmissing-include-dirs -Wempty-body -Wnested-externs $gcc_flags"