Page 1 of 1

Building 2.81 for iOS - having issues.

Posted: Tue Dec 18, 2012 11:35 am
by alh
Hi!

I ran into some troubles when I tried building Bullet for iOS.

What I did was to add all the sources from BulletCollision, BulletDynamics, vectormath and LinearMath to my iOS project (for easy debugging and patching)

My first issue was an invalid preprocessor instruction in btScalar.h, there was a line called "#end", but there seems to be no #end instruction in the preprocessor.
After trying to decrypt the header file, I concluded this #end could just be removed, and after doing this everything compiled fine.
Is this correct or am I misunderstanding something?
Is it a typo or is #end supposed to do something?

My second issue was when trying to enable NEON.
the __armv7__ macro was not defined, so no NEON code was enabled at first.
I added "|| defined(__ARM_ARCH_7S__)" and then NEON code is enabled.

But it does not compile.
I get several "Constant expression evaluates to 4294967295 which cannot be narrowed to type 'int32_t' (aka 'int')" and "Constant expression evaluates to -1 which cannot be narrowed to type 'int32_t' (aka 'int')".
Here is an example of a line that fails with the first message (L68, btVector3.h):
"const int32x4_t ATTRIBUTE_ALIGNED16(btvFFF0Mask) = (int32x4_t){0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0x0};"

XCode suggests to fix it with an explicit typecast, but I feel unsure if this is the right approach.

Anyone who can advice?
Am I just messing things up, not using the cmake system, or is the iOS build slightly broken in 2.81?
btScalar.h looks quite messy in the iOS definitions, with a couple of redundant #ifdefs

Re: Building 2.81 for iOS - having issues.

Posted: Wed Dec 19, 2012 3:57 pm
by Erwin Coumans
The #end issue in btScalar.h is fixed in latest trunk.

You shouldn't need to adjust other compiler directives. If __armv7__ seems required for our NEON implementation, so your compiler/version might not match.
What iOS version, XCode version and compiler flavor and version are you using?
(gcc, llvm-gcc, llvm, iOS 5, 6?, XCode?)

Re: Building 2.81 for iOS - having issues.

Posted: Thu Dec 20, 2012 11:04 am
by alh
I'm using XCode 4.5.2 with SDK 6.0 (but target is 5.0), and I'm using Apple LLVM 4.1, with language dialect GNU++11, and GNU C++ standard library.
Architecture is armv7 and armv7s (ARCHS_STANDARD_32_BIT)

I probably could change some of the settings, for which configuration is Bullet tested?

Thanks!

Re: Building 2.81 for iOS - having issues.

Posted: Thu Mar 14, 2013 12:26 pm
by nadro
It looks like eg. "_ARM_ARCH_7" is better way do detect ARM v7 architecture. "__armv7__" is missing in the latest XCode versions, so NEON is disabled by default.

Re: Building 2.81 for iOS - having issues.

Posted: Thu Mar 14, 2013 12:39 pm
by alh
Another note for future readers: You also need to set the language dialect to GNU++98, or the NEON code will not compile

Re: Building 2.81 for iOS - having issues.

Posted: Sun Mar 17, 2013 7:41 pm
by sth
It's possible to check for NEON support directly using __ARM_NEON__:

Code: Select all

            ...
        #endif //BT_USE_SSE
    #elif defined( __ARM_NEON__ )
        #ifdef __clang__
            ...