test: Adjust for clang's removal of __builtin_shuffle
authorVladimir Smirnov <civil@gentoo.org>
Mon, 4 Jun 2018 17:04:15 +0000 (10:04 -0700)
committerAdam Jackson <ajax@redhat.com>
Tue, 5 Jun 2018 16:35:07 +0000 (12:35 -0400)
__builtin_shuffle was removed in clang 5.0.

Build log says:
test/utils-prng.c:207:27: error: use of unknown builtin '__builtin_shuffle' [-Wimplicit-function-declaration]
            randdata.vb = __builtin_shuffle (randdata.vb, bswap_shufflemask);
                          ^
test/utils-prng.c:207:25: error: assigning to 'uint8x16' (vector of 16 'uint8_t' values) from incompatible type 'int'
            randdata.vb = __builtin_shuffle (randdata.vb, bswap_shufflemask);
                        ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2 errors generated

Link to original discussion:
http://lists.llvm.org/pipermail/cfe-dev/2017-August/055140.html

It's possible to build pixman if attached patch is applied. Basically
patch adds check for __builtin_shuffle support and in case there is
none, falls back to clang-specific __builtin_shufflevector that do the
same but have different API.

Bugzilla: https://bugs.gentoo.org/646360
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=104886
Tested-by: Philip Chimento <philip.chimento@gmail.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Adam Jackson <ajax@redhat.com>
test/utils-prng.c

index c27b5be83a2edacd06d5a1298f05f30f0a956204..0cf53dde282159047d9d744bb65439bd9c32f53d 100644 (file)
@@ -199,12 +199,25 @@ randmemset_internal (prng_t                  *prng,
         }
         else
         {
+
+#ifndef __has_builtin
+#define __has_builtin(x) 0
+#endif
+
 #ifdef HAVE_GCC_VECTOR_EXTENSIONS
-            const uint8x16 bswap_shufflemask =
+# if __has_builtin(__builtin_shufflevector)
+            randdata.vb =
+                __builtin_shufflevector (randdata.vb, randdata.vb,
+                                          3,  2,  1,  0,  7,  6 , 5,  4,
+                                         11, 10,  9,  8, 15, 14, 13, 12);
+# else
+            static const uint8x16 bswap_shufflemask =
             {
                 3, 2, 1, 0, 7, 6, 5, 4, 11, 10, 9, 8, 15, 14, 13, 12
             };
             randdata.vb = __builtin_shuffle (randdata.vb, bswap_shufflemask);
+# endif
+
             store_rand_128_data (buf, &randdata, aligned);
             buf += 16;
 #else