qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] configure: Never use 'uname' to identify target OS
@ 2017-07-13 15:15 Peter Maydell
  2017-07-14  5:00 ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
  2017-07-21 15:24 ` [Qemu-devel] " Peter Maydell
  0 siblings, 2 replies; 3+ messages in thread
From: Peter Maydell @ 2017-07-13 15:15 UTC (permalink / raw)
  To: qemu-devel, qemu-trivial; +Cc: patches

For a very long time we have used 'uname -s' as our fallback if
we don't identify the target OS using a compiler #define. This
obviously doesn't work for cross-compilation, and we've had
a comment suggesting we fix this in configure for a long time.
Since we now have an exhaustive list of which OSes we can run
on (thanks to commit 898be3e0415 making an unrecognized OS
be a fatal error), we know which ones we're missing.

Add check_define tests for the remaining OSes we support.  The
defines checked are based on ones we already use in the codebase for
identifying the host OS (with the exception of GNU/kFreeBSD).
We can now set bogus_os immediately rather than doing it later.

We leave the comment about uname being bad untouched, since
there is still a use of it for the fallback for unrecognized
host CPU type.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---

All of these OSes except OSX are on the "not actually supported"
list, so I don't care very much if we break them.  I did sanity check
FreeBSD and NetBSD which are the two most plausible ones to
get back into supported status.

 configure | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/configure b/configure
index 5096cbc..d733a05 100755
--- a/configure
+++ b/configure
@@ -536,8 +536,24 @@ elif check_define __sun__ ; then
   targetos='SunOS'
 elif check_define __HAIKU__ ; then
   targetos='Haiku'
+elif check_define __FreeBSD__ ; then
+  targetos='FreeBSD'
+elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
+  targetos='GNU/kFreeBSD'
+elif check_define __DragonFly__ ; then
+  targetos='DragonFly'
+elif check_define __NetBSD__; then
+  targetos='NetBSD'
+elif check_define __APPLE__; then
+  targetos='Darwin'
+elif check_define _AIX; then
+  targetos='AIX'
 else
-  targetos=$(uname -s)
+  # 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.
+  targetos='bogus'
+  bogus_os='yes'
 fi
 
 # Some host OSes need non-standard checks for which CPU to use.
@@ -781,12 +797,6 @@ Linux)
   QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
   supported_os="yes"
 ;;
-*)
-  # 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
 
 if [ "$bsd" = "yes" ] ; then
@@ -1576,7 +1586,7 @@ if test "$bogus_os" = "yes"; then
     # 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"
+    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
 fi
 
 gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
-- 
2.7.4

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

* Re: [Qemu-devel] [Qemu-trivial] [PATCH] configure: Never use 'uname' to identify target OS
  2017-07-13 15:15 [Qemu-devel] [PATCH] configure: Never use 'uname' to identify target OS Peter Maydell
@ 2017-07-14  5:00 ` Philippe Mathieu-Daudé
  2017-07-21 15:24 ` [Qemu-devel] " Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Philippe Mathieu-Daudé @ 2017-07-14  5:00 UTC (permalink / raw)
  To: Peter Maydell, qemu-devel, qemu-trivial; +Cc: patches

On 07/13/2017 12:15 PM, Peter Maydell wrote:
> For a very long time we have used 'uname -s' as our fallback if
> we don't identify the target OS using a compiler #define. This
> obviously doesn't work for cross-compilation, and we've had
> a comment suggesting we fix this in configure for a long time.
> Since we now have an exhaustive list of which OSes we can run
> on (thanks to commit 898be3e0415 making an unrecognized OS
> be a fatal error), we know which ones we're missing.
> 
> Add check_define tests for the remaining OSes we support.  The
> defines checked are based on ones we already use in the codebase for
> identifying the host OS (with the exception of GNU/kFreeBSD).
> We can now set bogus_os immediately rather than doing it later.
> 
> We leave the comment about uname being bad untouched, since
> there is still a use of it for the fallback for unrecognized
> host CPU type.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
> 
> All of these OSes except OSX are on the "not actually supported"
> list, so I don't care very much if we break them.  I did sanity check
> FreeBSD and NetBSD which are the two most plausible ones to
> get back into supported status.
> 
>   configure | 26 ++++++++++++++++++--------
>   1 file changed, 18 insertions(+), 8 deletions(-)
> 
> diff --git a/configure b/configure
> index 5096cbc..d733a05 100755
> --- a/configure
> +++ b/configure
> @@ -536,8 +536,24 @@ elif check_define __sun__ ; then
>     targetos='SunOS'
>   elif check_define __HAIKU__ ; then
>     targetos='Haiku'
> +elif check_define __FreeBSD__ ; then
> +  targetos='FreeBSD'
> +elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then
> +  targetos='GNU/kFreeBSD'

My first thought was "this check should go _before_ FreeBSD" then 
verified, can sound odd but indeed GNU/kFreeBSD does not define __FreeBSD__.

> +elif check_define __DragonFly__ ; then
> +  targetos='DragonFly'
> +elif check_define __NetBSD__; then
> +  targetos='NetBSD'
> +elif check_define __APPLE__; then

I guess Mac OS 9 MPW crippled C compiler also defined this, but 
hopefully even Apple lost the last verbatim copy, so this assumption is 
pretty safe :)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

> +  targetos='Darwin'
> +elif check_define _AIX; then
> +  targetos='AIX'
>   else
> -  targetos=$(uname -s)
> +  # 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.
> +  targetos='bogus'
> +  bogus_os='yes'
>   fi
>   
>   # Some host OSes need non-standard checks for which CPU to use.
> @@ -781,12 +797,6 @@ Linux)
>     QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES"
>     supported_os="yes"
>   ;;
> -*)
> -  # 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
>   
>   if [ "$bsd" = "yes" ] ; then
> @@ -1576,7 +1586,7 @@ if test "$bogus_os" = "yes"; then
>       # 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"
> +    error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')"
>   fi
>   
>   gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"
> 

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

* Re: [Qemu-devel] [PATCH] configure: Never use 'uname' to identify target OS
  2017-07-13 15:15 [Qemu-devel] [PATCH] configure: Never use 'uname' to identify target OS Peter Maydell
  2017-07-14  5:00 ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
@ 2017-07-21 15:24 ` Peter Maydell
  1 sibling, 0 replies; 3+ messages in thread
