qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 2/3] kvm-userspace: kvmppc: fix hostlonbits detection when cross compiling v2
@ 2008-09-30  9:10 ehrhardt
  2008-09-30 14:13 ` [Qemu-devel] " Hollis Blanchard
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: ehrhardt @ 2008-09-30  9:10 UTC (permalink / raw)
  To: kvm-ppc, kvm, avi, qemu-devel; +Cc: ehrhardt, hollisb

From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>

*update*
further debugging according to some requests revealed that ARCH_CFLAGS does
not contain all CFLAGS that might be needed, especially those supplied via
extra-cflags. Therefore people supplying things via extra-cflags instead of an
environment variable might have had issues.

A recent kvm merge with qemu brought code for 64bit power that broke cross
compilation. The issue is caused by configure trying to execute target
architecture binaries where configure is executed.

I tried to change that detection so that it works with&without cross
compilation with only a small change and especially without an addtional
configure command line switch. Including the bits/wordsize.h header a platform
usually can check its wordsize and by doing that configure can check the
hostlongbits without executing the binary. Instead it now stops after
preprocessing stage which resolved the __WORDSIZE constant and retrieves
that value.

I don't like my new check style, but it is at least less broken than before.
Another approach that was suggested was that qemu might end up needing
something like asm-offsets in the kernel to manage architecture sizes etc.
Comments and other approaches welcome.
 
Signed-off-by: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
---

[diffstat]
 configure |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

[diff]

diff --git a/qemu/configure b/qemu/configure
--- a/qemu/configure
+++ b/qemu/configure
@@ -685,14 +685,15 @@
 # ppc specific hostlongbits selection
 if test "$cpu" = "powerpc" ; then
     cat > $TMPC <<EOF
-int main(void){return sizeof(long);}
+#include <bits/wordsize.h>
+__WORDSIZE
 EOF
 
-    if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null; then
-        $TMPE
-        case $? in
-            4) hostlongbits="32";;
-            8) hostlongbits="64";;
+    if $cc $ARCH_CFLAGS $CFLAGS -E -o $TMPE.E $TMPC 2> /dev/null; then
+        wordsize=`tail -n 1 ${TMPE}.E`
+        case $wordsize in
+            32) hostlongbits="32";;
+            64) hostlongbits="64";;
             *) echo "Couldn't determine bits per long value"; exit 1;;
         esac
     else

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

* [Qemu-devel] Re: [PATCH 2/3] kvm-userspace: kvmppc: fix hostlonbits detection when cross compiling v2
  2008-09-30  9:10 [Qemu-devel] [PATCH 2/3] kvm-userspace: kvmppc: fix hostlonbits detection when cross compiling v2 ehrhardt
@ 2008-09-30 14:13 ` Hollis Blanchard
  2008-09-30 19:38 ` [Qemu-devel] " malc
  2008-09-30 21:19 ` malc
  2 siblings, 0 replies; 5+ messages in thread
From: Hollis Blanchard @ 2008-09-30 14:13 UTC (permalink / raw)
  To: ehrhardt; +Cc: avi, kvm, kvm-ppc, qemu-devel

On Tue, 2008-09-30 at 11:10 +0200, ehrhardt@linux.vnet.ibm.com wrote:
> diff --git a/qemu/configure b/qemu/configure
> --- a/qemu/configure
> +++ b/qemu/configure
> @@ -685,14 +685,15 @@
>  # ppc specific hostlongbits selection
>  if test "$cpu" = "powerpc" ; then
>      cat > $TMPC <<EOF
> -int main(void){return sizeof(long);}
> +#include <bits/wordsize.h>
> +__WORDSIZE
>  EOF
> 
> -    if $cc $ARCH_CFLAGS -o $TMPE $TMPC 2> /dev/null; then
> -        $TMPE
> -        case $? in
> -            4) hostlongbits="32";;
> -            8) hostlongbits="64";;
> +    if $cc $ARCH_CFLAGS $CFLAGS -E -o $TMPE.E $TMPC 2> /dev/null; then
> +        wordsize=`tail -n 1 ${TMPE}.E`
> +        case $wordsize in
> +            32) hostlongbits="32";;
> +            64) hostlongbits="64";;
>              *) echo "Couldn't determine bits per long value"; exit 1;;
>          esac
>      else

Yeah, trying to execute target-specific code is simply incompatible with
cross-compiling, so clearly this needs to be changed.

<bits/wordsize.h> might be too Linux-specific, not sure. Also, I worry
about the preprocessor being allowed to insert all the whitespace it
wants, so I'm not sure if you can assume that __WORDSIZE will be on the
last output line.

Instead you could use this:
	$cc -E -dM - < /dev/null | grep __powerpc64__

-- 
Hollis Blanchard
IBM Linux Technology Center

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

* Re: [Qemu-devel] [PATCH 2/3] kvm-userspace: kvmppc: fix hostlonbits detection when cross compiling v2
  2008-09-30  9:10 [Qemu-devel] [PATCH 2/3] kvm-userspace: kvmppc: fix hostlonbits detection when cross compiling v2 ehrhardt
  2008-09-30 14:13 ` [Qemu-devel] " Hollis Blanchard
@ 2008-09-30 19:38 ` malc
  2008-10-01 12:26   ` Christian Ehrhardt
  2008-09-30 21:19 ` malc
  2 siblings, 1 reply; 5+ messages in thread
From: malc @ 2008-09-30 19:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: ehrhardt, avi, kvm, kvm-ppc, hollisb

On Tue, 30 Sep 2008, ehrhardt@linux.vnet.ibm.com wrote:

