XCode 11: build linking against bullet physics now fails (worked in XCode 10.3)

I have a project which links against the bullet physics library, and while it worked perfectly under XCode 10.3, the build suddenly fails with zero changes to the project after updating to XCode 11.


The project in question is a C++ library project, generated using swift package manager (`swift package generate-xcodeproj`). It's built using clang, with C++ dialect C++17.


The error is being thrown from this file: https://github.com/bulletphysics/bullet3/blob/master/src/LinearMath/btVector3.h on line 335:


y = bt_splat_ps(y, 0x80);


The error is this: "Argument value 10880 is outside the valid range [0, 255]"


Here bt_splat_ps is a macro defined like so:


#define _mm_shuffle_ps(a, b, mask) \
  (__m128)__builtin_ia32_shufps((__v4sf)(__m128)(a), (__v4sf)(__m128)(b), \
                                (int)(mask))

#define BT_SHUFFLE(x, y, z, w) ((w) << 6 | (z) << 4 | (y) << 2 | (x))
#define bt_pshufd_ps(_a, _mask) _mm_shuffle_ps((_a), (_a), (_mask))

#define bt_splat_ps(_a, _i) bt_pshufd_ps((_a), BT_SHUFFLE(_i, _i, _i, _i))

...

y = bt_splat_ps(y, 0x80);


So it looks like maybe this error is coming from the argument which is provided to `__builtin_ia32_shufps`?


Is there anything which has changed in the XCode 11 tools which would explain why this was previously working and no longer works?

Replies

Also it's worth noting, I tried building it under XCode 10.3 again, and this same issue is reported as a warning, not an error. Maybe one of the default build settings became more strict with respect to this?

Hi Skohan,


Out of interest, what happens if you change the code to


y = bt_splat_ps(y, 128);


If it doesn't make any difference I would try this


#define BT_SHUFFLE(x, y, z, w) (((w) << 6 | (z) << 4 | (y) << 2 | (x))&255)


Thought that would change the behaviour.


It looks like the shuffle is creating the value 10880


(0x80 << 6) + (0x80 <<4) + (0x80 << 2) + (0x80) = 0x2000 + 0x800 + 0x200 + 0x80 = 0x2a80 = 10,880