Skip to contentSkip to conversation

Fix check for target OS support

PATCH In review Stefan Weil 4 participants 8 messages Mar 27, 2017 – Mar 28, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix check for target OS support

This check had several problems which are fixed here:

* Calling "configure --help" was no longer possible on Cygwin. Fix this by introducing a third state for supported_os and by moving the error handling code.
Move the error handling code for supported_cpu, too.

* Fix the error text. Use target cpu and target os because the build cpu and build host don't matter here.

* Support cross compilation with the most common cross prefixes for Mingw-w64. Other cross builds are still broken!

---

This fixes a regression: building QEMU for Windows with a cross build under Cygwin is currently broken.

Can the patch be applied directly, or who should send a pull request?

Stefan

 configure | 68 +++++++++++++++++++++++++++++++++++----------------------------
 1 file changed, 38 insertions(+), 30 deletions(-)
configure +38 -30
index d1ce33bc79..902bd20070 100755
@@ -322,7 +322,7 @@ jemalloc="no"
 replication="yes"
 
 supported_cpu="no"
-supported_os="no"
+supported_os="deprecated"
 
 # parse CC options first
 for opt do
@@ -440,7 +440,13 @@ int main(void) { return 0; }
 EOF
 }
 
-if check_define __linux__ ; then
+if test "$cross_prefix" = "i686_64-w64-mingw32-" ; then
+  targetos='MINGW32'
+elif test "$cross_prefix" = "x86_64-w64-mingw32-" ; then
+  targetos='MINGW32'
+elif test -n "$cross_prefix" ; then
+  targetos="$cross_prefix"
+elif check_define __linux__ ; then
   targetos="Linux"
 elif check_define _WIN32 ; then
   targetos='MINGW32'
@@ -694,7 +700,7 @@ Linux)
   supported_os="yes"
 ;;
 *)
-  error_exit "Unsupported host OS $targetos"
+  supported_os="no"
 ;;
 esac
 
@@ -1428,6 +1434,34 @@ EOF
 exit 0
 fi
 
+if test "$supported_cpu" = "no"; then
+    echo "WARNING: SUPPORT FOR THIS TARGET CPU WILL GO AWAY IN FUTURE RELEASES!"
+    echo
+    echo "CPU target architecture $cpu support is not currently maintained."
+    echo "The QEMU project intends to remove support for this target CPU in"
+    echo "a future release if nobody volunteers to maintain it and to"
+    echo "provide a build host for our continuous integration setup."
+    echo "configure has succeeded and you can continue to build, but"
+    echo "if you care about QEMU on this platform you should contact"
+    echo "us upstream at [email protected]."
+    echo
+fi
+
+if test "$supported_os" = "no"; then
+  error_exit "Unsupported target OS $targetos"
+elif test "$supported_os" = "deprecated"; then
+    echo "WARNING: SUPPORT FOR THIS TARGET OS WILL GO AWAY IN FUTURE RELEASES!"
+    echo
+    echo "Target OS $targetos support is not currently maintained."
+    echo "The QEMU project intends to remove support for this target OS in"
+    echo "a future release if nobody volunteers to maintain it and to"
+    echo "provide a build host for our continuous integration setup."
+    echo "configure has succeeded and you can continue to build, but"
+    echo "if you care about QEMU on this platform you should contact"
+    echo "us upstream at [email protected]."
+    echo
+fi
+
 # Now we have handled --enable-tcg-interpreter and know we're not just
 # printing the help message, bail out if the host CPU isn't supported.
 if test "$ARCH" = "unknown"; then
@@ -5127,32 +5161,6 @@ if test "$sdl_too_old" = "yes"; then
 echo "-> Your SDL version is too old - please upgrade to have SDL support"
 fi
 
-if test "$supported_cpu" = "no"; then
-    echo
-    echo "WARNING: SUPPORT FOR THIS HOST CPU WILL GO AWAY IN FUTURE RELEASES!"
-    echo
-    echo "CPU host architecture $cpu support is not currently maintained."
-    echo "The QEMU project intends to remove support for this host CPU in"
-    echo "a future release if nobody volunteers to maintain it and to"
-    echo "provide a build host for our continuous integration setup."
-    echo "configure has succeeded and you can continue to build, but"
-    echo "if you care about QEMU on this platform you should contact"
-    echo "us upstream at [email protected]."
-fi
-
-if test "$supported_os" = "no"; then
-    echo
-    echo "WARNING: SUPPORT FOR THIS HOST OS WILL GO AWAY IN FUTURE RELEASES!"
-    echo
-    echo "Host OS $targetos support is not currently maintained."
-    echo "The QEMU project intends to remove support for this host OS in"
-    echo "a future release if nobody volunteers to maintain it and to"
-    echo "provide a build host for our continuous integration setup."
-    echo "configure has succeeded and you can continue to build, but"
-    echo "if you care about QEMU on this platform you should contact"
-    echo "us upstream at [email protected]."
-fi
-
 config_host_mak="config-host.mak"
 
 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak
