Skip to content

Conversation

@melvincarvalho
Copy link
Contributor

Summary

  • Fixes build failure with GCC 13+ due to stricter alignment enforcement
  • Removes unnecessary ALIGN(64) from BLAKE2 state structures
  • Moves #pragma pack(pop) to correct position

Problem

GCC 13 and later enforce stricter alignment rules. Building fails with:

blake2.h:101:5: error: size of array element is not a multiple of its alignment
  101 |     blake2s_state S[8][1];

The blake2s_state and blake2b_state structs were declared with ALIGN(64) but their sizes are not multiples of 64 bytes. When used in arrays inside #pragma pack(push, 1), GCC 13 rejects this.

Solution

  1. Remove ALIGN(64) from blake2s_state and blake2b_state - not needed for the reference (non-SIMD) implementation
  2. Move #pragma pack(pop) before the parallel state structures that contain arrays of these types

Testing

  • Clean build succeeds with GCC 13.3.0 on Ubuntu 24.04
  • Full blockchain sync verified working

Fixes #143

GCC 13 enforces stricter alignment rules. The blake2s_state and
blake2b_state structs were declared with ALIGN(64) but used in
arrays inside #pragma pack(push, 1), causing build failures:

  error: size of array element is not a multiple of its alignment

Fix by:
1. Remove ALIGN(64) from state structs (not needed for reference impl)
2. Move #pragma pack(pop) before parallel state structures

Fixes #143
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a GCC 13+ build failure caused by stricter alignment enforcement when using ALIGN(64) on structures inside #pragma pack(1) blocks.

Key changes:

  • Removed unnecessary ALIGN(64) attributes from blake2s_state and blake2b_state structures
  • Relocated #pragma pack(pop) before parallel state structure definitions to prevent alignment conflicts

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Successfully merging this pull request may close these issues.

GCC 13+ build failure: blake2.h alignment error

2 participants