Skip to contentSkip to conversation

tcg/i386: Add vector operations patch does not compile on Mac OS 10.6

Qemu-devel Programmingkid 1 participant 1 message Feb 28, 2018

lore
Share & tools
lore
#0 lore raw

https://lists.gnu.org/archive/html/qemu-devel/2017-09/msg04321.html

This patch causes problems with Mac OS 10.6. It stops compilation. This is the error I see when I try to compile the code:

tcg/i386/tcg-target.inc.c:3495:no such instruction: xgetbv

This is the code that causes the problem:

asm ("xgetbv" : "=a" (xcrl), "=d" (xcrh) : "c" (0));

This issue is documented here: https://bugs.launchpad.net/qemu/+bug/1751494

It looks like GNU's as command does not output Mac OS X's Mach-O object file format so updating this command is not going to work. I think one way to fix this issue is to add a test to the configure command that sees if a simple xgetbv test program can compile on the current system. If it can then use the xgetbv instruction. If it can't then use a generic function or what you feel is best.

I think the test program would look like this:

int main(int argc, char *argv[])

{
    asm volatile("xgetbv");
}

This may not be a valid use of the instruction but it is enough to tell us if this instruction can be used. On Mac OS 10.12 the program does compile. On Mac OS 10.6 the program failed to compile because the instruction is not recognized.

What do you think is the solution to this problem?