Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 646360 - x11-libs/pixman: fails to build with >=sys-devel/clang-5
Summary: x11-libs/pixman: fails to build with >=sys-devel/clang-5
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Highest blocker (vote)
Assignee: Gentoo X packagers
URL: https://bugs.freedesktop.org/show_bug...
Whiteboard:
Keywords:
Depends on:
Blocks: systemwide-clang
  Show dependency tree
 
Reported: 2018-02-01 20:56 UTC by Vladimir Smirnov (RETIRED)
Modified: 2018-11-21 17:25 UTC (History)
2 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
pixman-0.34.0-clang5.patch (clang.patch,1000 bytes, patch)
2018-02-01 20:56 UTC, Vladimir Smirnov (RETIRED)
Details | Diff
emerge --info (emerge.info,7.28 KB, text/plain)
2018-02-01 20:56 UTC, Vladimir Smirnov (RETIRED)
Details
build.log (pixman-build.log,84.03 KB, text/x-log)
2018-02-01 21:26 UTC, Vladimir Smirnov (RETIRED)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir Smirnov (RETIRED) gentoo-dev 2018-02-01 20:56:30 UTC
Created attachment 517498 [details, diff]
pixman-0.34.0-clang5.patch

pixman-0.34 and 9999 fails to build with clang-5.0 or later (e.x. gentoo-prefix on macOS or with clang on Linux).

Upstream bug: https://bugs.freedesktop.org/show_bug.cgi?id=104886

Short summary:
Since clang-5.0 there is no __builtin_shuffle (gcc-specific function), but HAVE_GCC_VECTOR_EXTENSIONS is still defined.

There is a substitute function that do the same but with different API (also clang-specific) - __builtin_shufflevector.

If you try to build pixman with clang-5.0 or later it will fail with following error:
/Users/vsmirnov/gentoo/var/tmp/portage/x11-libs/pixman-0.34.0/work/pixman-0.34.0/test/utils-prng.c:207:27: error: use of unknown builtin '__builtin_shuffle' [-Wimplicit-function-declaration]
            randdata.vb = __builtin_shuffle (randdata.vb, bswap_shufflemask);
                          ^
/Users/vsmirnov/gentoo/var/tmp/portage/x11-libs/pixman-0.34.0/work/pixman-0.34.0/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


$ clang --version
clang version 5.0.1 (tags/RELEASE_501/final)
Target: x86_64-apple-darwin17.4.0
Thread model: posix
InstalledDir: /Users/vsmirnov/gentoo/usr/lib/llvm/5/bin

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

Link to upstream bug: https://bugs.freedesktop.org/show_bug.cgi?id=104886

Proposed patch (workaround) is in attachment.
Comment 1 Vladimir Smirnov (RETIRED) gentoo-dev 2018-02-01 20:56:51 UTC
Created attachment 517500 [details]
emerge --info
Comment 2 Vladimir Smirnov (RETIRED) gentoo-dev 2018-02-01 20:58:36 UTC
pximan-0.34.0-clang5.patch works on both gcc and clang5.

I can commit the patch by myself, but as I'm not part of X11 I'd like to check up with somebody before doing anything.
Comment 3 Vladimir Smirnov (RETIRED) gentoo-dev 2018-02-01 21:26:45 UTC
Created attachment 517504 [details]
build.log
Comment 4 Chí-Thanh Christopher Nguyễn gentoo-dev 2018-02-02 18:34:55 UTC
We usually apply patches only after upstream approves them, unless they are for Gentoo specific things.

And maybe it is a bug in clang, that it defines HAVE_GCC_VECTOR_EXTENSIONS while supporting only a subset of what is listed here: https://gcc.gnu.org/onlinedocs/gcc/Vector-Extensions.html
Comment 5 Fabian Groffen gentoo-dev 2018-06-02 12:40:54 UTC
@x11: please be lenient here, pixman cannot be installed on macOS without a rememedy/patch.  You can consider Gentoo Prefix a Gentoo-specific thing, if that makes your decision process easier.

If it helps, we can apply conditionally on tc-is-clang or a CHOST check.
Comment 6 Fabian Groffen gentoo-dev 2018-06-02 12:49:39 UTC
I could also live with a blunt hack like this:

--- a/pixman-0.34.0.ebuild
+++ b/pixman-0.34.0.ebuild
@@ -3,7 +3,7 @@
 
 EAPI=5
 XORG_MULTILIB=yes
-inherit xorg-2
+inherit xorg-2 flag-o-matic toolchain-funcs
 
 EGIT_REPO_URI="https://anongit.freedesktop.org/git/pixman.git"
 DESCRIPTION="Low-level pixel manipulation routines"
@@ -15,6 +15,8 @@
 IUSE="altivec iwmmxt loongson2f cpu_flags_x86_mmxext neon cpu_flags_x86_sse2 cpu_flags_x86_ssse3"
 
 src_configure() {
+       # workaround bug #646360
+       tc-is-clang && append-cppflags -Dvector_size=fooblahblah
        XORG_CONFIGURE_OPTIONS=(
                $(use_enable cpu_flags_x86_mmxext mmx)
                $(use_enable cpu_flags_x86_sse2 sse2)
Comment 7 Matt Turner gentoo-dev 2018-06-02 16:50:26 UTC
Thanks. Sorry for not having a look sooner. The patch looks fine to me. I'll give it a commit message and send it upstream. I used to work on pixman, so I can actually push it and make a new release.
Comment 8 Matt Turner gentoo-dev 2018-06-03 17:18:10 UTC
I tested clang 5 and 6, and while everything compiles, it fails the test suite:

FAIL: combiner-test
FAIL: gradient-crash-test
FAIL: stress-test

I don't feel good about making a release claiming to fix clang support if these tests fail.
Comment 9 Matt Turner gentoo-dev 2018-06-05 18:39:52 UTC
This is  now fixed upstream by https://gitlab.freedesktop.org/pixman/pixman/commit/bd2b49185b28c5024597a5e530af9fc25de3193a

We're investigating the failures when built with clang in https://gitlab.freedesktop.org/pixman/pixman/issues/22
Comment 10 Matt Turner gentoo-dev 2018-11-21 17:25:07 UTC
The patch is included in the 0.36.0 pixman release.