sharedstructures icon indicating copy to clipboard operation
sharedstructures copied to clipboard

Fails to build on Arch Linux: error: ignoring packed attribute because of unpacked non-POD field

Open briancaine opened this issue 1 year ago • 4 comments

Having trouble building on Arch Linux.

$ make
[  3%] Building CXX object CMakeFiles/sharedstructures.dir/src/Allocator.cc.o
In file included from /tmp/sharedstructures/src/Allocator.hh:5,
                 from /tmp/sharedstructures/src/Allocator.cc:1:
/tmp/sharedstructures/src/Pool.hh:191:27: error: ignoring packed attribute because of unpacked non-POD field ‘std::atomic<long unsigned int> sharedstructures::Pool::Data::size’ [-Werror]
  191 |     std::atomic<uint64_t> size;
      |                           ^~~~
In file included from /tmp/sharedstructures/src/Allocator.hh:6:
/tmp/sharedstructures/src/ProcessLock.hh:11:24: error: ignoring packed attribute because of unpacked non-POD field ‘std::atomic<int> sharedstructures::ProcessLock::lock’ [-Werror]
   11 |   std::atomic<int32_t> lock;
      |                        ^~~~
/tmp/sharedstructures/src/ProcessLock.hh:18:24: error: ignoring packed attribute because of unpacked non-POD field ‘std::atomic<int> sharedstructures::ProcessReadWriteLock::write_lock’ [-Werror]
   18 |   std::atomic<int32_t> write_lock;
      |                        ^~~~~~~~~~
/tmp/sharedstructures/src/ProcessLock.hh:19:24: error: ignoring packed attribute because of unpacked non-POD field ‘std::atomic<int> sharedstructures::ProcessReadWriteLock::reader_tokens [65]’ [-Werror]
   19 |   std::atomic<int32_t> reader_tokens[NUM_READER_SLOTS];
      |                        ^~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/sharedstructures.dir/build.make:76: CMakeFiles/sharedstructures.dir/src/Allocator.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:103: CMakeFiles/sharedstructures.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

I've attached the output of my cmake .. (too big to paste in) sharedstructures_cmake.txt

briancaine avatar Jul 19 '23 18:07 briancaine

I haven't seen this issue before. It looks like you're building with gcc on amd64, which is a fairly common configuration, but it seems like your system is more strict about alignment for some reason. I've added alignment specifiers to several structures which might help, but I don't have an Arch system handy to test by myself. Let me know if the most recent change doesn't resolve the issue.

fuzziqersoftware avatar Jul 19 '23 19:07 fuzziqersoftware

No, doesn't seem to have fixed it.

$ make
[  3%] Building CXX object CMakeFiles/sharedstructures.dir/src/Allocator.cc.o
In file included from /tmp/sharedstructures/src/Allocator.hh:5,
                 from /tmp/sharedstructures/src/Allocator.cc:1:
/tmp/sharedstructures/src/Pool.hh:191:38: error: ignoring packed attribute because of unpacked non-POD field ‘std::atomic<long unsigned int> sharedstructures::Pool::Data::size’ [-Werror]
  191 |     alignas(8) std::atomic<uint64_t> size;
      |                                      ^~~~
In file included from /tmp/sharedstructures/src/Allocator.hh:6:
/tmp/sharedstructures/src/ProcessLock.hh:11:35: error: ignoring packed attribute because of unpacked non-POD field ‘std::atomic<int> sharedstructures::ProcessLock::lock’ [-Werror]
   11 |   alignas(4) std::atomic<int32_t> lock;
      |                                   ^~~~
/tmp/sharedstructures/src/ProcessLock.hh:20:35: error: ignoring packed attribute because of unpacked non-POD field ‘std::atomic<int> sharedstructures::ProcessReadWriteLock::write_lock’ [-Werror]
   20 |   alignas(4) std::atomic<int32_t> write_lock;
      |                                   ^~~~~~~~~~
/tmp/sharedstructures/src/ProcessLock.hh:21:35: error: ignoring packed attribute because of unpacked non-POD field ‘std::atomic<int> sharedstructures::ProcessReadWriteLock::reader_tokens [65]’ [-Werror]
   21 |   alignas(4) std::atomic<int32_t> reader_tokens[NUM_READER_SLOTS];
      |                                   ^~~~~~~~~~~~~
cc1plus: all warnings being treated as errors
make[2]: *** [CMakeFiles/sharedstructures.dir/build.make:76: CMakeFiles/sharedstructures.dir/src/Allocator.cc.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:103: CMakeFiles/sharedstructures.dir/all] Error 2
make: *** [Makefile:146: all] Error 2

briancaine avatar Jul 19 '23 22:07 briancaine

same problem on WSL 2 Ubuntu 22.04

devbug avatar Aug 08 '23 09:08 devbug

I have also same isuue on WSL2 Ubuntu 22.04

onrdmr avatar Oct 29 '23 13:10 onrdmr