@@ -5212,7 +5220,7 @@ if test "$mingw32" = "yes" ; then
     echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
   fi
   if test "$guest_agent_msi" = "yes"; then
-    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak  
+    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
     echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
     echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
     echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak
Signature · 1 line
2.11.0
#1 lore raw
Quoted 9 lines · Stefan Weil

This check had several problems which are fixed here:

* Calling "configure --help" was no longer possible on Cygwin. Fix this by introducing a third state for supported_os and by moving the error handling code.
Move the error handling code for supported_cpu, too.

* Fix the error text. Use target cpu and target os because the build cpu and build host don't matter here.

I think it is important that we print the deprecation message last, after all the other configure output. Otherwise it will scroll off the screen and most people will miss it. That's why I put it where it is.

Quoted 21 lines

* Support cross compilation with the most common cross prefixes for Mingw-w64. Other cross builds are still broken!

---

This fixes a regression: building QEMU for Windows with a cross build under Cygwin is currently broken.

Can the patch be applied directly, or who should send a pull request?

Stefan

 configure | 68 +++++++++++++++++++++++++++++++++++----------------------------
 1 file changed, 38 insertions(+), 30 deletions(-)
configure +0 -0
index d1ce33bc79..902bd20070 100755

configure jemalloc="no" · line 325

Quoted 5 lines
configure +1 -1
@@ -322,7 +322,7 @@ jemalloc="no"
 replication="yes"
 
 supported_cpu="no"
-supported_os="no"
+supported_os="deprecated"

I don't see any need for anything other than 'yes' or 'no' ?

Quoted 4 lines
configure +0 -0
 # parse CC options first
 for opt do

configure int main(void) { return 0; } · line 448

Quoted 10 lines
configure +6 -1
@@ -440,7 +440,13 @@ int main(void) { return 0; }
 EOF
 }
 
-if check_define __linux__ ; then
+if test "$cross_prefix" = "i686_64-w64-mingw32-" ; then
+  targetos='MINGW32'
+elif test "$cross_prefix" = "x86_64-w64-mingw32-" ; then
+  targetos='MINGW32'
+elif test -n "$cross_prefix" ; then
+  targetos="$cross_prefix"

This doesn't look right. We already have too many cases where we determine the target OS by something other than looking at check_defines; one thing I'd like to do when we've got rid of unsupported OSes is to make sure that we determine the target OS by check_define and only by check_define.

configure Linux) · line 703

Quoted 10 lines
configure +2 -1
+elif check_define __linux__ ; then
   targetos="Linux"
 elif check_define _WIN32 ; then
   targetos='MINGW32'
@@ -694,7 +700,7 @@ Linux)
   supported_os="yes"
 ;;
 *)
-  error_exit "Unsupported host OS $targetos"
+  supported_os="no"

This was deliberately an error_exit because anything going down that path got the Linux defines/includes by accident and we thought that would not work on anything else. What was using it? If we need an extra entry in the case statement we can add one.

Quoted 11 lines
configure +0 -0
 ;;
 esac
 
@@ -1428,6 +1434,34 @@ EOF
 exit 0
 fi
 
 config_host_mak="config-host.mak"
 
 echo "# Automatically generated by configure - do not modify" >config-all-disas.mak

configure if test "$mingw32" = "yes" ; then · line 5226

Quoted 8 lines
configure +1 -1
@@ -5212,7 +5220,7 @@ if test "$mingw32" = "yes" ; then
     echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
   fi
   if test "$guest_agent_msi" = "yes"; then
-    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
+    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
     echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
     echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
     echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak

Stray unintended change?

Quoted 3 lines

--
2.11.0

thanks
-- PMM

#2 lore raw

Am 28.03.2017 um 09:10 schrieb Peter Maydell:

Quoted 8 lines · Stefan Weil
Quoted 7 lines

This check had several problems which are fixed here:

* Calling "configure --help" was no longer possible on Cygwin. Fix this by introducing a third state for supported_os and by moving the error handling code.
Move the error handling code for supported_cpu, too.

Quoted 6 lines
Quoted 2 lines

* Fix the error text. Use target cpu and target os because the build cpu and build host don't matter here.

