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

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

Open
briancaine opened this issue Jul 19, 2023 · 4 comments

Comments

@briancaine
Copy link

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

@fuzziqersoftware
Copy link
Owner

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.

@briancaine
Copy link
Author

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

@devbug
Copy link

devbug commented Aug 8, 2023

same problem on WSL 2 Ubuntu 22.04

@onrdmr
Copy link

onrdmr commented Oct 29, 2023

I have also same isuue on WSL2 Ubuntu 22.04

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants