diff mbox

host-pcc: enable building with -m32 or -m64

Message ID 4DDEA34C.4040304@linux.vnet.ibm.com
State New
Headers show

Commit Message

Stefan Berger May 26, 2011, 7 p.m. UTC
With the below patch I can build either ppc (-m32) or ppc64 (-m64) 
versions of Qemu (on a ppc64 host) when passing these compiler flags via 
'configure ... --extra-cflags="-m32"'.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>

---
  configure |    9 ++++++++-
  1 file changed, 8 insertions(+), 1 deletion(-)

Comments

malc May 26, 2011, 7:14 p.m. UTC | #1
On Thu, 26 May 2011, Stefan Berger wrote:

> With the below patch I can build either ppc (-m32) or ppc64 (-m64) versions of
> Qemu (on a ppc64 host) when passing these compiler flags via 'configure ...
> --extra-cflags="-m32"'.
> 
> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
> 
> ---
>  configure |    9 ++++++++-
>  1 file changed, 8 insertions(+), 1 deletion(-)
> 
> Index: qemu-git/configure
> ===================================================================
> --- qemu-git.orig/configure
> +++ qemu-git/configure
> @@ -807,7 +807,14 @@ case "$cpu" in
>      arm*)
>             host_guest_base="yes"
>             ;;
> -    ppc*)
> +    ppc)
> +           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
> +           LDFLAGS="-m32 $LDFLAGS"
> +           host_guest_base="yes"
> +           ;;
> +    ppc64)
> +           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
> +           LDFLAGS="-m64 $LDFLAGS"
>             host_guest_base="yes"
>             ;;
>      mips*)
> 

This isn't right, if one has particular toolchain and wants to build
something that defaults to a different bitlength he should be able to
do that, this patch attempts to outsmart the defaults and furthermore
prevents one from overriding the settings.

P.S. host-pcc... pcc?

P.P.S. On the ppc64 machine i have, gcc defaults to 32bit and for a
       good reason - 64bit code is quite a bit slower when running
       typical workloads (64bit guest not being one of them though)
Stefan Berger May 26, 2011, 7:27 p.m. UTC | #2
On 05/26/2011 03:14 PM, malc wrote:
> On Thu, 26 May 2011, Stefan Berger wrote:
>
>> With the below patch I can build either ppc (-m32) or ppc64 (-m64) versions of
>> Qemu (on a ppc64 host) when passing these compiler flags via 'configure ...
>> --extra-cflags="-m32"'.
>>
>> Signed-off-by: Stefan Berger<stefanb@linux.vnet.ibm.com>
>>
>> ---
>>   configure |    9 ++++++++-
>>   1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> Index: qemu-git/configure
>> ===================================================================
>> --- qemu-git.orig/configure
>> +++ qemu-git/configure
>> @@ -807,7 +807,14 @@ case "$cpu" in
>>       arm*)
>>              host_guest_base="yes"
>>              ;;
>> -    ppc*)
>> +    ppc)
>> +           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
>> +           LDFLAGS="-m32 $LDFLAGS"
>> +           host_guest_base="yes"
>> +           ;;
>> +    ppc64)
>> +           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
>> +           LDFLAGS="-m64 $LDFLAGS"
>>              host_guest_base="yes"
>>              ;;
>>       mips*)
>>
> This isn't right, if one has particular toolchain and wants to build
> something that defaults to a different bitlength he should be able to
> do that, this patch attempts to outsmart the defaults and furthermore
> prevents one from overriding the settings.
>
> P.S. host-pcc... pcc?
>
> P.P.S. On the ppc64 machine i have, gcc defaults to 32bit and for a
>         good reason - 64bit code is quite a bit slower when running
>         typical workloads (64bit guest not being one of them though)
>
Is it possible to change my ppc64 gcc compiler to produce 32bit binaries 
by default -- how? I'd like to test this case because for me not passing 
any parameters via --extra-cflags defaults to the ppc64 case above - 
obviously it will produce 64 bit binaries by default. -m32 then ends up 
in the ppc) case, -m64 again in the ppc64) case.

    Stefan