I think it is important that we print the deprecation message last, after all the other configure output. Otherwise it will scroll off the screen and most people will miss it. That's why I put it where it is.

Ok, then only the error handling for unsupported target os has to be moved (to support ./configure --help).

Quoted 10 lines

configure jemalloc="no" · line 325

Quoted 9 lines

index d1ce33bc79..902bd20070 100755

configure +1 -1
@@ -322,7 +322,7 @@ jemalloc="no"
 replication="yes"
 
 supported_cpu="no"
-supported_os="no"
+supported_os="deprecated"

I don't see any need for anything other than 'yes' or 'no' ?

yes = file
no = raise error
deprecated = raise warning

Needed for delayed error handling, see below.

Quoted 6 lines
Quoted 6 lines
configure +0 -0
 # parse CC options first
 for opt do
@@ -440,7 +440,13 @@ int main(void) { return 0; }
 EOF
 }
 
Quoted 13 lines

configure int main(void) { return 0; } · line 448

Quoted 7 lines
configure +6 -1
-if check_define __linux__ ; then
+if test "$cross_prefix" = "i686_64-w64-mingw32-" ; then
+  targetos='MINGW32'
+elif test "$cross_prefix" = "x86_64-w64-mingw32-" ; then
+  targetos='MINGW32'
+elif test -n "$cross_prefix" ; then
+  targetos="$cross_prefix"

This doesn't look right. We already have too many cases where we determine the target OS by something other than looking at check_defines; one thing I'd like to do when we've got rid of unsupported OSes is to make sure that we determine the target OS by check_define and only by check_define.

That part of my patch is not needed. I added it because I did not realize that "check_define" already does the correct thing and because a wrong cross prefix raises a misleading error message.

Quoted 7 lines
Quoted 7 lines
configure +1 -0
+elif check_define __linux__ ; then
   targetos="Linux"
 elif check_define _WIN32 ; then
   targetos='MINGW32'
@@ -694,7 +700,7 @@ Linux)
   supported_os="yes"
 ;;
Quoted 8 lines

configure Linux) · line 703

Quoted 3 lines
configure +1 -1
 *)
-  error_exit "Unsupported host OS $targetos"
+  supported_os="no"

This was deliberately an error_exit because anything going down that path got the Linux defines/includes by accident and we thought that would not work on anything else. What was using it? If we need an extra entry in the case statement we can add one.

It remains an error (that's why I introduced a third state for supported_os), but must be handled later, after processing a potential --help option.

Quoted 9 lines

configure if test "$mingw32" = "yes" ; then · line 5226

Quoted 8 lines
configure +1 -1
     echo "CONFIG_QGA_NTDDDISK=y" >> $config_host_mak
   fi
   if test "$guest_agent_msi" = "yes"; then
-    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
+    echo "QEMU_GA_MSI_ENABLED=yes" >> $config_host_mak
     echo "QEMU_GA_MSI_MINGW_DLL_PATH=${QEMU_GA_MSI_MINGW_DLL_PATH}" >> $config_host_mak
     echo "QEMU_GA_MSI_WITH_VSS=${QEMU_GA_MSI_WITH_VSS}" >> $config_host_mak
     echo "QEMU_GA_MSI_ARCH=${QEMU_GA_MSI_ARCH}" >> $config_host_mak

Stray unintended change?

Whitespace at line ending removed by my editor.

Stefan

#3 lore raw
Quoted 11 lines · Stefan Weil

Am 28.03.2017 um 09:10 schrieb Peter Maydell:

Quoted 9 lines · Stefan Weil

configure Linux) · line 703

Quoted 3 lines

*)

configure +1 -1
-  error_exit "Unsupported host OS $targetos"
+  supported_os="no"

This was deliberately an error_exit because anything going down that path got the Linux defines/includes by accident and we thought that would not work on anything else. What was using it? If we need an extra entry in the case statement we can add one.

Quoted 3 lines

