pixman: Add an upstream patch to make it build with clang.

Pixman currently does not build with clang because of following error:
pixman-mmx.c:100:20: error: constraint 'K' expects an integer constant expression
        : "y" (__A), "K" (__N)

The error happens because __N is a function parameter and clang does not
process it as an integer literal by design.
Fix this by forcing the macro version of the function which exposes __N value
as an integer literal.

Also disable integrated assembler since clang's integerated assembler can't handle
pixman's assembly syntax.

BUG=chromium:793487
TEST=pixman builds with clang on caroline/kevin boards.

CQ-DEPEND=CL:818176

Change-Id: I82d608a440304f7743cfce2bc2ffce5b1e4f366f
Reviewed-on: https://chromium-review.googlesource.com/818306
Commit-Ready: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Luis Lozano <llozano@chromium.org>
diff --git a/x11-libs/pixman/files/pixman-clang.patch b/x11-libs/pixman/files/pixman-clang.patch
new file mode 100644
index 0000000..80143b5
--- /dev/null
+++ b/x11-libs/pixman/files/pixman-clang.patch
@@ -0,0 +1,40 @@
+Apply a patch from pixman upstream to fix the follwing build error with clang:
+pixman-mmx.c:100:20: error: constraint 'K' expects an integer constant expression
+        : "y" (__A), "K" (__N)
+
+The error happens because __N is a function parameter and clang does not
+process it as an integer literal by design.
+Fix this by forcing the macro version of the function which exposes __N value
+as an integer literal. https://crbug.com/793487
+diff -Nuar old/pixman/pixman-mmx.c new/pixman/pixman-mmx.c
+--- old/pixman/pixman-mmx.c
++++ new/pixman/pixman-mmx.c
+@@ -89,20 +89,6 @@
+     return __A;
+ }
+ 
+-#  ifdef __OPTIMIZE__
+-extern __inline __m64 __attribute__((__gnu_inline__, __always_inline__, __artificial__))
+-_mm_shuffle_pi16 (__m64 __A, int8_t const __N)
+-{
+-    __m64 ret;
+-
+-    asm ("pshufw %2, %1, %0\n\t"
+-	: "=y" (ret)
+-	: "y" (__A), "K" (__N)
+-    );
+-
+-    return ret;
+-}
+-#  else
+ #   define _mm_shuffle_pi16(A, N)					\
+     ({									\
+ 	__m64 ret;							\
+@@ -114,7 +100,6 @@
+ 									\
+ 	ret;								\
+     })
+-#  endif
+ # endif
+ #endif
+ 
diff --git a/x11-libs/pixman/pixman-0.32.4.ebuild b/x11-libs/pixman/pixman-0.32.4-r1.ebuild
similarity index 74%
rename from x11-libs/pixman/pixman-0.32.4.ebuild
rename to x11-libs/pixman/pixman-0.32.4-r1.ebuild
index 2a3796a..93e1e9b 100644
--- a/x11-libs/pixman/pixman-0.32.4.ebuild
+++ b/x11-libs/pixman/pixman-0.32.4-r1.ebuild
@@ -28,5 +28,14 @@
 		--disable-gtk
 		--disable-libpng
 	)
+	# Pixman can't be built with clang's integrated assembler.
+	# Fallback to GNU assembler. Note that it has to be set with
+	# modifying CCASFLAGS (changing CFLAGS doesn't work with pixman).
+	# https://crbug.com/793487
+	CCASFLAGS+=" -fno-integrated-as"
 	xorg-2_src_configure
 }
+
+src_prepare() {
+	epatch "${FILESDIR}"/pixman-clang.patch
+}