[llvm] r178604 - Attempting to fix the build on older GCC versions.

Benjamin Kramer benny.kra at gmail.com
Wed Apr 3 00:38:57 PDT 2013


On Wed, Apr 3, 2013 at 3:39 AM, Aaron Ballman <aaron at aaronballman.com>wrote:

> Author: aaronballman
> Date: Tue Apr  2 20:39:37 2013
> New Revision: 178604
>
> URL: http://llvm.org/viewvc/llvm-project?rev=178604&view=rev
> Log:
> Attempting to fix the build on older GCC versions.
>
> Modified:
>     llvm/trunk/lib/Support/Host.cpp
>
> Modified: llvm/trunk/lib/Support/Host.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Support/Host.cpp?rev=178604&r1=178603&r2=178604&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Support/Host.cpp (original)
> +++ llvm/trunk/lib/Support/Host.cpp Tue Apr  2 20:39:37 2013
> @@ -113,7 +113,8 @@ static bool GetX86CpuIDAndInfo(unsigned
>  }
>
>  static bool OSHasAVXSupport() {
> -#if defined(__GNUC__)
> +#if defined( __GNUC__ ) && \
> +    (__GNUC__ > 4 || __GNUC__ == 4 && __GNUC_MINOR__ >= 4)
>    int rEAX, rEDX;
>    __asm__ ("xgetbv" : "=a" (rEAX), "=d" (rEDX) : "c" (0));
>

Ugh, this doesn't look right to me. The support is dependent on the
assembler used, not the compiler, and this check even disables clang (which
identifies itself as GCC 4.2).

I don't see a way to check the assembler version, but an ugly workaround
would be to hand-assemble xgetbv and emit a .byte sequence.

   __asm__ (".byte 0x0f, 0x01, 0xd0" : "=a" (rEAX), "=d" (rEDX) : "c" (0));

nasty, but it should work.

- Ben



>  #elif defined(_MSC_VER)
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20130403/c291e5f3/attachment.html>


More information about the llvm-commits mailing list