qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] Patch for compiling with GCC 4
@ 2008-02-16 11:22 Christian Roue
  2008-02-16 20:01 ` Paul Brook
  0 siblings, 1 reply; 7+ messages in thread
From: Christian Roue @ 2008-02-16 11:22 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 958 bytes --]

Hi all,
I tried to compile qemu cvs head on my x86_64 linux with gcc 4.1.2 using
--disable-gcc-check, I found compile fails as stated in configure before i
disabled gcc check..
Error message, points to a problem of dyngen not correctly detecting
function ends on i386 when last instruction is a jump. I applied following
change and successfully compiled/run qemu i386.  This extra test check for
a relative backward jump  to function exit ret,
gcc 4 apparently generates a few of these.

My small change to cvs head is :

--- dyngen.c       2008-02-13 18:54:36.000000000 +0100
+++ dyngen.c    2008-02-13 19:10:14.000000000 +0100
@@ -1474,7 +1474,7 @@
         len = p_end - p_start;
         if (len == 0)
             error("empty code for %s", name);
-        if (p_end[-1] == 0xc3) {
+        if (p_end[-1] == 0xc3 || p_end[-2] == 0xeb) {
             len--;
         } else {
             error("ret or jmp expected at the end of %s", name);

Bye
Chris.

[-- Attachment #2: Type: text/html, Size: 1482 bytes --]

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

* Re: [Qemu-devel] Patch for compiling with GCC 4
  2008-02-16 11:22 [Qemu-devel] Patch for compiling with GCC 4 Christian Roue
@ 2008-02-16 20:01 ` Paul Brook
  2008-02-17 20:22   ` Christian Roue
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Brook @ 2008-02-16 20:01 UTC (permalink / raw)
  To: qemu-devel; +Cc: Christian Roue

On Saturday 16 February 2008, Christian Roue wrote:
> Hi all,
> I tried to compile qemu cvs head on my x86_64 linux with gcc 4.1.2 using
> --disable-gcc-check, I found compile fails as stated in configure before i
> disabled gcc check..
> Error message, points to a problem of dyngen not correctly detecting
> function ends on i386 when last instruction is a jump. I applied following
> change and successfully compiled/run qemu i386.  This extra test check for
> a relative backward jump  to function exit ret,
> gcc 4 apparently generates a few of these.

You patch is wrong. The dyngen error is correct.

Paul

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

* Re: [Qemu-devel] Patch for compiling with GCC 4
  2008-02-16 20:01 ` Paul Brook
@ 2008-02-17 20:22   ` Christian Roue
  2008-02-18 12:07     ` Alexander Graf
  0 siblings, 1 reply; 7+ messages in thread
From: Christian Roue @ 2008-02-17 20:22 UTC (permalink / raw)
  To: Paul Brook; +Cc: qemu-devel

Well, I somehow felt like it was a bit brutal and probably fixing the
symptoms which is apparently the case.
Looking more carefully, compile fails in :
sh4-linux-user for function op_cmp_str_T0_T1
gcc optimization leads to a ret followed by a last assignement with a jump back.
I guess dyngen hopes to find function epilogue as the last bytes.
It's apparently the only function where it happens.

I found that adding gcc option "-fno-tree-dominator-opts" for sh4
target avoids this (I suppose) unwanted optimization.
It may be a bit brutal again ( disabling too many optims or wrong ones).
May be the op_cmp_str_T0_T1 function can be rewritten to something
that avoids this optimization.
Am I on a better track ?

Bye
Chris.


On Feb 16, 2008 9:01 PM, Paul Brook <paul@codesourcery.com> wrote:
> On Saturday 16 February 2008, Christian Roue wrote:
> > Hi all,
> > I tried to compile qemu cvs head on my x86_64 linux with gcc 4.1.2 using
> > --disable-gcc-check, I found compile fails as stated in configure before i
> > disabled gcc check..
> > Error message, points to a problem of dyngen not correctly detecting
> > function ends on i386 when last instruction is a jump. I applied following
> > change and successfully compiled/run qemu i386.  This extra test check for
> > a relative backward jump  to function exit ret,
> > gcc 4 apparently generates a few of these.
>
> You patch is wrong. The dyngen error is correct.
>
> Paul
>

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

* Re: [Qemu-devel] Patch for compiling with GCC 4
  2008-02-17 20:22   ` Christian Roue
@ 2008-02-18 12:07     ` Alexander Graf
  2008-02-18 19:52       ` Christian Roue
  2008-02-18 20:49       ` Thiemo Seufer
  0 siblings, 2 replies; 7+ messages in thread