> From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
>
> *update*
> further debugging according to some requests revealed that ARCH_CFLAGS does
> not contain all CFLAGS that might be needed, especially those supplied via
> extra-cflags. Therefore people supplying things via extra-cflags instead of an
> environment variable might have had issues.

This part i don't get, there are few more checks before/after 
hostlongbits where no CFLAGS are added to the $cc argument list. What
makes hostlongbits selection "special"? Do people specify -m32/-m64 via
--extra-cflags?

>
> A recent kvm merge with qemu brought code for 64bit power that broke cross
> compilation. The issue is caused by configure trying to execute target
> architecture binaries where configure is executed.

Yes, i never thought about cross-compilation, my bad.

> I tried to change that detection so that it works with&without cross
> compilation with only a small change and especially without an addtional
> configure command line switch. Including the bits/wordsize.h header a platform
> usually can check its wordsize and by doing that configure can check the
> hostlongbits without executing the binary. Instead it now stops after
> preprocessing stage which resolved the __WORDSIZE constant and retrieves
> that value.
>
> I don't like my new check style, but it is at least less broken than before.
> Another approach that was suggested was that qemu might end up needing
> something like asm-offsets in the kernel to manage architecture sizes etc.
> Comments and other approaches welcome.
>

I think Hollis Blanchard's method is sound,

Thank you for bringing this up.

-- 
mailto:av1474@comtv.ru

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

* Re: [Qemu-devel] [PATCH 2/3] kvm-userspace: kvmppc: fix hostlonbits detection when cross compiling v2
  2008-09-30  9:10 [Qemu-devel] [PATCH 2/3] kvm-userspace: kvmppc: fix hostlonbits detection when cross compiling v2 ehrhardt
  2008-09-30 14:13 ` [Qemu-devel] " Hollis Blanchard
  2008-09-30 19:38 ` [Qemu-devel] " malc
@ 2008-09-30 21:19 ` malc
  2 siblings, 0 replies; 5+ messages in thread
From: malc @ 2008-09-30 21:19 UTC (permalink / raw)
  To: qemu-devel; +Cc: ehrhardt, kvm, kvm-ppc

On Tue, 30 Sep 2008, ehrhardt@linux.vnet.ibm.com wrote:

> From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>

The commit message of r5364, the revision which basically exists
because of your posts, was somehow butchered and as such doesn't
include any references, i'm very sorry about that.

The above line was there in the commit message editing buffer, but
then i somehow screwed it all up, probably when trying to reformat
stuff suffling text around.

Once again, i'm sorry.

[..snip..]

-- 
mailto:av1474@comtv.ru

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

* Re: [Qemu-devel] [PATCH 2/3] kvm-userspace: kvmppc: fix hostlonbits detection when cross compiling v2
  2008-09-30 19:38 ` [Qemu-devel] " malc
@ 2008-10-01 12:26   ` Christian Ehrhardt
  0 siblings, 0 replies; 5+ messages in thread
From: Christian Ehrhardt @ 2008-10-01 12:26 UTC (permalink / raw)
  To: malc; +Cc: hollisb, avi, qemu-devel, kvm-ppc, kvm

malc wrote:
> On Tue, 30 Sep 2008, ehrhardt@linux.vnet.ibm.com wrote:
>
>> From: Christian Ehrhardt <ehrhardt@linux.vnet.ibm.com>
>>
>> *update*
>> further debugging according to some requests revealed that 
>> ARCH_CFLAGS does
>> not contain all CFLAGS that might be needed, especially those 
>> supplied via
>> extra-cflags. Therefore people supplying things via extra-cflags 
>> instead of an
>> environment variable might have had issues.
>
> This part i don't get, there are few more checks before/after 
> hostlongbits where no CFLAGS are added to the $cc argument list. What
> makes hostlongbits selection "special"? Do people specify -m32/-m64 via
> --extra-cflags?
>
it was there to ensure availability of the needed include paths to reach 
wordsize.h.
But Hollis approach is much simpler, better and more reliable so never 
mind :-)

>>
>> A recent kvm merge with qemu brought code for 64bit power that broke 
>> cross
>> compilation. The issue is caused by configure trying to execute target
>> architecture binaries where configure is executed.
>
> Yes, i never thought about cross-compilation, my bad.
np, now it's fixed - thanks for quickly applying it.
>
>> I tried to change that detection so that it works with&without cross
>> compilation with only a small change and especially without an addtional
>> configure command line switch. Including the bits/wordsize.h header a 
>> platform
>> usually can check its wordsize and by doing that configure can check the
>> hostlongbits without executing the binary. Instead it now stops after
>> preprocessing stage which resolved the __WORDSIZE constant and retrieves
>> that value.
>>
>> I don't like my new check style, but it is at least less broken than 
>> before.
>> Another approach that was suggested was that qemu might end up needing
>> something like asm-offsets in the kernel to manage architecture sizes 
>> etc.
>> Comments and other approaches welcome.
>>
>
> I think Hollis Blanchard's method is sound,
>
> Thank you for bringing this up.
>


-- 

Grüsse / regards, 
Christian Ehrhardt
IBM Linux Technology Center, Open Virtualization

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

end of thread, other threads:[~2008-10-01 12:32 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-30  9:10 [Qemu-devel] [PATCH 2/3] kvm-userspace: kvmppc: fix hostlonbits detection when cross compiling v2 ehrhardt
2008-09-30 14:13 ` [Qemu-devel] " Hollis Blanchard
2008-09-30 19:38 ` [Qemu-devel] " malc
2008-10-01 12:26   ` Christian Ehrhardt
2008-09-30 21:19 ` malc

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).