qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] kvm-unittest: fix build with gcc 4.3.X and olde


From: Michael S. Tsirkin
Subject: Re: [Qemu-devel] [PATCH] kvm-unittest: fix build with gcc 4.3.X and older
Date: Thu, 17 Oct 2013 12:28:58 +0300

On Thu, Oct 17, 2013 at 11:34:41AM +0300, Gleb Natapov wrote:
> On Thu, Oct 17, 2013 at 11:27:37AM +0300, Michael S. Tsirkin wrote:
> > On Thu, Oct 17, 2013 at 11:20:27AM +0300, Gleb Natapov wrote:
> > > On Thu, Oct 17, 2013 at 11:12:31AM +0300, Michael S. Tsirkin wrote:
> > > > On Thu, Oct 17, 2013 at 09:27:51AM +0300, Gleb Natapov wrote:
> > > > > On Wed, Oct 16, 2013 at 10:46:53PM +0300, Michael S. Tsirkin wrote:
> > > > > > Old GCC didn't let you reference variable by
> > > > > > number if it is listed with a specific register
> > > > > > constraint, on the assumption you can just
> > > > > > use the register name explicitly.
> > > > > > 
> > > > > > Build fails with errors like this:
> > > > > > a.c:6: error: invalid 'asm': invalid operand code 'd'
> > > > > > 
> > > > > Is it worth to support such ancient compiler? Nobody complained till
> > > > > now.
> > > > 
> > > > Well it's not as widely used as kvm itself yet :)
> > > > The patch seems simple enough though.
> > > > 
> > > > > BTW with your patch I still cannot compile with 4.2:
> > > > > 
> > > > > x86/s3.c: In function 'main':
> > > > > x86/s3.c:145: error: inconsistent operand constraints in an 'asm'
> > > > 
> > > > OK that's easy to fix.
> > > > 
> > > > > > To fix, let's just use %eax %al etc.
> > > > > > 
> > > > > Only %d0 does not work and dropping "d" fixes it since compiler can
> > > > > figure out correct register from variable size. The patch bellow fixes
> > > > > compilation for 4.2.
> > > > 
> > > > It does produce warnings with -Wall though:
> > > > Assembler messages:
> > > > Warning: using `%ax' instead of `%eax' due to `w' suffix
> > > > Warning: using `%al' instead of `%eax' due to `b' suffix
> > > > 
> > > Not for me. No warning with 4.7.3 and 4.2. .s file produced by gcc shows
> > > correct assembly with my patch.
> > 
> > 4.3 doesn't.
> > 
> I pretty much doubt that 4.2 and 4.7 produce correct assembly and 4.3
> does not. Which file is it? Send me .s file produced by it.

Tried to get it but problem went away after I reset and re-applied your
patch. I think I had some other change in there that
caused it, and blamed your patch incorrectly. Sorry.

> > We have the "a" constraint there anyway - so what's the issue with just
> > writing %eax etc? I think it's safer than relying on compiler to do
> > the right thing.
> > 
> It just papers over the problem. Compiler should either complain that it
> does not know what %w0 or complain that variable length does not match
> assembly

Of course it can't. Compiler does not parse assembly at all:
these are just constant strings as far as it's concerned.

> or use correct register.

Actually it does: it seems to correctly deduce
size from variable type.

So your patch looks good to me, please apply.


> --
>                       Gleb.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]