Revision control

Copy as Markdown

From: Jonas Karlsson <jonas.karlsson@qt.io>
Subject: [PATCH] PhysX: Skip the packing check on 32-bit x86 with GCC
PhysX checks that the application has not set the pack value below 8 by
asserting that a long long follows a char at offset 8 in a struct. On
32-bit x86 the System V ABI aligns 8 byte types in structs to 4 bytes,
so the offset is 4 without any packing having been changed, and the
assertion fails in every translation unit, as PxPreprocessor.h is
included everywhere. PhysX already skips the check for clang there;
GCC lays the struct out the same way, and -malign-double, which would
make it pass, changes the ABI.
Skip it for both, which PX_GCC_FAMILY covers. Every other target keeps
the check.
---
src/3rdparty/PhysX/include/foundation/PxPreprocessor.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/3rdparty/PhysX/include/foundation/PxPreprocessor.h b/src/3rdparty/PhysX/include/foundation/PxPreprocessor.h
--- a/src/3rdparty/PhysX/include/foundation/PxPreprocessor.h
+++ b/src/3rdparty/PhysX/include/foundation/PxPreprocessor.h
@@ -479,7 +479,8 @@ PX_CUDA_CALLABLE PX_INLINE void PX_UNUSED(T const&)
};
#endif
// clang (as of version 3.9) cannot align doubles on 8 byte boundary when compiling for Intel 32 bit target
-#if !PX_APPLE_FAMILY && !PX_EMSCRIPTEN && !(PX_CLANG && PX_X86)
+// and neither can GCC without -malign-double, which breaks the i386 ABI
+#if !PX_APPLE_FAMILY && !PX_EMSCRIPTEN && !(PX_GCC_FAMILY && PX_X86)
PX_COMPILE_TIME_ASSERT(PX_OFFSET_OF(PxPackValidation, a) == 8);
#endif