Skip to content

GCC 13+ build failure: blake2.h alignment error #143

@melvincarvalho

Description

@melvincarvalho

Problem

Building with GCC 13+ fails with alignment errors in blake2.h:

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

Cause

GCC 13 is stricter about alignment constraints. The blake2s_state and blake2b_state structs are declared with ALIGN(64) but their sizes are not multiples of 64 bytes. When these aligned structs are used in arrays inside #pragma pack(push, 1), GCC 13 rejects this as invalid.

Solution

Two changes needed:

  1. Remove ALIGN(64) from blake2s_state and blake2b_state struct definitions (not needed for reference implementation)
  2. Move #pragma pack(pop) before the parallel state structures (blake2sp_state, blake2bp_state) which contain arrays of the aligned types

Environment

  • GCC 13.3.0 (Ubuntu 24.04)
  • Affects clean builds from source

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions