Wednesday, June 22, 2011

specifying alignment with arm neon instructions and the iOS toolchain

On ARM Cortex CPUs with the SIMD "neon" extension, you can do a bunch of complex loads and stores in a single instruction, like so:

vld4.u8 {d0,d1,d2,d3}, [r0@128]

where "@128" means 128-bit aligned. But the iPhone (iOS) SDK uses gas, the gnu assembler. gas treats '@' as a comment character, so the gas syntax uses a colon instead. Or at least it should. The version of gas distributed in the latest 4.3 SDK is broken, so you can't specify an alignment at all. You'll get an error like:

']' expected -- `vld4.u8 {d0,d1,d2,d3},[r3:64]

This is bad because aligned transfers are faster.

The ARM assembler is located in '/Developer/Platforms/iPhoneOS.platform/Developer/usr/libexec/gcc/darwin/arm'. This is what needs to be fixed.

Wednesday, June 8, 2011

ld: bad codegen, pointer diff in boost::detail::sp_counted_base::sp_counted_base

Trying to build an iOS project with XCode 4:

- boost built as a framework
- a static library
- the iOS app

which gives the above error. I get the same behavior no matter which compiler I select (gcc, gcc-llvm, clang), which makes a little sense since it's a linker error.

A little (lot) of googling finds a lot of suggestions to play with the compiler visibility flags. Some people say enable, others disable. The short answer is, yes, this is how I fixed things. But just messing with symbol visibility without understanding the problem rubs me the wrong way, especially when the oh-so-useful but oh-so-frightening boost is involved.