It remains an error (that's why I introduced a third state for supported_os), but must be handled later, after processing a potential --help option.

I think the right fix for this is to special case --help to bypass more checks and to happen earlier. For instance if you don't happen to have a 'python' on your PATH then we do this:

netbsdvm# ./configure --help

ERROR: Python not found. Use --python=/path/to/python

I'll have a go at writing a patch.

thanks
-- PMM

#4 lore raw
In reply to Stefan Weil
Quoted 2 lines · Stefan Weil

* Support cross compilation with the most common cross prefixes for Mingw-w64. Other cross builds are still broken!

Can you explain how it's broken? Why does check_define not work at this point, for cross builds?

"../configure --cross-prefix=x86_64-w64-mingw32-" seems to work for me.

Paolo

Quoted 8 lines
configure +7 -0
+if test "$cross_prefix" = "i686_64-w64-mingw32-" ; then
+  targetos='MINGW32'
+elif test "$cross_prefix" = "x86_64-w64-mingw32-" ; then
+  targetos='MINGW32'
+elif test -n "$cross_prefix" ; then
+  targetos="$cross_prefix"
+elif check_define __linux__ ; then
   targetos="Linux"
#5 lore raw

Am 28.03.2017 um 10:04 schrieb Paolo Bonzini:

Quoted 9 lines · Stefan Weil
Quoted 2 lines

* Support cross compilation with the most common cross prefixes for Mingw-w64. Other cross builds are still broken!

Can you explain how it's broken? Why does check_define not work at this point, for cross builds?

"../configure --cross-prefix=x86_64-w64-mingw32-" seems to work for me.

Paolo

You are right. I was wrong because of this use case:

$ ./configure '--enable-debug' '--cross-prefix=x86_64-w64-mingw32'

ERROR: Unsupported host OS CYGWIN_NT-6.1

So the error message is misleading when I specify a wrong cross prefix (it should have been x86_64-w64-mingw32- instead of x86_64-w64-mingw32).

With the correct cross prefix, builds work, so cross builds are not a critical issue as I thought.

The second issue which remains is calling ./configure --help:

$ ./configure --help

ERROR: Unsupported host OS CYGWIN_NT-6.1

The third issue is the message for deprecated cpus or targets which should use "target" instead of "host".

All these three issues are not critical for the next QEMU version. Therefore I think they can be fixed after the release.

Regards
Stefan

#6 lore raw
Quoted 11 lines · Stefan Weil

Am 28.03.2017 um 10:04 schrieb Paolo Bonzini:

Quoted 9 lines · Stefan Weil
Quoted 2 lines

* Support cross compilation with the most common cross prefixes for Mingw-w64. Other cross builds are still broken!

Can you explain how it's broken? Why does check_define not work at this point, for cross builds?

"../configure --cross-prefix=x86_64-w64-mingw32-" seems to work for me.

Paolo

Quoted 8 lines

You are right. I was wrong because of this use case:

$ ./configure '--enable-debug' '--cross-prefix=x86_64-w64-mingw32'

ERROR: Unsupported host OS CYGWIN_NT-6.1

So the error message is misleading when I specify a wrong cross prefix (it should have been x86_64-w64-mingw32- instead of x86_64-w64-mingw32).

Ah, I see. In the fall-through case we'd then complain that the compiler didn't work. I think the underlying problem here is that we use the compiler (for the check_prefix tests) before the "does this compiler even work" test...

(This only happens in the case where you're doing a cross compile and the build machine is not a supported QEMU host.)

Quoted 8 lines

With the correct cross prefix, builds work, so cross builds are not a critical issue as I thought.

The second issue which remains is calling ./configure --help:

$ ./configure --help

ERROR: Unsupported host OS CYGWIN_NT-6.1

Yeah, we should not complain for --help; I'll see if I can fix that.

Quoted 2 lines

The third issue is the message for deprecated cpus or targets which should use "target" instead of "host".

We are not (yet) deprecating any targets, so we don't want to say "target". What we're deprecating are hosts. (In a cross compile setup the 'host' (machine being compiled for) isn't the 'build' (machine running the compiler), but I think if you're advanced enough to be cross-compiling you can deal with the confusing terminology.)

thanks
-- PMM

#7 lore raw
In reply to Stefan Weil
Quoted 16 lines · Stefan Weil

You are right. I was wrong because of this use case:

$ ./configure '--enable-debug' '--cross-prefix=x86_64-w64-mingw32'

ERROR: Unsupported host OS CYGWIN_NT-6.1

So the error message is misleading when I specify a wrong cross prefix (it should have been x86_64-w64-mingw32- instead of x86_64-w64-mingw32).

With the correct cross prefix, builds work, so cross builds are not a critical issue as I thought.

The second issue which remains is calling ./configure --help:

$ ./configure --help
Quoted 7 lines

ERROR: Unsupported host OS CYGWIN_NT-6.1

The third issue is the message for deprecated cpus or targets which should use "target" instead of "host".

All these three issues are not critical for the next QEMU version. Therefore I think they can be fixed after the release.

On a related note, I was scratching my head for a while over the weekend trying to build on MingW with the "ERROR: Unsupported host ..." message, since it also pops up if you don't have gcc installed, or indeed gcc but not the gcc headers installed.

The latter case was much harder to spot since config.log showed other warnings and #errors from previous configure tests before failing with the unrelated ERROR message.

ATB,

Mark.