Optimisation problem with armv6 iOS



I have things working in iOS simulators, but when i try the iPod touch, not everything works. this is xcode 4.2.

what im seeing is mouse events going to the wrong component. now, what i think is happening is that the screen coordinates are somehow coming through wrong for a tap. The bit of code im looking at is:

UIViewComponentPeer::handleTouches in juce_ios_UIViewComponentPeer.mm

i dont think there’s anything wrong with this code, because what i think i have here is a compiler problem. the touch in question is an armv6 build and it only goes wrong when optimization is enabled - yes that old chestnut!

in the debugger, it looks like the y' coordinate is incorrectly a copy of thex’ coordinate, although it’s hard to tell being an optimised build. what i’ve done is make copies of X and Y in an attempt to try to to see the values when in the debugger.

so anyhow, if this is a compiler optimization problem then it’s just tough for me. right now, i’ve disabled optimisation for armv6 (but it goes a lot slower on an already slow platform).

i was wondering if anyone else has seen tools problems in this regard, either that or whether there might really be a difference with iOS 4.2.1 or iOS3.2 in its touch behaviour that might affect this.

also, im using this “apple LLVM compiler 3.0” option, but the older option doesnt make any difference for this.

any help, ideas, similar observations appreciated,


Ah, compiler bugs… Always good fun.

I had a quick look at the code-path for the coords, but it does all look like pretty bog-standard stuff, the x and y are just passed around as part of various structures, and I couldn’t see any obvious places where I might have made incorrect assumptions about aliasing or anything. I suppose if you wanted to dig deeper, you could try randomly tweaking bits of UIViewComponentPeer::handleTouches, to see if anything makes a difference…

By ‘older’, do you mean an older LLVM, or GCC? If GCC and LLVM were both showing the same compiler bug, that’d be a bit scary!


there are two choices for the compiler, “Apple LLVM compiler 3.0”, which i assumed is the latest (is this true?) and also, “LLVM GCC 4.2”.

trying the experiment with the gcc 4.2 compiler doesnt work because it doesnt link the project. i get:
ld: library not found for -lstdc++

anyhow, i’ve left it to leave the armv6 not optimised. i guess this is just tough!


for the benefit of anyone else with this problem,

turns out this is a known apple bug. however, there is a workaround that lets you enable optimization, you have to switch of thumb code. you can do this by adding -mno-thumb to the armv6 build.