Skip to contentSkip to conversation

build: compile translate.o at -O1 optimization

PATCH In review Paolo Bonzini 7 participants 12 messages Nov 27, 2012 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 build: compile translate.o at -O1 optimization

Some versions of GCC require insane (>2GB) amounts of memory to compile translate.o. As a countermeasure, compile it with -O1. This should fix the buildbot failure for default_x86_64_fedora16.

---
 Makefile.target | 2 ++
 1 file changed, 2 insertions(+)
Makefile.target +2 -0
index 8b658c0..3981931 100644
@@ -143,6 +143,8 @@ GENERATED_HEADERS += hmp-commands.h qmp-commands-old.h
 
 endif # CONFIG_SOFTMMU
 
+%/translate.o: CFLAGS := $(patsubst -O2,-O1,$(CFLAGS))
+
 nested-vars += obj-y
 
 # This resolves all nested paths, so it must come last
Signature · 1 line
1.8.0
#1 lore raw
Quoted 4 lines · Paolo Bonzini

Some versions of GCC require insane (>2GB) amounts of memory to compile translate.o. As a countermeasure, compile it with -O1. This should fix the buildbot failure for default_x86_64_fedora16.

This is a well known bug in old gcc (ie fixed in 4.5, 4.6 and trunk a year ago). Use a newer gcc, or a 64 bit build system with a reasonable amount of RAM, or as a workaround apply some suitable compiler flags by passing configure '--extra-cflags=-fno-var-tracking'. This patch definitely shouldn't be applied as we shouldn't be hampering the majority for the benefit of old broken systems.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48190
https://bugs.launchpad.net/gcc-linaro/+bug/714921

-- PMM

#2 lore raw
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Paolo Bonzini

Some versions of GCC require insane (>2GB) amounts of memory to compile translate.o. As a countermeasure, compile it with -O1. This should fix the buildbot failure for default_x86_64_fedora16.

Quoted 7 lines

This is a well known bug in old gcc (ie fixed in 4.5, 4.6 and trunk a year ago). Use a newer gcc, or a 64 bit build system with a reasonable amount of RAM, or as a workaround apply some suitable compiler flags by passing configure '--extra-cflags=-fno-var-tracking'. This patch definitely shouldn't be applied as we shouldn't be hampering the majority for the benefit of old broken systems.

It isn't that simple. It's Fedora 17 with gcc 4.7.2 which runs oom while compiling translate.c

cheers,
Gerd

#3 lore raw
Quoted 11 lines · Gerd Hoffmann
Quoted 7 lines · Peter Maydell

This is a well known bug in old gcc (ie fixed in 4.5, 4.6 and trunk a year ago). Use a newer gcc, or a 64 bit build system with a reasonable amount of RAM, or as a workaround apply some suitable compiler flags by passing configure '--extra-cflags=-fno-var-tracking'. This patch definitely shouldn't be applied as we shouldn't be hampering the majority for the benefit of old broken systems.

It isn't that simple. It's Fedora 17 with gcc 4.7.2 which runs oom while compiling translate.c

In that case it is a new (or regressed) gcc bug and we should be pursuing it with the upstream gcc folk. We still shouldn't be putting random workarounds in our configure script.

-- PMM

#4 lore raw

Il 27/11/2012 14:46, Peter Maydell ha scritto:

Quoted 10 lines · Gerd Hoffmann
Quoted 9 lines · Peter Maydell
Quoted 7 lines

This is a well known bug in old gcc (ie fixed in 4.5, 4.6 and trunk a year ago). Use a newer gcc, or a 64 bit build system with a reasonable amount of RAM, or as a workaround apply some suitable compiler flags by passing configure '--extra-cflags=-fno-var-tracking'. This patch definitely shouldn't be applied as we shouldn't be hampering the majority for the benefit of old broken systems.

Quoted 6 lines
Quoted 2 lines

It isn't that simple. It's Fedora 17 with gcc 4.7.2 which runs oom while compiling translate.c

In that case it is a new (or regressed) gcc bug and we should be pursuing it with the upstream gcc folk. We still shouldn't be putting random workarounds in our configure script.

Sure we should, but we're also one week from release. Pretty sure a lot of people will compile QEMU on a machine with <2GB and fail; the choice is between documenting the problem and workaround in the release information, or doing it for everyone in the Makefile.

Unfortunately, this one is not fixed by settling for worse debug information, and it happens with GCC 4.7.2 (latest stable). It is fixed in GCC trunk, but it is also possible that it is just latent because I found that several GCC switches fix it:

* -fPIE is what causes it. Removing it obviously fixes it, but I'm not sure it is a good idea (does it break linux-user self-virtualization?)

* -fno-gcse turns off the pass that explodes, and fixes it

* -fno-tree-pre turns off a similar but unrelated pass, but also fixes it (found by chance because I confused it with -fno-gcse :)).

I think -fno-gcse is a valid workaround, and better than this patch.

Paolo

#5 lore raw
In reply to Gerd Hoffmann
Quoted 15 lines · Gerd Hoffmann
Quoted 6 lines · Peter Maydell
Quoted 4 lines · Paolo Bonzini

Some versions of GCC require insane (>2GB) amounts of memory to compile translate.o. As a countermeasure, compile it with -O1. This should fix the buildbot failure for default_x86_64_fedora16.

Quoted 7 lines

This is a well known bug in old gcc (ie fixed in 4.5, 4.6 and trunk a year ago). Use a newer gcc, or a 64 bit build system with a reasonable amount of RAM, or as a workaround apply some suitable compiler flags by passing configure '--extra-cflags=-fno-var-tracking'. This patch definitely shouldn't be applied as we shouldn't be hampering the majority for the benefit of old broken systems.

Quoted 2 lines

It isn't that simple. It's Fedora 17 with gcc 4.7.2 which runs oom while compiling translate.c

Even apply Peter's suggestion? Do all gcc 4.7.2 on various platform
have the same problem, or it only happen on Fedora 17.

Regards,
chenwj

Signature · 5 lines
Wei-Ren Chen (陳韋任)
Computer Systems Lab, Institute of Information Science,
Academia Sinica, Taiwan (R.O.C.)
Tel:886-2-2788-3799 #1667
Homepage: http://people.cs.nctu.edu.tw/~chenwj
#6 lore raw

Il 27/11/2012 14:49, 陳韋任 (Wei-Ren Chen) ha scritto:

Quoted 4 lines
Quoted 2 lines
Quoted 2 lines

It isn't that simple. It's Fedora 17 with gcc 4.7.2 which runs oom while compiling translate.c

Even apply Peter's suggestion? Do all gcc 4.7.2 on various platform
have the same problem, or it only happen on Fedora 17.

All. It is reproducible with GCC's stable branch from the FSF repository. I'm testing a patch, but it will take more than 1 week to get it to the distros.

Paolo

#7 lore raw
In reply to 陳韋任 (Wei-Ren Chen)

Am 27.11.2012 14:49, schrieb 陳韋任 (Wei-Ren Chen):

Quoted 16 lines · Gerd Hoffmann
Quoted 15 lines · Peter Maydell
Quoted 13 lines · Paolo Bonzini
Quoted 4 lines

Some versions of GCC require insane (>2GB) amounts of memory to compile translate.o. As a countermeasure, compile it with -O1. This should fix the buildbot failure for default_x86_64_fedora16.

This is a well known bug in old gcc (ie fixed in 4.5, 4.6 and trunk a year ago). Use a newer gcc, or a 64 bit build system with a reasonable amount of RAM, or as a workaround apply some suitable compiler flags by passing configure '--extra-cflags=-fno-var-tracking'. This patch definitely shouldn't be applied as we shouldn't be hampering the majority for the benefit of old broken systems.

Quoted 5 lines
Quoted 2 lines

It isn't that simple. It's Fedora 17 with gcc 4.7.2 which runs oom while compiling translate.c

Even apply Peter's suggestion? Do all gcc 4.7.2 on various platform
have the same problem, or it only happen on Fedora 17.

I ran into the same problem with various versions of openSUSE in the openSUSE Build Service where v1.2 built fine.

openSUSE Factory is using gcc 4.7.2, 12.2 4.7.1.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#8 lore raw
In reply to Paolo Bonzini
Quoted 15 lines · Paolo Bonzini

Some versions of GCC require insane (>2GB) amounts of memory to compile translate.o. As a countermeasure, compile it with -O1. This should fix the buildbot failure for default_x86_64_fedora16.

---
 Makefile.target | 2 ++
 1 file changed, 2 insertions(+)
Makefile.target +0 -0
index 8b658c0..3981931 100644

Makefile.target GENERATED_HEADERS += hmp-commands.h qmp-commands-old.h · line 147

Quoted 5 lines
Makefile.target +2 -0
@@ -143,6 +143,8 @@ GENERATED_HEADERS += hmp-commands.h qmp-commands-old.h
 
 endif # CONFIG_SOFTMMU
 
+%/translate.o: CFLAGS := $(patsubst -O2,-O1,$(CFLAGS))
+

This may change some string argument in CFLAGS, for example an argument to -I.

How about:

  CFLAGS_opt = -O2
  CFLAGS += $(CFLAGS_opt)
  ...
  %/translate.o: CFLAGS_opt = -O1
Signature · 1 line
error compiling committee.c: too many arguments to function
#9 lore raw

Il 27/11/2012 16:53, Avi Kivity ha scritto:

Quoted 9 lines

This may change some string argument in CFLAGS, for example an argument to -I.

How about:

  CFLAGS_opt = -O2
  CFLAGS += $(CFLAGS_opt)
  ...
  %/translate.o: CFLAGS_opt = -O1

Not possible because CFLAGS comes from configure, but anyway what I'm going to do is

%/translate.o: QEMU_CFLAGS += -fno-gcse

now that Gerd found the culprit patch.

Paolo

#10 lore raw
In reply to Avi Kivity
Quoted 25 lines · Avi Kivity
Quoted 15 lines · Paolo Bonzini

Some versions of GCC require insane (>2GB) amounts of memory to compile translate.o. As a countermeasure, compile it with -O1. This should fix the buildbot failure for default_x86_64_fedora16.

---
 Makefile.target | 2 ++
 1 file changed, 2 insertions(+)
Makefile.target +0 -0
index 8b658c0..3981931 100644

Makefile.target GENERATED_HEADERS += hmp-commands.h qmp-commands-old.h · line 147

Quoted 5 lines
Makefile.target +2 -0
@@ -143,6 +143,8 @@ GENERATED_HEADERS += hmp-commands.h qmp-commands-old.h
 
 endif # CONFIG_SOFTMMU
 
+%/translate.o: CFLAGS := $(patsubst -O2,-O1,$(CFLAGS))
+

This may change some string argument in CFLAGS, for example an argument to -I.

Quoted 6 lines

How about:

  CFLAGS_opt = -O2
  CFLAGS += $(CFLAGS_opt)
  ...
  %/translate.o: CFLAGS_opt = -O1

Just append -O1 to CFLAGS; the last -O wins.

#11 lore raw

Il 27/11/2012 17:49, Markus Armbruster ha scritto:

Quoted 6 lines
Quoted 6 lines
Quoted 2 lines

+%/translate.o: CFLAGS := $(patsubst -O2,-O1,$(CFLAGS)) +

This may change some string argument in CFLAGS, for example an argument to -I.

Quoted 8 lines
Quoted 6 lines

How about:

  CFLAGS_opt = -O2
  CFLAGS += $(CFLAGS_opt)
  ...
  %/translate.o: CFLAGS_opt = -O1

Just append -O1 to CFLAGS; the last -O wins.

But you don't want to override -O0...

Anyhow, v2 was posted and does it in a different, more fine-grained manner.

Paolo