From: Alexander Graf @ 2008-02-18 12:07 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Brook


On Feb 17, 2008, at 9:22 PM, Christian Roue wrote:

> Well, I somehow felt like it was a bit brutal and probably fixing the
> symptoms which is apparently the case.
> Looking more carefully, compile fails in :
> sh4-linux-user for function op_cmp_str_T0_T1
> gcc optimization leads to a ret followed by a last assignement with  
> a jump back.
> I guess dyngen hopes to find function epilogue as the last bytes.
> It's apparently the only function where it happens.
>
> I found that adding gcc option "-fno-tree-dominator-opts" for sh4
> target avoids this (I suppose) unwanted optimization.
> It may be a bit brutal again ( disabling too many optims or wrong  
> ones).
> May be the op_cmp_str_T0_T1 function can be rewritten to something
> that avoids this optimization.
> Am I on a better track ?

This looks like the right approach to the symptoms. The "real fix"  
would be to move the sh4 target to TCG, but for the meantime I believe  
this is the way to go. You can already find a lot of these  
unoptimization flags autodetected in the configure script, so I guess  
that'd be the right place for a patch.

I am not sure if anybody with commit right listens, though.

Regards,

Alex

>
>
> Bye
> Chris.
>
>
> On Feb 16, 2008 9:01 PM, Paul Brook <paul@codesourcery.com> wrote:
>> On Saturday 16 February 2008, Christian Roue wrote:
>>> Hi all,
>>> I tried to compile qemu cvs head on my x86_64 linux with gcc 4.1.2  
>>> using
>>> --disable-gcc-check, I found compile fails as stated in configure  
>>> before i
>>> disabled gcc check..
>>> Error message, points to a problem of dyngen not correctly detecting
>>> function ends on i386 when last instruction is a jump. I applied  
>>> following
>>> change and successfully compiled/run qemu i386.  This extra test  
>>> check for
>>> a relative backward jump  to function exit ret,
>>> gcc 4 apparently generates a few of these.
>>
>> You patch is wrong. The dyngen error is correct.
>>
>> Paul
>>
>
>

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

* Re: [Qemu-devel] Patch for compiling with GCC 4
  2008-02-18 12:07     ` Alexander Graf
@ 2008-02-18 19:52       ` Christian Roue
  2008-02-18 20:49       ` Thiemo Seufer
  1 sibling, 0 replies; 7+ messages in thread
From: Christian Roue @ 2008-02-18 19:52 UTC (permalink / raw)
  To: qemu-devel

Alex,
thanks for the hint.
I'll have a look at TCG.

Bye
Chris.


On Feb 18, 2008 1:07 PM, Alexander Graf <alex@csgraf.de> wrote:
>
> On Feb 17, 2008, at 9:22 PM, Christian Roue wrote:
>
> > Well, I somehow felt like it was a bit brutal and probably fixing the
> > symptoms which is apparently the case.
> > Looking more carefully, compile fails in :
> > sh4-linux-user for function op_cmp_str_T0_T1
> > gcc optimization leads to a ret followed by a last assignement with
> > a jump back.
> > I guess dyngen hopes to find function epilogue as the last bytes.
> > It's apparently the only function where it happens.
> >
> > I found that adding gcc option "-fno-tree-dominator-opts" for sh4
> > target avoids this (I suppose) unwanted optimization.
> > It may be a bit brutal again ( disabling too many optims or wrong
> > ones).
> > May be the op_cmp_str_T0_T1 function can be rewritten to something
> > that avoids this optimization.
> > Am I on a better track ?
>
> This looks like the right approach to the symptoms. The "real fix"
> would be to move the sh4 target to TCG, but for the meantime I believe
> this is the way to go. You can already find a lot of these
> unoptimization flags autodetected in the configure script, so I guess
> that'd be the right place for a patch.
>
> I am not sure if anybody with commit right listens, though.
>
> Regards,
>
> Alex
>
>
> >
> >
> > Bye
> > Chris.
> >
> >
> > On Feb 16, 2008 9:01 PM, Paul Brook <paul@codesourcery.com> wrote:
> >> On Saturday 16 February 2008, Christian Roue wrote:
> >>> Hi all,
> >>> I tried to compile qemu cvs head on my x86_64 linux with gcc 4.1.2
> >>> using
> >>> --disable-gcc-check, I found compile fails as stated in configure
> >>> before i
> >>> disabled gcc check..
> >>> Error message, points to a problem of dyngen not correctly detecting
> >>> function ends on i386 when last instruction is a jump. I applied
> >>> following
> >>> change and successfully compiled/run qemu i386.  This extra test
> >>> check for
> >>> a relative backward jump  to function exit ret,
> >>> gcc 4 apparently generates a few of these.
> >>
> >> You patch is wrong. The dyngen error is correct.
> >>
> >> Paul
> >>
> >
> >
>
>
>
>

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

* Re: [Qemu-devel] Patch for compiling with GCC 4
  2008-02-18 12:07     ` Alexander Graf
  2008-02-18 19:52       ` Christian Roue
@ 2008-02-18 20:49       ` Thiemo Seufer
  2008-02-19 19:12         ` Christian Roue
  1 sibling, 1 reply; 7+ messages in thread
From: Thiemo Seufer @ 2008-02-18 20:49 UTC (permalink / raw)
  To: Alexander Graf; +Cc: qemu-devel, Paul Brook

Alexander Graf wrote:
>
> On Feb 17, 2008, at 9:22 PM, Christian Roue wrote:
>
>> Well, I somehow felt like it was a bit brutal and probably fixing the
>> symptoms which is apparently the case.
>> Looking more carefully, compile fails in :
>> sh4-linux-user for function op_cmp_str_T0_T1
>> gcc optimization leads to a ret followed by a last assignement with a 
>> jump back.
>> I guess dyngen hopes to find function epilogue as the last bytes.
>> It's apparently the only function where it happens.
>>
>> I found that adding gcc option "-fno-tree-dominator-opts" for sh4
>> target avoids this (I suppose) unwanted optimization.
>> It may be a bit brutal again ( disabling too many optims or wrong  
>> ones).
>> May be the op_cmp_str_T0_T1 function can be rewritten to something
>> that avoids this optimization.
>> Am I on a better track ?
>
> This looks like the right approach to the symptoms. The "real fix" would 
> be to move the sh4 target to TCG,

The migration to tcg can be done gradually, fixing the immediate problem
shouldn't get too involved.

> but for the meantime I believe this is 
> the way to go. You can already find a lot of these unoptimization flags 
> autodetected in the configure script, so I guess that'd be the right 
> place for a patch.

I added those as workarounds, they should rather go away than expand to
cover even more flags.


Thiemo

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

* Re: [Qemu-devel] Patch for compiling with GCC 4
  2008-02-18 20:49       ` Thiemo Seufer
