qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PULL 0/5] migration pull


From: Peter Maydell
Subject: Re: [Qemu-devel] [PULL 0/5] migration pull
Date: Tue, 23 Feb 2016 11:25:17 +0000

On 23 February 2016 at 10:43, Peter Maydell <address@hidden> wrote:
> That code fragment you suggest compiles fine normally, but not if I
> add -save-temps:
>
> $ cat /tmp/zz9.c
> #pragma GCC target("avx2")
> #include <immintrin.h>
> __m256i foo;
> $ gcc -g -Wall -o /tmp/zz9.o -c /tmp/zz9.c
> $ echo $?
> 0
> $ gcc -g -Wall -o /tmp/zz9.o -c /tmp/zz9.c -save-temps
> /tmp/zz9.c:4:1: error: unknown type name ‘__m256i’
>  __m256i foo;
>  ^
> /tmp/zz9.c: In function ‘bar’:
> /tmp/zz9.c:7:19: error: ‘__m256i’ undeclared (first use in this function)
>      return sizeof(__m256i);
>                    ^
> /tmp/zz9.c:7:19: note: each undeclared identifier is reported only
> once for each function it appears in
> /tmp/zz9.c:8:1: warning: control reaches end of non-void function
> [-Wreturn-type]
>  }
>  ^
>
> This seems to be because -save-temps causes the #pragma not to
> actually #define __AVX__.

This is because -save-temps causes gcc to invoke the
preprocessor and the compiler as separate passes, and the
standalone preprocessor doesn't know that the target pragma
should result in a new #define, so the result is that the
immintrin.h doesn't pull in what it should.

This is also the reason why my build failed -- I use ccache,
which is another tool that results in the preprocessor being
done as a standalone pass rather than in the same pass as
compilation proper.

Arguably it's a gcc bug that the target pragma doesn't cause
the standalone preprocessor to define the same #defines that
you get if it's all in one pass, but regardless I don't think
we can break ccache builds, so you'll need to find a different
way to do this, I'm afraid.

(Also gcc's docs don't say anything about target pragmas
adding #defines so either the docs or the implementation are
wrong.)

thanks
-- PMM



reply via email to

[Prev in Thread] Current Thread [Next in Thread]