does not work with clang

Reported by lp-void on 2012-05-08
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
QEMU
Undecided
Unassigned

Bug Description

Frozen on start.

CPU: dual-core 64-bit penryn
MacOS: 10.7.3-x86_64
Xcode: 4.3.2
CC: /usr/bin/clang
CXX: /usr/bin/clang++ => /usr/bin/clang
LD: /usr/bin/clang
CFLAGS: -Os -w -pipe -march=native -Qunused-arguments
CXXFLAGS: -Os -w -pipe -march=native -Qunused-arguments
MAKEFLAGS: -j2

Wei-Ren Chen (chenwj) wrote :

IIRC, clang doesn't support global register yet. Do you configure QEMU to use TCI? What's the version of Clang and QEMU you're using?

lp-void (lp-void) wrote :

This one does not compile:

./configure --prefix=/usr/local/Cellar/qemu/1.0.1 --cc=/usr/bin/clang --host-cc=/usr/bin/clang --disable-darwin-user --enable-cocoa --disable-bsd-user --disable-guest-agent

> In file included from /private/tmp/homebrew-qemu-1.0.1-CpcD/qemu-1.0.1/target-i386/op_helper.c:22:
/private/tmp/homebrew-qemu-1.0.1-CpcD/qemu-1.0.1/dyngen-exec.h:64:20: error: global register variables are not supported
register CPUState *env asm(AREG0);

This one compiles but freezes immediately:

./configure --prefix=/usr/local/Cellar/qemu/1.0.1 --cc=/usr/bin/llvm-gcc --host-cc=/usr/bin/llvm-gcc --disable-darwin-user --enable-cocoa --disable-bsd-user --disable-guest-agent

These two patches are applied:
https://trac.macports.org/export/92470/trunk/dports/emulators/qemu/files/patch-configure.diff
https://trac.macports.org/export/92470/trunk/dports/emulators/qemu/files/patch-cocoa-uint16-redefined.diff

Wei-Ren Chen (chenwj) wrote :

O.K., the first thing you need to know is llvm-gcc uses GCC as it's frontend to parse your source code, and uses LLVM as it's backend to generate binary. In order to support global register correctly, not only the frontend has to be able to recognize the global register syntax, but also the LLVM backend is required to do the right thing. Since LLVM doesn't support global register, even llvm-gcc can recognize the global register syntax (uses GCC frontend), it cannot generate correct binary. So this might be the problem you hit.

lp-void (lp-void) wrote :

& there is no configure option to avoid using global registers ?

Wei-Ren Chen (chenwj) wrote :

You can try to configure QEMU to use TCI (interpreter) rather then TCG (jitter). IIRC, TCI doesn't use global register.

lp-void (lp-void) wrote :

Can you please show me where to find configure options or specific options to accomplish that ?

Wei-Ren Chen (chenwj) wrote :

  `../qemu/configure --enable-tcg-interpreter` will use TCI not TCG. You can use `configure --help` to see what options it provides.

lp-void (lp-void) wrote :

I was thinking there must be something like that ;-) thanks! btw why this site is so nazi about deleting or editing comments ? :-] makes me feel like I am in court in murder trial

lp-void (lp-void) wrote :

It works! with --enable-tcg-interpreter!

Wei-Ren Chen (chenwj) wrote :

You can send launchpad a bug report talking about this. ;-)

Wei-Ren Chen (chenwj) wrote :

So O.K. to close? :-)

lp-void (lp-void) wrote :

Sure! thanks again!

lp-void (lp-void) on 2012-05-09
visibility: public → private
lp-void (lp-void) on 2012-05-09
visibility: private → public
Paolo Bonzini (bonzini) on 2012-09-11
Changed in qemu:
status: New → Fix Committed

I tried another approach in my patch for the package in fink on Mac OS X. Since dyngen-exec.h seems to be the only place with a GLOBAL register variable, I removed register from the variable declaration. So far, it seems to work. Regarding an impact on performance, I have no information. Has anyone an idea about it?

Regarding testing the patch from above with --enable-tcg-interpreter, the problem is that I do not have 10.7 or 10.8 and therefore have to ask others.

Regards

Michael Schindler, maintainer of the fink package of qemu.

Peter Maydell (pmaydell) wrote :

> I removed register from the variable declaration

That is going to be badly broken somewhere along the line for at least some CPU targets: don't try to ship that!

This is all fixed properly in git master (because Blue Swirl committed a lot of patches that let us finally drop the need for that global register variable), so either:
 (1) compile with a real gcc (not llvm-gcc or clang)
 (2) use git master
 (3) wait for 1.3.

For fink it should be entirely possible to use option (1) I would have thought.

> That is going to be badly broken somewhere along the line for at least some
> CPU targets: don't try to ship that!

oops. already done. oh well.

>This is all fixed properly in git master (because Blue Swirl committed a lot
> of patches that let us finally drop the need for that global register
> variable), so either:
> (1) compile with a real gcc (not llvm-gcc or clang)
> (2) use git master
> (3) wait for 1.3.

Thanks for the explanation.

option (1) is a pain for 10.7/8 because it means dependence on fink's gcc.
option (2) is not straight forward, because a fink package needs a fixed base of source code. Although it means some extra works, this seems the way to go, though. A brief check of the git commits revealed that the number of commits is rather large and it is probably best to base the fink package on a distinct commit. I will try that in the next days.

Michael

Hi

Faster than promised: Fink package qemu for 10.7/8 is now based on the git commit ac05f3492421caeb05809ffa02c6198ede179e43.

Michael.

Peter Maydell (pmaydell) wrote :

This was released in QEMU 1.3.

Changed in qemu:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers