Skip to contentSkip to conversation

[6967] Temporary workaround for ppc on ppc

Qemu-devel malc 3 participants 7 messages Apr 2, 2009 – Jun 8, 2009 Kbuild

lore
Share & tools
lore

malc

author
#0 lore raw

Revision: 6967

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6967
Author:   malc
Date:     2009-04-02 01:16:39 +0000 (Thu, 02 Apr 2009)

Log Message:
-----------
Temporary workaround for ppc on ppc

target-ppc/translate.c puts values of type opcode_t into .opcodes section, using GCC extension to do so, and hoping that this will make them appear contiguously and in the source order in the resulting executable. This assumption is not safe and is known to be violated with certain versions of GCC, certain flags passed to it and on certain platforms (gcc 4.3.0, -O and PPC/PPC64 for instance)

The workaround consists of adding -fno-unit-at-a-time to the list of GCC command line options while building PPC translate.o on a PPC.

Modified Paths:
--------------
trunk/Makefile.target

Modified: trunk/Makefile.target
===================================================================

Makefile.target +4 -0
@@ -84,6 +84,10 @@
 HELPER_CFLAGS+=-fomit-frame-pointer
 endif
 
+ifeq ($(subst ppc64,ppc,$(ARCH))$(TARGET_BASE_ARCH),ppcppc)
+translate.o: CFLAGS := $(CFLAGS) $(call cc-option, $(CFLAGS), -fno-unit-at-a-time,)
+endif
+
 ifeq ($(ARCH),sparc)
   CFLAGS+=-ffixed-g2 -ffixed-g3
   ifneq ($(CONFIG_SOLARIS),yes)
#1 lore raw
Quoted 8 lines · malc

Revision: 6967

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6967

Author: malc
Date: 2009-04-02 01:16:39 +0000 (Thu, 02 Apr 2009)
Log Message:
-----------
Temporary workaround for ppc on ppc

Quoted 6 lines

target-ppc/translate.c puts values of type opcode_t into .opcodes section, using GCC extension to do so, and hoping that this will make them appear contiguously and in the source order in the resulting executable. This assumption is not safe and is known to be violated with certain versions of GCC, certain flags passed to it and on certain platforms (gcc 4.3.0, -O and PPC/PPC64 for instance)

I've always wondered if the section hack was a very clever one or too clever one, this makes it clear.

The section uses could be removed by moving the opcode tables towards the end of file and making the handler functions use normal C declarations or aided with a macro. That separates the function and its table entry a lot, but I guess we don't want to use the #include trick this time?

author
#2 lore raw
Quoted 16 lines · Blue Swirl
Quoted 8 lines · malc

Revision: 6967

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6967

Author: malc
Date: 2009-04-02 01:16:39 +0000 (Thu, 02 Apr 2009)
Log Message:
-----------
Temporary workaround for ppc on ppc

Quoted 6 lines

target-ppc/translate.c puts values of type opcode_t into .opcodes section, using GCC extension to do so, and hoping that this will make them appear contiguously and in the source order in the resulting executable. This assumption is not safe and is known to be violated with certain versions of GCC, certain flags passed to it and on certain platforms (gcc 4.3.0, -O and PPC/PPC64 for instance)

Quoted 4 lines

I've always wondered if the section hack was a very clever one or too clever one, this makes it clear.

The section uses could be removed by moving the opcode tables towards

There are _no_ opcode tables that's why it fails. The code just does

opcode_t in_section(.opcodes) start;
<lots of opcode_t>;
opcode_t in_section(.opcodes) end;

And then scans from &start to &end.

The only way, that i know of, to make that work is to indeed put things into a table (an array).

Quoted 4 lines

the end of file and making the handler functions use normal C declarations or aided with a macro. That separates the function and its table entry a lot, but I guess we don't want to use the #include trick this time?

I think PPC's translate.c should be just split and massaged a lot.

Signature · 1 line
mailto:[email protected]
#3 lore raw
Quoted 26 lines · malc
Quoted 16 lines · Blue Swirl
Quoted 8 lines · malc

Revision: 6967

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6967

Author: malc
Date: 2009-04-02 01:16:39 +0000 (Thu, 02 Apr 2009)
Log Message:
-----------
Temporary workaround for ppc on ppc

Quoted 6 lines

target-ppc/translate.c puts values of type opcode_t into .opcodes section, using GCC extension to do so, and hoping that this will make them appear contiguously and in the source order in the resulting executable. This assumption is not safe and is known to be violated with certain versions of GCC, certain flags passed to it and on certain platforms (gcc 4.3.0, -O and PPC/PPC64 for instance)

Quoted 4 lines

I've always wondered if the section hack was a very clever one or too clever one, this makes it clear.

The section uses could be removed by moving the opcode tables towards

There are _no_ opcode tables that's why it fails. The code just does

Quoted 8 lines

opcode_t in_section(.opcodes) start;
<lots of opcode_t>;
opcode_t in_section(.opcodes) end;

And then scans from &start to &end.

The only way, that i know of, to make that work is to indeed put things into a table (an array).

Yes, that's what I meant.

The alternative is to move the opcodes to a new file, which is included two times by translate.c, first to get the opcode function definitions and second time to construct the table. This is what I meant with the #include trick below.

Quoted 7 lines
Quoted 4 lines

the end of file and making the handler functions use normal C declarations or aided with a macro. That separates the function and its table entry a lot, but I guess we don't want to use the #include trick this time?

I think PPC's translate.c should be just split and massaged a lot.

Fully agree.

author
#4 lore raw
Quoted 36 lines · Blue Swirl
Quoted 26 lines · malc
Quoted 16 lines · Blue Swirl
Quoted 8 lines · malc

Revision: 6967

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6967

Author: malc
Date: 2009-04-02 01:16:39 +0000 (Thu, 02 Apr 2009)
Log Message:
-----------
Temporary workaround for ppc on ppc

Quoted 6 lines

target-ppc/translate.c puts values of type opcode_t into .opcodes section, using GCC extension to do so, and hoping that this will make them appear contiguously and in the source order in the resulting executable. This assumption is not safe and is known to be violated with certain versions of GCC, certain flags passed to it and on certain platforms (gcc 4.3.0, -O and PPC/PPC64 for instance)

Quoted 4 lines

I've always wondered if the section hack was a very clever one or too clever one, this makes it clear.

The section uses could be removed by moving the opcode tables towards

There are _no_ opcode tables that's why it fails. The code just does

Quoted 8 lines

opcode_t in_section(.opcodes) start;
<lots of opcode_t>;
opcode_t in_section(.opcodes) end;

And then scans from &start to &end.

The only way, that i know of, to make that work is to indeed put things into a table (an array).

Quoted 6 lines

Yes, that's what I meant.

The alternative is to move the opcodes to a new file, which is included two times by translate.c, first to get the opcode function definitions and second time to construct the table. This is what I meant with the #include trick below.

That should work yeah.

Quoted 11 lines
Quoted 7 lines
Quoted 4 lines

the end of file and making the handler functions use normal C declarations or aided with a macro. That separates the function and its table entry a lot, but I guess we don't want to use the #include trick this time?

I think PPC's translate.c should be just split and massaged a lot.

Fully agree.

Signature · 1 line
mailto:[email protected]
#5 lore raw
In reply to malc
Quoted 28 lines · malc

Revision: 6967

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6967
Author:   malc
Date:     2009-04-02 01:16:39 +0000 (Thu, 02 Apr 2009)

Log Message:
-----------
Temporary workaround for ppc on ppc

target-ppc/translate.c puts values of type opcode_t into .opcodes section, using GCC extension to do so, and hoping that this will make them appear contiguously and in the source order in the resulting executable. This assumption is not safe and is known to be violated with certain versions of GCC, certain flags passed to it and on certain platforms (gcc 4.3.0, -O and PPC/PPC64 for instance)

The workaround consists of adding -fno-unit-at-a-time to the list of GCC command line options while building PPC translate.o on a PPC.

Modified Paths:
--------------
trunk/Makefile.target

Modified: trunk/Makefile.target
===================================================================

Makefile.target line 93

Quoted 10 lines
Makefile.target +4 -0
@@ -84,6 +84,10 @@
 HELPER_CFLAGS+=-fomit-frame-pointer
 endif
 
+ifeq ($(subst ppc64,ppc,$(ARCH))$(TARGET_BASE_ARCH),ppcppc)
+translate.o: CFLAGS := $(CFLAGS) $(call cc-option, $(CFLAGS), -fno-unit-at-a-time,)
+endif
+
 ifeq ($(ARCH),sparc)
   CFLAGS+=-ffixed-g2 -ffixed-g3
   ifneq ($(CONFIG_SOLARIS),yes)

Could we get this applied to the stable branch? It goes some way to fixing qemu-system-ppc on a ppc host in Fedora 11:

https://bugzilla.redhat.com/504273

Cheers,
Mark.

author
#6 lore raw
Quoted 43 lines · Mark McLoughlin
Quoted 28 lines · malc

Revision: 6967

          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6967
Author:   malc
Date:     2009-04-02 01:16:39 +0000 (Thu, 02 Apr 2009)

Log Message:
-----------
Temporary workaround for ppc on ppc

target-ppc/translate.c puts values of type opcode_t into .opcodes section, using GCC extension to do so, and hoping that this will make them appear contiguously and in the source order in the resulting executable. This assumption is not safe and is known to be violated with certain versions of GCC, certain flags passed to it and on certain platforms (gcc 4.3.0, -O and PPC/PPC64 for instance)

The workaround consists of adding -fno-unit-at-a-time to the list of GCC command line options while building PPC translate.o on a PPC.

Modified Paths:
--------------
trunk/Makefile.target

Modified: trunk/Makefile.target
===================================================================

Makefile.target line 93

Quoted 10 lines
Makefile.target +4 -0
@@ -84,6 +84,10 @@
 HELPER_CFLAGS+=-fomit-frame-pointer
 endif
 
+ifeq ($(subst ppc64,ppc,$(ARCH))$(TARGET_BASE_ARCH),ppcppc)
+translate.o: CFLAGS := $(CFLAGS) $(call cc-option, $(CFLAGS), -fno-unit-at-a-time,)
+endif
+
 ifeq ($(ARCH),sparc)
   CFLAGS+=-ffixed-g2 -ffixed-g3
   ifneq ($(CONFIG_SOLARIS),yes)

Could we get this applied to the stable branch? It goes some way to fixing qemu-system-ppc on a ppc host in Fedora 11:

Quoted 1 line

https://bugzilla.redhat.com/504273

I was contemplating replacing it with less far reaching -fno-toplevel-reorder, can you test if it works with whatever F11 is shipping?

Signature · 1 line
mailto:[email protected]