bullet3 icon indicating copy to clipboard operation
bullet3 copied to clipboard

Enforce C++11

Open jhigginbotham64 opened this issue 2 years ago • 11 comments

Not doing this breaks the CMake build on some older compilers: https://github.com/JuliaPackaging/Yggdrasil/pull/4786#discussion_r853969776

jhigginbotham64 avatar Apr 20 '22 10:04 jhigginbotham64

Thanks for the PR. What file(s) require C++11?

erwincoumans avatar Apr 21 '22 20:04 erwincoumans

Funny thing is, without that flag it complains about nullptr

The nullptr shouldn't be used in Bullet, and needs to be removed.

erwincoumans avatar Apr 21 '22 20:04 erwincoumans

The nullptr shouldn't be used in Bullet, and needs to be removed.

Several of the examples use it: https://github.com/bulletphysics/bullet3/search?q=nullptr

Thanks for the PR. What file(s) require C++11?

I'll be right back with potential other examples, isolating broken cases take a bit with build systems. :upside_down_face: Having to re-run things.

jhigginbotham64 avatar Apr 21 '22 21:04 jhigginbotham64

Ok so I took a trip back over to the build system via https://github.com/JuliaPackaging/Yggdrasil/pull/4804, where the changes involved removing "-DCMAKE_CXX_STANDARD="11"" and "-DBUILD_EXTRAS=OFF", and there are two errors that show up on i686 and PowerPC, it appears to be a crapshoot which shows up where:

[22:12:21] In file included from /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/Core:251:0,

[22:12:21] from /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/Dense:1,

[22:12:21] from /workspace/srcdir/bullet3-3.22b/examples/SharedMemory/plugins/stablePDPlugin/MathUtil.h:4,

[22:12:21] from /workspace/srcdir/bullet3-3.22b/examples/SharedMemory/plugins/stablePDPlugin/MathUtil.cpp:1:

[22:12:21] /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h: In instantiation of ‘Packet Eigen::internal::pfrexp_generic(const Packet&, Packet&) [with Packet = __vector(2) double]’:

[22:12:21] /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/src/Core/arch/SSE/PacketMath.h:919:36: required from here

[22:12:21] /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h:42:77: error: invalid use of incomplete type ‘struct Eigen::internal::make_unsigned

[22:12:21] typedef typename make_unsigned<typename make_integer<Scalar>::type>::type ScalarUI;

[22:12:21] ^

[22:12:21] In file included from /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/Core:163:0,

[22:12:21] from /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/Dense:1,

[22:12:21] from /workspace/srcdir/bullet3-3.22b/examples/SharedMemory/plugins/stablePDPlugin/MathUtil.h:4,

[22:12:21] from /workspace/srcdir/bullet3-3.22b/examples/SharedMemory/plugins/stablePDPlugin/MathUtil.cpp:1:

[22:12:21] /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/src/Core/util/Meta.h:182:27: note: declaration of ‘struct Eigen::internal::make_unsigned’ [22:12:21] template struct make_unsigned;

[22:12:21] ^

and then there's:

[22:12:05] /workspace/srcdir/bullet3-3.22b/examples/SharedMemory/PhysicsServerExample.cpp:658:26: warning: override controls (override/final) only available with -std=c++11 or -std=gnu++11

[22:12:05] virtual void clearLines() override

[22:12:05] ^

It builds successfully on all other platforms, including Mac, Windows, FreeBSD, Linux x86 and Linux Arm. GCC version is 5.2. Adding the C++11 flag back in fixes the build on i686 and changes the error on PowerPC to:

[22:33:42] In file included from /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/Core:211:0,

[22:33:42] from /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/Dense:1,

[22:33:42] from /workspace/srcdir/bullet3-3.22b/examples/SharedMemory/plugins/stablePDPlugin/MathUtil.h:4,

[22:33:42] from /workspace/srcdir/bullet3-3.22b/examples/SharedMemory/plugins/stablePDPlugin/SpAlg.h:3,

[22:33:46] quad = vec_mul(pair, vec_sld(pair, pair, 4));

[22:33:46] ^

[22:33:46] /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/src/Core/arch/AltiVec/PacketMath.h:1564:46: error: invalid parameter combination for AltiVec intrinsic

[22:33:46] octo = vec_mul(quad, vec_sld(quad, quad, 2));

[22:33:46] ^

[22:33:46] /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/src/Core/arch/AltiVec/PacketMath.h: In function ‘typename Eigen::internal::unpacket_traits<T>::type Eigen::internal::predux_mul(const Packet&) [with Packet = __vector(16) signed char; typename Eigen::internal::unpacket_traits<T>::type = signed char]’:

[22:33:46] /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/src/Core/arch/AltiVec/PacketMath.h:1582:37: error: invalid parameter combination for AltiVec intrinsic

[22:33:46] pair = vec_mul(a, vec_sld(a, a, 8));

