[Pixman] Pixman on iOS

Siarhei Siamashka siarhei.siamashka at gmail.com
Mon Mar 7 06:19:29 PST 2011

On Sun, Mar 6, 2011 at 2:55 PM, Luca Barbato <lu_zero at gentoo.org> wrote:
> On 03/06/2011 11:27 AM, Siarhei Siamashka wrote:
>> On Sun, Mar 6, 2011 at 5:28 AM, cu <cairouser at yahoo.com> wrote:
>>> I am starting to look (very carefully) into building pixman and, one day
>>> may be, cairo on iphone/ipad/iOS.
>>> So far I've got to the point where I can configure and build pixman for
>>> a single arm architecture. So far so good.
>>> However, I seem to be unable to enable NEON optimizations. Presumably,
>>> iPhone/iPad armv7 does have those.
>>> I wonder if the issue is specific set of compiler directives used to
>>> access NEON operations? Any help or insight would be appreciated.
>> In order to compile NEON assembly optimizations, ideally one would
>> need GAS compatible assembler (fully supporting 'modern' features like
>> macros) which can produce Mach-O object files. I'm not aware of the
>> latest news on this front and my information may be a bit outdated.
>> But from what I read, apparently Apple forked an ancient version of
>> binutils ages ago and has a very primitive assembler. And on the other
>> hand, upstream GNU binutils do not support Mach-O yet. The popular
>> solution seems to be to use intermediate preprocessors written in
>> scripting languages on assembly source files to produce something that
>> can be digested by the assembler from iPhone SDK.
> That one helps a lot:
> https://github.com/yuvi/gas-preprocessor

Thanks for the link, it's clearly interesting. Unfortunately this
script seems to be choking on 'pixman-arm-neon-asm.S', so it might
need to be improved a bit.

I also experimented with solving a similar problem in a bit different
way some time ago after Mozilla folks expressed some concerns on IRC
regarding whether the new pixman NEON optimizations would be also
usable on Windows Mobile. This Windows Mobile topic died eventually,
but my old script is still available here:

The usage is simple. First one needs to do a normal build of pixman
for ARM linux, so that the library with object files in ELF format is
generated for NEON optimizations in
'pixman/.libs/libpixman-arm-neon.a'. Then run:

$ arm-none-gnueabi-objdump -d pixman/.libs/libpixman-arm-neon.a > objdump.log
$ ruby objdump2s.rb objdump.log > pixman/pixman-arm-neon-asm.S

As a result, 'pixman/pixman-arm-neon-asm.S' should now contain the
NEON assembly source file with all macros expanded.

I have just tested it, and everything seems to work fine (compiling it
for ARM linux again) except for two problems:
1. objdump from binutils 2.21 seems to have proken alignment
specifiers (2.20.1 is fine)
2. all versions of objdump that I have seem to disassemble 'vshll.u16'
instruction incorrectly and this instruction is used by the new
bilinear fast path, a temporary solution is to try pixman-2.21.6 which
does not have bilinear optimizations yet

And the final note. If anyone would want to redistribute this
preprocessed file for whatever purpose, preserving the original
copyright header and also adding a notice that it is not the original
source but an autogenerated file would be really appreciated. As well
as also having a reference to the original source or including it

>> After NEON assembly can be compiled, pixman runtime CPU detection
>> needs to be tweaked to detect NEON and enable it on iPhone. And
>> finally, somebody needs to check whether iPhone ABI is compatible with
>> what is used by Linux and Android (ARM EABI) because this can be
>> potentially a source of really bad runtime bugs. Just running tests
>> from pixman test suite to see whether they pass or fail may be a good
>> start.
> For starter I'd just force-enable/disable depending on the target build.

Yes, that makes sense. At least for the initial test build.

>> That said, I neither have any Apple hardware required to do iPhone
>> development, nor do I feel that it would be the right thing for me to
>> work on this issue considering many factors. Surely it would have been
>> better for everyone if Apple tried to be more compatible with Linux.
>> But as it does not seem to be the case, somebody has to do some work
>> to make sure that pixman NEON optimizations work there.
> I have the needed hardware so if enough people find that part
> interesting I could give a try.

I'm actually more worried that if this build for iPhone ends up being
a one shot experiment without any maintainer to keep it alive, then it
is going to bitrot soon. IMHO adding support for more marginal
platforms (in cairo/pixman context) is not something that is clearly
beneficial. More like it will attract the users who can't solve their
problems themselves but complaining about bugs and breakages.

Best regards,
Siarhei Siamashka

More information about the Pixman mailing list