Andreas Färber May 26, 2011, 8:20 p.m. UTC | #3
Am 26.05.2011 um 21:00 schrieb Stefan Berger:

> With the below patch I can build either ppc (-m32) or ppc64 (-m64)  
> versions of Qemu (on a ppc64 host) when passing these compiler flags  
> via 'configure ... --extra-cflags="-m32"'.

You probably meant "without passing"?

Nack. Please don't hardcode -mXX in configure, it's -arch ppc vs. - 
arch ppc64 on my host/gcc. What's wrong with passing --extra-cflags?

Andreas

> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
>
> ---
> configure |    9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> Index: qemu-git/configure
> ===================================================================
> --- qemu-git.orig/configure
> +++ qemu-git/configure
> @@ -807,7 +807,14 @@ case "$cpu" in
>     arm*)
>            host_guest_base="yes"
>            ;;
> -    ppc*)
> +    ppc)
> +           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
> +           LDFLAGS="-m32 $LDFLAGS"
> +           host_guest_base="yes"
> +           ;;
> +    ppc64)
> +           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
> +           LDFLAGS="-m64 $LDFLAGS"
>            host_guest_base="yes"
>            ;;
>     mips*)
Stefan Berger May 26, 2011, 8:31 p.m. UTC | #4
On 05/26/2011 04:20 PM, Andreas Färber wrote:
> Am 26.05.2011 um 21:00 schrieb Stefan Berger:
>
>> With the below patch I can build either ppc (-m32) or ppc64 (-m64) 
>> versions of Qemu (on a ppc64 host) when passing these compiler flags 
>> via 'configure ... --extra-cflags="-m32"'.
>
> You probably meant "without passing"?
>
> Nack. Please don't hardcode -mXX in configure, it's -arch ppc vs. 
> -arch ppc64 on my host/gcc. What's wrong with passing --extra-cflags?
>
I posted the following patch today for compiling libcacard with -m32 on 
a 64 bit machine.

http://lists.nongnu.org/archive/html/qemu-devel/2011-05/msg02909.html

It adds LDFLAGS. This works fine on x86-64. Then trying this out on 
ppc64 with -m32 in extra-cflags I find the following in config-host.mak

[...]
HELPER_CFLAGS=
LDFLAGS=-Wl,--warn-common -g
ARLIBS_BEGIN=
[...]

The -m32 doesn't make it into LDFLAGS. The below patch fixed it for me 
following the pattern of x86-64 and i686 a bit further up in the case 
statement in configure.

    Stefan

> Andreas
>
>> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
>>
>> ---
>> configure |    9 ++++++++-
>> 1 file changed, 8 insertions(+), 1 deletion(-)
>>
>> Index: qemu-git/configure
>> ===================================================================
>> --- qemu-git.orig/configure
>> +++ qemu-git/configure
>> @@ -807,7 +807,14 @@ case "$cpu" in
>>     arm*)
>>            host_guest_base="yes"
>>            ;;
>> -    ppc*)
>> +    ppc)
>> +           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
>> +           LDFLAGS="-m32 $LDFLAGS"
>> +           host_guest_base="yes"
>> +           ;;
>> +    ppc64)
>> +           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
>> +           LDFLAGS="-m64 $LDFLAGS"
>>            host_guest_base="yes"
>>            ;;
>>     mips*)
>
>
>
malc May 26, 2011, 8:42 p.m. UTC | #5
On Thu, 26 May 2011, Stefan Berger wrote:

