Bug 104886 - Fails to build pixman-0.34.0 with clang 5.x or later
Summary: Fails to build pixman-0.34.0 with clang 5.x or later
Status: RESOLVED MOVED
Alias: None
Product: pixman
Classification: Unclassified
Component: pixman (show other bugs)
Version: 0.34.x
Hardware: Other All
: medium normal
Assignee: Matt Turner
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-31 14:47 UTC by Vladimir
Modified: 2018-06-05 15:28 UTC (History)
0 users

See Also:
i915 platform:
i915 features:


Attachments
pixman-clang.patch (984 bytes, patch)
2018-01-31 14:47 UTC, Vladimir
Details | Splinter Review
clang.patch (1000 bytes, patch)
2018-01-31 23:39 UTC, Vladimir
Details | Splinter Review

Description Vladimir 2018-01-31 14:47:08 UTC
Created attachment 137090 [details] [review]
pixman-clang.patch

__builtin_shuffle was removed in clang 5.0 (but it's present in clang 4.x), that's why it's not possible to build pixman-0.34.0 anymore.

Build log says:
/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: 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.
Comment 1 Vladimir 2018-01-31 23:39:14 UTC
Created attachment 137100 [details] [review]
clang.patch

Apparently gcc doesn't support __has_builtin macro. So correct patch will be like new attachment
Comment 2 Philip Chimento 2018-04-09 17:51:40 UTC
I can confirm this patch works. It would be nice to get it committed and into a 0.34.1 release, since it blocks building on macOS.
Comment 3 ilovezfs 2018-05-14 07:39:11 UTC
This affects Xcode 9.3 so the pixman formula in Homebrew is now broken on macOS 10.13, which is what the vast majority of users use now. As Philip Chimento said, a release with the patch applied would be appreciated.
Comment 4 Matt Turner 2018-06-03 17:19:07 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 5 Vladimir 2018-06-03 22:04:38 UTC
Failing tests are another bug. As you might notice my patch is only replacing __builtin_shuffle with __builtin_shufflevector for a helper function in test.

Tests for example will pass allright with CFLAGS="-O1", but not with CFLAGS="-O2"

Also the same tests will fail under the same conditions if you just disable vector ops for clang in util-prng.c, so again, not related to the patch.
Comment 6 GitLab Migration User 2018-06-05 15:28:09 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/pixman/pixman/issues/21.


Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.