CauldronDevelopmentLLC / CAMotics

Open-Source Simulation & Computer Aided Machining - A 3-axis CNC GCode simulator
Other
602 stars 140 forks source link

GCC9: error: taking address of packed member of 'CAMotics::STLBinaryTriangle' may result in an unaligned pointer value #282

Closed srakitnican closed 5 years ago

srakitnican commented 5 years ago

On CAMotics 1.1.1 with 6c11aa6026070a403be44ddf316cfadba6b22f8b using GCC 9.

g++ -o build/camotics/stl/STLReader.o -c -std=c++11 -Wno-deprecated-declarations -g -Wall -Werror -I/usr/include/v8-3.14/ -O2 -g -pipe -Wall -Werror=format-sec
urity -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 -m64 -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection -Wno-error=parenthe
ses -fPIC -DDEBUG -D_REENTRANT -DHAVE_EXPAT -DHAVE_PTHREADS -DHAVE_LIBSQLITE -DHAVE_V8 -DDEBUG_LEVEL=1 -DHAVE_CBANG -DUSING_CBANG -DQT_CORE_LIB -DQT_GUI_LIB -D
QT_OPENGL_LIB -DQT_SHARED -I/builddir/build/BUILD/cbang-fdd8867333016a479b66dcb3ec9de5eaf54b9adb/src -I/builddir/build/BUILD/cbang-fdd8867333016a479b66dcb3ec9d
e5eaf54b9adb/include -I/builddir/build/BUILD/cbang-fdd8867333016a479b66dcb3ec9de5eaf54b9adb/src/boost -I/usr/include/QtCore -I/usr/include/QtGui -I/usr/include
/QtOpenGL -Isrc -Ibuild -Isrc src/camotics/stl/STLReader.cpp
src/camotics/stl/STLReader.cpp: In member function 'virtual void CAMotics::STLReader::readFacet(cb::Vector3F&, cb::Vector3F&, cb::Vector3F&, cb::Vector3F&)':
src/camotics/stl/STLReader.cpp:87:14: error: taking address of packed member of 'CAMotics::STLBinaryTriangle' may result in an unaligned pointer value [-Werror=address-of-packed-member]
   87 |     v1 = tri.v1;
      |          ~~~~^~
src/camotics/stl/STLReader.cpp:88:14: error: taking address of packed member of 'CAMotics::STLBinaryTriangle' may result in an unaligned pointer value [-Werror=address-of-packed-member]
   88 |     v2 = tri.v2;
      |          ~~~~^~
src/camotics/stl/STLReader.cpp:89:14: error: taking address of packed member of 'CAMotics::STLBinaryTriangle' may result in an unaligned pointer value [-Werror=address-of-packed-member]
   89 |     v3 = tri.v3;
      |          ~~~~^~
src/camotics/stl/STLReader.cpp:90:18: error: taking address of packed member of 'CAMotics::STLBinaryTriangle' may result in an unaligned pointer value [-Werror=address-of-packed-member]
   90 |     normal = tri.normal;
      |              ~~~~^~~~~~
cc1plus: all warnings being treated as errors
scons: *** [build/camotics/stl/STLReader.o] Error 1
scons: building terminated because of errors.
srakitnican commented 5 years ago

This happens only with -Werror compiler flag.

jcoffland commented 5 years ago

The debug build is also much slower than the release build.

srakitnican commented 5 years ago

Fedora build needs debugging/symbol information produced with the -g option which gets stripped by Fedora build scripts into a separate package, any tip how to accomplish that with a release build?

jcoffland commented 5 years ago

Try building like this scons ccflags=-g but leave debug=1 off.

srakitnican commented 5 years ago

I tried that, it clearly builds with the -g option, but it gets stripped at the end of the build.

<mock-chroot> sh-4.4# ls -lh /builddir/build/BUILD/CAMotics-1.1.1/{camotics,camsim,gcodetool,tplang}
-rwxr-xr-x. 1 mockbuild mock 5.3M Feb  4 09:11 /builddir/build/BUILD/CAMotics-1.1.1/camotics
-rwxr-xr-x. 1 mockbuild mock 4.1M Feb  4 09:11 /builddir/build/BUILD/CAMotics-1.1.1/camsim
-rwxr-xr-x. 1 mockbuild mock 3.4M Feb  4 09:11 /builddir/build/BUILD/CAMotics-1.1.1/gcodetool
-rwxr-xr-x. 1 mockbuild mock 4.3M Feb  4 09:11 /builddir/build/BUILD/CAMotics-1.1.1/tplang
jcoffland commented 5 years ago

Yes. In my build system I automatically add link flags to strip the executables in non-debug mode. You could try this: scons debug=1 ccflags=-O3

jcoffland commented 5 years ago

Fixed.