@ 2008-02-19 19:12         ` Christian Roue
  0 siblings, 0 replies; 7+ messages in thread
From: Christian Roue @ 2008-02-19 19:12 UTC (permalink / raw)
  To: qemu-devel

Thanks Thiemo.
I'll look at TCG, some more doc reading ahead apparently.

Bye
Chris

On Feb 18, 2008 9:49 PM, Thiemo Seufer <ths@networkno.de> wrote:
> Alexander Graf wrote:
> >
> > On Feb 17, 2008, at 9:22 PM, Christian Roue wrote:
> >
> >> Well, I somehow felt like it was a bit brutal and probably fixing the
> >> symptoms which is apparently the case.
> >> Looking more carefully, compile fails in :
> >> sh4-linux-user for function op_cmp_str_T0_T1
> >> gcc optimization leads to a ret followed by a last assignement with a
> >> jump back.
> >> I guess dyngen hopes to find function epilogue as the last bytes.
> >> It's apparently the only function where it happens.
> >>
> >> I found that adding gcc option "-fno-tree-dominator-opts" for sh4
> >> target avoids this (I suppose) unwanted optimization.
> >> It may be a bit brutal again ( disabling too many optims or wrong
> >> ones).
> >> May be the op_cmp_str_T0_T1 function can be rewritten to something
> >> that avoids this optimization.
> >> Am I on a better track ?
> >
> > This looks like the right approach to the symptoms. The "real fix" would
> > be to move the sh4 target to TCG,
>
> The migration to tcg can be done gradually, fixing the immediate problem
> shouldn't get too involved.
>
> > but for the meantime I believe this is
> > the way to go. You can already find a lot of these unoptimization flags
> > autodetected in the configure script, so I guess that'd be the right
> > place for a patch.
>
> I added those as workarounds, they should rather go away than expand to
> cover even more flags.
>
>
> Thiemo
>
>
>

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

end of thread, other threads:[~2008-02-19 19:12 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-16 11:22 [Qemu-devel] Patch for compiling with GCC 4 Christian Roue
2008-02-16 20:01 ` Paul Brook
2008-02-17 20:22   ` Christian Roue
2008-02-18 12:07     ` Alexander Graf
2008-02-18 19:52       ` Christian Roue
2008-02-18 20:49       ` Thiemo Seufer
2008-02-19 19:12         ` Christian Roue

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