[22:33:46] ^

[22:33:46] /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/src/Core/arch/AltiVec/PacketMath.h:1583:46: error: invalid parameter combination for AltiVec intrinsic

[22:33:46] quad = vec_mul(pair, vec_sld(pair, pair, 4));

[22:33:46] ^

[22:33:46] /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/src/Core/arch/AltiVec/PacketMath.h:1584:46: error: invalid parameter combination for AltiVec intrinsic

[22:33:46] octo = vec_mul(quad, vec_sld(quad, quad, 2));

[22:33:46] ^

[22:33:46] /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/src/Core/arch/AltiVec/PacketMath.h:1585:48: error: invalid parameter combination for AltiVec intrinsic

[22:33:46] result = vec_mul(octo, vec_sld(octo, octo, 1));

[22:33:46] ^

[22:33:46] /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/src/Core/arch/AltiVec/PacketMath.h: In function ‘typename Eigen::internal::unpacket_traits<T>::type Eigen::internal::predux_mul(const Packet&) [with Packet = __vector(16) unsigned char; typename Eigen::internal::unpacket_traits<T>::type = unsigned char]’:

[22:33:46] /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/src/Core/arch/AltiVec/PacketMath.h:1594:37: error: invalid parameter combination for AltiVec intrinsic

[22:33:46] pair = vec_mul(a, vec_sld(a, a, 8));

[22:33:46] ^

[22:33:46] /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/src/Core/arch/AltiVec/PacketMath.h:1595:46: error: invalid parameter combination for AltiVec intrinsic

[22:33:46] quad = vec_mul(pair, vec_sld(pair, pair, 4));

[22:33:46] ^

[22:33:46] /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/src/Core/arch/AltiVec/PacketMath.h:1596:46: error: invalid parameter combination for AltiVec intrinsic

[22:33:46] octo = vec_mul(quad, vec_sld(quad, quad, 2));

[22:33:46] ^

[22:33:46] /workspace/srcdir/bullet3-3.22b/examples/ThirdPartyLibs/Eigen/src/Core/arch/AltiVec/PacketMath.h:1597:48: error: invalid parameter combination for AltiVec intrinsic

[22:33:46] result = vec_mul(octo, vec_sld(octo, octo, 1));

[22:33:46] ^

Let me know if there's anything else I can do.

jhigginbotham64 avatar Apr 21 '22 22:04 jhigginbotham64

Thanks. I think stablePDPlugin build is optional, perhaps it can be disabled? I'll look into fixing the other things.

erwincoumans avatar Apr 23 '22 22:04 erwincoumans

override will be removed here: https://github.com/bulletphysics/bullet3/pull/4251 Need to check how to disable the stablePDPlugin by default in cmake.

erwincoumans avatar Apr 24 '22 23:04 erwincoumans

Are you using CMake to build? Do you know where STATIC_LINK_SPD_PLUGIN is defined? It shouldn't be enabled by default, since that uses C++11. We could conditionally enable C++11 only iff STATIC_LINK_SPD_PLUGIN is enabled.

erwincoumans avatar Apr 24 '22 23:04 erwincoumans

Awesome, thanks for working on this! Yes, I am using cmake to build, but the only references I could find to STATIC_LINK_SPD_PLUGIN were in lua files: https://github.com/bulletphysics/bullet3/search?q=STATIC_LINK_SPD_PLUGIN

It also refers to an enable_stable_pd flag: https://github.com/bulletphysics/bullet3/search?q=enable_stable_pd

Searching instead for "stable" yields https://github.com/bulletphysics/bullet3/search?q=stable

I notice that the CMakeLists.txt for BulletRobotics refers to the source files for the plugin, but doesn't seem to pay attention to any STATIC_LINK_SPD_PLUGIN flag.

The short answer to your question is no, I don't know where STATIC_LINK_SPD_PLUGIN is defined. But I also don't know lua.

Sorry I can't give you more than that. :frowning_face:

jhigginbotham64 avatar Apr 25 '22 22:04 jhigginbotham64

Update: I've tried building with 3.24, now the override errors are gone and the remaining errors are more consistent. i686 consistently whines about "invalid use of incomplete type" somewhere in the Stable PD plugin (required by the Eigen 3rd-party lib), and PowerPC complains about "invalid parameter combination for AltiVec intrinsic" as shown above. Idk if either of those are related to C++ 11 though.

jhigginbotham64 avatar Apr 26 '22 19:04 jhigginbotham64

@erwincoumans Should I close this issue? If so, where could I get help with those other build errors? Maybe the forums?

jhigginbotham64 avatar May 02 '22 01:05 jhigginbotham64

You can keep it open, we should disable compiling the stable pd control plugin by default, and make it optional through a CMake flag, that also enables C++11 again optionally.

erwincoumans avatar May 11 '22 05:05 erwincoumans