sharedstructures
sharedstructures copied to clipboard
Fails to build on Arch Linux: error: ignoring packed attribute because of unpacked non-POD field
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
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.
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
same problem on WSL 2 Ubuntu 22.04
I have also same isuue on WSL2 Ubuntu 22.04