Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pioneerLib.dir/src/CollMesh.cpp does not compile on i686 arch #4691

Open
sagitter opened this issue Oct 8, 2019 · 2 comments

Comments

@sagitter
Copy link

commented Oct 8, 2019

Observed behaviour

pioneerLib.dir/src/CollMesh.cpp compilation is failed on Fedora 30 i686 architecture with the following error:

[ 12%] Building CXX object CMakeFiles/pioneerLib.dir/src/CollMesh.cpp.o
/usr/bin/c++   -I/builddir/build/BUILD/pioneer-e85a0cf4ca8e710d926f6c1581c3d9db242f361f/build -I/builddir/build/BUILD/pioneer-e85a0cf4ca8e710d926f6c1581c3d9db242f361f -I/builddir/build/BUILD/pioneer-e85a0cf4ca8e710d926f6c1581c3d9db242f361f/contrib -I/builddir/build/BUILD/pioneer-e85a0cf4ca8e710d926f6c1581c3d9db242f361f/src -I/usr/include/assimp -I/usr/include/freetype2 -I/usr/include/SDL2 -I/usr/include/sigc++-2.0 -I/usr/lib/sigc++-2.0/include -I/builddir/build/BUILD/pioneer-e85a0cf4ca8e710d926f6c1581c3d9db242f361f/contrib/lua  -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1 -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1 -m32 -march=i686 -mtune=generic -msse2 -mfpmath=sse -mstackrealign -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -fpermissive -DNDEBUG   -fdiagnostics-color -std=gnu++11 -o CMakeFiles/pioneerLib.dir/src/CollMesh.cpp.o -c /builddir/build/BUILD/pioneer-e85a0cf4ca8e710d926f6c1581c3d9db242f361f/src/CollMesh.cpp
make[2]: Leaving directory '/builddir/build/BUILD/pioneer-e85a0cf4ca8e710d926f6c1581c3d9db242f361f/build'
In file included from /builddir/build/BUILD/pioneer-e85a0cf4ca8e710d926f6c1581c3d9db242f361f/src/CollMesh.cpp:5:
/builddir/build/BUILD/pioneer-e85a0cf4ca8e710d926f6c1581c3d9db242f361f/src/scenegraph/Serializer.h:26:37: error: static assertion failed: Int64 is sized differently on this platform and will not serialize properly.
   26 |  static_assert((sizeof(Uint64) == 8 && alignof(Uint64) == 8), "Int64 is sized differently on this platform and will not serialize properly.");
      |                ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/pioneer-e85a0cf4ca8e710d926f6c1581c3d9db242f361f/src/scenegraph/Serializer.h:29:40: error: static assertion failed: Vector2d is padded differently on this platform and will not serialize properly.
   29 |  static_assert((sizeof(vector2d) == 16 && alignof(vector2d) == 8), "Vector2d is padded differently on this platform and will not serialize properly.");
      |                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/pioneer-e85a0cf4ca8e710d926f6c1581c3d9db242f361f/src/scenegraph/Serializer.h:31:40: error: static assertion failed: Vector3d is padded differently on this platform and will not serialize properly.
   31 |  static_assert((sizeof(vector3d) == 24 && alignof(vector3d) == 8), "Vector3d is padded differently on this platform and will not serialize properly.");
      |                ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/pioneer-e85a0cf4ca8e710d926f6c1581c3d9db242f361f/src/scenegraph/Serializer.h:33:36: error: static assertion failed: Aabb is padded differently on this platform and will not serialize properly.
   33 |  static_assert((sizeof(Aabb) == 56 && alignof(Aabb) == 8), "Aabb is padded differently on this platform and will not serialize properly.");
      |                ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~
/builddir/build/BUILD/pioneer-e85a0cf4ca8e710d926f6c1581c3d9db242f361f/src/scenegraph/Serializer.h: In member function 'ByteRange Serializer::Reader::Blob()':
/builddir/build/BUILD/pioneer-e85a0cf4ca8e710d926f6c1581c3d9db242f361f/src/scenegraph/Serializer.h:184:12: warning: comparison of integer expressions of different signedness: 'unsigned int' and 'int' [-Wsign-compare]
  184 |    if (len > (m_data.end - m_at))
      |        ~~~~^~~~~~~~~~~~~~~~~~~~~
make[2]: *** [CMakeFiles/pioneerLib.dir/build.make:183: CMakeFiles/pioneerLib.dir/src/CollMesh.cpp.o] Error 1

Expected behaviour

Correctly compiled.

Steps to reproduce

Try to compile on Fedora with

@Web-eWorks

This comment has been minimized.

Copy link
Member

commented Oct 8, 2019

I'm going to take a stab in the dark and guess that on i686 the alignof(uint64_t) is 4 instead of the 8 I would expect. Same with doubles, which would be the issue there. Can you try changing the affected lines to read alignof(<type>) <= 8? I think that would resolve the issue, at least temporarily.

@sagitter

This comment has been minimized.

Copy link
Author

commented Oct 9, 2019

This patch is working:

--- a/src/scenegraph/Serializer.orig.h	2019-10-09 13:49:04.000000000 +0200
+++ b/src/scenegraph/Serializer.h	2019-10-09 18:47:05.238671730 +0200
@@ -23,14 +23,14 @@
 // where possible, prefer serializing state information via JSON instead.
 namespace Serializer {
 	static_assert((sizeof(Uint32) == 4 && alignof(Uint32) == 4), "Int32 is sized differently on this platform and will not serialize properly.");
-	static_assert((sizeof(Uint64) == 8 && alignof(Uint64) == 8), "Int64 is sized differently on this platform and will not serialize properly.");
+	static_assert((sizeof(Uint64) == 8 && alignof(Uint64) <= 8), "Int64 is sized differently on this platform and will not serialize properly.");
 	static_assert((sizeof(Color) == 4 && alignof(Color) == 1), "Color is padded differently on this platform and will not serialize properly.");
 	static_assert((sizeof(vector2f) == 8 && alignof(vector2f) == 4), "Vector2f is padded differently on this platform and will not serialize properly.");
-	static_assert((sizeof(vector2d) == 16 && alignof(vector2d) == 8), "Vector2d is padded differently on this platform and will not serialize properly.");
+	static_assert((sizeof(vector2d) == 16 && alignof(vector2d) <= 8), "Vector2d is padded differently on this platform and will not serialize properly.");
 	static_assert((sizeof(vector3f) == 12 && alignof(vector3f) == 4), "Vector3f is padded differently on this platform and will not serialize properly.");
-	static_assert((sizeof(vector3d) == 24 && alignof(vector3d) == 8), "Vector3d is padded differently on this platform and will not serialize properly.");
+	static_assert((sizeof(vector3d) == 24 && alignof(vector3d) <= 8), "Vector3d is padded differently on this platform and will not serialize properly.");
 	static_assert((sizeof(Quaternionf) == 16 && alignof(Quaternionf) == 4), "Quaternionf is padded differently on this platform and will not serialize properly.");
-	static_assert((sizeof(Aabb) == 56 && alignof(Aabb) == 8), "Aabb is padded differently on this platform and will not serialize properly.");
+	static_assert((sizeof(Aabb) == 56 && alignof(Aabb) <= 8), "Aabb is padded differently on this platform and will not serialize properly.");
 
 	class Writer {
 	public:
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.