From: Peter Maydell @ 2017-07-21 15:24 UTC (permalink / raw)
  To: QEMU Developers, QEMU Trivial; +Cc: patches@linaro.org

On 13 July 2017 at 16:15, Peter Maydell <peter.maydell@linaro.org> wrote:
> For a very long time we have used 'uname -s' as our fallback if
> we don't identify the target OS using a compiler #define. This
> obviously doesn't work for cross-compilation, and we've had
> a comment suggesting we fix this in configure for a long time.
> Since we now have an exhaustive list of which OSes we can run
> on (thanks to commit 898be3e0415 making an unrecognized OS
> be a fatal error), we know which ones we're missing.
>
> Add check_define tests for the remaining OSes we support.  The
> defines checked are based on ones we already use in the codebase for
> identifying the host OS (with the exception of GNU/kFreeBSD).
> We can now set bogus_os immediately rather than doing it later.
>
> We leave the comment about uname being bad untouched, since
> there is still a use of it for the fallback for unrecognized
> host CPU type.
>
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---

Applied, thanks.

-- PMM

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

end of thread, other threads:[~2017-07-21 15:25 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-07-13 15:15 [Qemu-devel] [PATCH] configure: Never use 'uname' to identify target OS Peter Maydell
2017-07-14  5:00 ` [Qemu-devel] [Qemu-trivial] " Philippe Mathieu-Daudé
2017-07-21 15:24 ` [Qemu-devel] " 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).