> On 05/26/2011 04:20 PM, Andreas F?rber wrote:
> > Am 26.05.2011 um 21:00 schrieb Stefan Berger:
> > 
> > > With the below patch I can build either ppc (-m32) or ppc64 (-m64)
> > > versions of Qemu (on a ppc64 host) when passing these compiler flags via
> > > 'configure ... --extra-cflags="-m32"'.
> > 
> > You probably meant "without passing"?
> > 
> > Nack. Please don't hardcode -mXX in configure, it's -arch ppc vs. -arch
> > ppc64 on my host/gcc. What's wrong with passing --extra-cflags?
> > 
> I posted the following patch today for compiling libcacard with -m32 on a 64
> bit machine.
> 
> http://lists.nongnu.org/archive/html/qemu-devel/2011-05/msg02909.html
> 
> It adds LDFLAGS. This works fine on x86-64. Then trying this out on ppc64 with
> -m32 in extra-cflags I find the following in config-host.mak
> 
> [...]
> HELPER_CFLAGS=
> LDFLAGS=-Wl,--warn-common -g
> ARLIBS_BEGIN=
> [...]
> 
> The -m32 doesn't make it into LDFLAGS. The below patch fixed it for me
> following the pattern of x86-64 and i686 a bit further up in the case
> statement in configure.

[..snip..]

You can just do `./configure --cc="gcc -m[32|64]"'
Andreas Färber May 26, 2011, 9:24 p.m. UTC | #6
Am 26.05.2011 um 22:31 schrieb Stefan Berger:

> On 05/26/2011 04:20 PM, Andreas Färber wrote:
>> Am 26.05.2011 um 21:00 schrieb Stefan Berger:
>>
>>> With the below patch I can build either ppc (-m32) or ppc64 (-m64)  
>>> versions of Qemu (on a ppc64 host) when passing these compiler  
>>> flags via 'configure ... --extra-cflags="-m32"'.
>>
>> You probably meant "without passing"?
>>
>> Nack. Please don't hardcode -mXX in configure, it's -arch ppc vs. - 
>> arch ppc64 on my host/gcc. What's wrong with passing --extra-cflags?
>>
> I posted the following patch today for compiling libcacard with -m32  
> on a 64 bit machine.
>
> http://lists.nongnu.org/archive/html/qemu-devel/2011-05/msg02909.html
>
> It adds LDFLAGS. This works fine on x86-64. Then trying this out on  
> ppc64 with -m32 in extra-cflags I find the following in config- 
> host.mak
>
> [...]
> HELPER_CFLAGS=
> LDFLAGS=-Wl,--warn-common -g
> ARLIBS_BEGIN=
> [...]
>
> The -m32 doesn't make it into LDFLAGS. The below patch fixed it for  
> me following the pattern of x86-64 and i686 a bit further up in the  
> case statement in configure.

Erm, you did try --extra-ldflags for LDFLAGS, did you? That --extra- 
cflags doesn't end up there is intentional!

Andreas
Stefan Berger May 26, 2011, 10:25 p.m. UTC | #7
On 05/26/2011 05:24 PM, Andreas Färber wrote:
> Am 26.05.2011 um 22:31 schrieb Stefan Berger:
>
>> On 05/26/2011 04:20 PM, Andreas Färber wrote:
>>> Am 26.05.2011 um 21:00 schrieb Stefan Berger:
>>>
>>>> With the below patch I can build either ppc (-m32) or ppc64 (-m64) 
>>>> versions of Qemu (on a ppc64 host) when passing these compiler 
>>>> flags via 'configure ... --extra-cflags="-m32"'.
>>>
>>> You probably meant "without passing"?
>>>
>>> Nack. Please don't hardcode -mXX in configure, it's -arch ppc vs. 
>>> -arch ppc64 on my host/gcc. What's wrong with passing --extra-cflags?
>>>
>> I posted the following patch today for compiling libcacard with -m32 
>> on a 64 bit machine.
>>
>> http://lists.nongnu.org/archive/html/qemu-devel/2011-05/msg02909.html
>>
>> It adds LDFLAGS. This works fine on x86-64. Then trying this out on 
>> ppc64 with -m32 in extra-cflags I find the following in config-host.mak
>>
>> [...]
>> HELPER_CFLAGS=
>> LDFLAGS=-Wl,--warn-common -g
>> ARLIBS_BEGIN=
>> [...]
>>
>> The -m32 doesn't make it into LDFLAGS. The below patch fixed it for 
>> me following the pattern of x86-64 and i686 a bit further up in the 
>> case statement in configure.
>
> Erm, you did try --extra-ldflags for LDFLAGS, did you? That 
> --extra-cflags doesn't end up there is intentional!
>
No, I didn't. Here's what happened. On x86_64 host I used to be able to 
compile 32bit executables with --extra-cflags="-m32". That stopped 
working when libcacard showed up -- I posted a patch today -- only the 
linking of vscclient in libcacard/ didn't work. The "work-around" before 
the patch was --disable-smartcard. Now taking that same habit of passing 
--extra-cflags="-m32" to the ppc64 machine again didn't work, but was 
broken somewhere else. So this is where this is all coming from.

    Stefan

> Andreas
Paolo Bonzini May 27, 2011, 7:12 a.m. UTC | #8
On 05/26/2011 09:00 PM, Stefan Berger wrote:
> With the below patch I can build either ppc (-m32) or ppc64 (-m64)
> versions of Qemu (on a ppc64 host) when passing these compiler flags via
> 'configure ... --extra-cflags="-m32"'.
>
> Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
>
> ---
> configure | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> Index: qemu-git/configure
> ===================================================================
> --- qemu-git.orig/configure
> +++ qemu-git/configure
> @@ -807,7 +807,14 @@ case "$cpu" in
> arm*)
> host_guest_base="yes"
> ;;
> - ppc*)
> + ppc)
> + QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
> + LDFLAGS="-m32 $LDFLAGS"
> + host_guest_base="yes"
> + ;;
> + ppc64)
> + QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
> + LDFLAGS="-m64 $LDFLAGS"
> host_guest_base="yes"
> ;;
> mips*)

The patch doesn't seem to match the description.  I would have guessed 
that with this patch you _do not_ need to pass these compiler flags via 
--extra-cflags anymore.

Also, -m32/-m64 are really CPPFLAGS, not CFLAGS since they affect also 
the compiler's include path.

Paolo
Andreas Färber May 29, 2011, 9:09 p.m. UTC | #9
Am 27.05.2011 um 00:25 schrieb Stefan Berger:

> On 05/26/2011 05:24 PM, Andreas Färber wrote:
>> Am 26.05.2011 um 22:31 schrieb Stefan Berger:
>>
>>> On 05/26/2011 04:20 PM, Andreas Färber wrote:
>>>> Am 26.05.2011 um 21:00 schrieb Stefan Berger:
>>>>
>>>>> With the below patch I can build either ppc (-m32) or ppc64 (- 
>>>>> m64) versions of Qemu (on a ppc64 host) when passing these  
>>>>> compiler flags via 'configure ... --extra-cflags="-m32"'.
>>>>
>>>> You probably meant "without passing"?
>>>>
>>>> Nack. Please don't hardcode -mXX in configure, it's -arch ppc vs.  
>>>> -arch ppc64 on my host/gcc. What's wrong with passing --extra- 
>>>> cflags?
>>>>
>>> I posted the following patch today for compiling libcacard with - 
>>> m32 on a 64 bit machine.
>>>
>>> http://lists.nongnu.org/archive/html/qemu-devel/2011-05/ 
>>> msg02909.html
>>>
>>> It adds LDFLAGS. This works fine on x86-64. Then trying this out  
>>> on ppc64 with -m32 in extra-cflags I find the following in config- 
>>> host.mak
>>>
>>> [...]
>>> HELPER_CFLAGS=
>>> LDFLAGS=-Wl,--warn-common -g
>>> ARLIBS_BEGIN=
>>> [...]
>>>
>>> The -m32 doesn't make it into LDFLAGS. The below patch fixed it  
>>> for me following the pattern of x86-64 and i686 a bit further up  
>>> in the case statement in configure.
>>
>> Erm, you did try --extra-ldflags for LDFLAGS, did you? That --extra- 
>> cflags doesn't end up there is intentional!
>>
> No, I didn't. Here's what happened. On x86_64 host I used to be able  
> to compile 32bit executables with --extra-cflags="-m32". That  
> stopped working when libcacard showed up -- I posted a patch today  
> -- only the linking of vscclient in libcacard/ didn't work. The  
> "work-around" before the patch was --disable-smartcard. Now taking  
> that same habit of passing --extra-cflags="-m32" to the ppc64  
> machine again didn't work, but was broken somewhere else. So this is  
> where this is all coming from.

Stefan, I rather care about where this is going, and my unanswered  
question is: Does it work if you use --extra-cflags=-m32 --extra- 
ldflags=-m32?
If yes, then we can drop this patch and be good. Otherwise we need to  
think about a better solution.

Andreas
Stefan Berger May 29, 2011, 10:07 p.m. UTC | #10
On 05/29/2011 05:09 PM, Andreas Färber wrote:
> Am 27.05.2011 um 00:25 schrieb Stefan Berger:
>
>> On 05/26/2011 05:24 PM, Andreas Färber wrote:
>>> Am 26.05.2011 um 22:31 schrieb Stefan Berger:
>>>
>>>> On 05/26/2011 04:20 PM, Andreas Färber wrote:
>>>>> Am 26.05.2011 um 21:00 schrieb Stefan Berger:
>>>>>
>>>>>> With the below patch I can build either ppc (-m32) or ppc64 
>>>>>> (-m64) versions of Qemu (on a ppc64 host) when passing these 
>>>>>> compiler flags via 'configure ... --extra-cflags="-m32"'.
>>>>>
>>>>> You probably meant "without passing"?
>>>>>
>>>>> Nack. Please don't hardcode -mXX in configure, it's -arch ppc vs. 
>>>>> -arch ppc64 on my host/gcc. What's wrong with passing --extra-cflags?
>>>>>
>>>> I posted the following patch today for compiling libcacard with 
>>>> -m32 on a 64 bit machine.
>>>>
>>>> http://lists.nongnu.org/archive/html/qemu-devel/2011-05/msg02909.html
>>>>
>>>> It adds LDFLAGS. This works fine on x86-64. Then trying this out on 
>>>> ppc64 with -m32 in extra-cflags I find the following in 
>>>> config-host.mak
>>>>
>>>> [...]
>>>> HELPER_CFLAGS=
>>>> LDFLAGS=-Wl,--warn-common -g
>>>> ARLIBS_BEGIN=
>>>> [...]
>>>>
>>>> The -m32 doesn't make it into LDFLAGS. The below patch fixed it for 
>>>> me following the pattern of x86-64 and i686 a bit further up in the 
>>>> case statement in configure.
>>>
>>> Erm, you did try --extra-ldflags for LDFLAGS, did you? That 
>>> --extra-cflags doesn't end up there is intentional!
>>>
>> No, I didn't. Here's what happened. On x86_64 host I used to be able 
>> to compile 32bit executables with --extra-cflags="-m32". That stopped 
>> working when libcacard showed up -- I posted a patch today -- only 
>> the linking of vscclient in libcacard/ didn't work. The "work-around" 
>> before the patch was --disable-smartcard. Now taking that same habit 
>> of passing --extra-cflags="-m32" to the ppc64 machine again didn't 
>> work, but was broken somewhere else. So this is where this is all 
>> coming from.
>
> Stefan, I rather care about where this is going, and my unanswered 
> question is: Does it work if you use --extra-cflags=-m32 
> --extra-ldflags=-m32?
> If yes, then we can drop this patch and be good. Otherwise we need to 
> think about a better solution.
>
It works as you show above once this patch here has been applied:

http://lists.nongnu.org/archive/html/qemu-devel/2011-05/msg02909.html

    Stefan
diff mbox

Patch

Index: qemu-git/configure
===================================================================
--- qemu-git.orig/configure
+++ qemu-git/configure
@@ -807,7 +807,14 @@  case "$cpu" in
      arm*)
             host_guest_base="yes"
             ;;
-    ppc*)
+    ppc)
+           QEMU_CFLAGS="-m32 $QEMU_CFLAGS"
+           LDFLAGS="-m32 $LDFLAGS"
+           host_guest_base="yes"
+           ;;
+    ppc64)
+           QEMU_CFLAGS="-m64 $QEMU_CFLAGS"
+           LDFLAGS="-m64 $LDFLAGS"
             host_guest_base="yes"
             ;;
      mips*)