From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYDaB-0004PT-PI for qemu-devel@nongnu.org; Tue, 23 Feb 2016 09:05:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aYDa6-0004gN-Th for qemu-devel@nongnu.org; Tue, 23 Feb 2016 09:04:55 -0500 Received: from mx1.redhat.com ([209.132.183.28]:38598) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aYDa6-0004gB-No for qemu-devel@nongnu.org; Tue, 23 Feb 2016 09:04:50 -0500 References: <56CC2ADA.8060407@redhat.com> From: Paolo Bonzini Message-ID: <56CC66FE.30702@redhat.com> Date: Tue, 23 Feb 2016 15:04:46 +0100 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PULL 0/5] migration pull List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Peter Maydell , Liang Li Cc: Amit Shah , Juan Quintela , qemu list , "Dr. David Alan Gilbert" On 23/02/2016 12:25, Peter Maydell wrote: > On 23 February 2016 at 10:43, Peter Maydell = 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 >> __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 =E2=80=98__m256i=E2=80=99 >> __m256i foo; >> ^ >> /tmp/zz9.c: In function =E2=80=98bar=E2=80=99: >> /tmp/zz9.c:7:19: error: =E2=80=98__m256i=E2=80=99 undeclared (first us= e 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__. >=20 > 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. >=20 > 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. >=20 > 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. It's a bug in the header file, it was fixed in 4.9. https://gcc.gnu.org/ml/gcc-patches/2013-06/txtvBBiTsFs8g.txt Amit or Liang, can you restrict the new optimization to GCC 4.9+? Paolo