
Stefan Schulze Frielinghaus pushed to branch wip/fix-gen_workspace at Glasgow Haskell Compiler / GHC Commits: 16b5251e by Stefan Schulze Frielinghaus at 2025-09-16T10:59:49+02:00 rts: Fix alignment for gen_workspace #26334 After a0fa4941903272c48b050d24e93eec819eff51bd bootstrap is broken on s390x and errors out with rts/sm/GCThread.h:207:5: error: error: alignment of array elements is greater than element size 207 | gen_workspace gens[]; | ^~~~~~~~~~~~~ The alignment constraint is applied via the attribute to the type gen_workspace and leaves the underlying type struct gen_workspace_ untouched. On Aarch64, x86, and s390x the struct has a size of 128 bytes. On Aarch64 and x86 the alignments of 128 and 64 are divisors of the size, respectively, which is why the type is a viable member type for an array. However, on s390x, the alignment is 256 and therefore is not a divisor of the size and hence cannot be used for arrays. Basically I see two fixes here. Either decrease the alignment requirement on s390x, or by applying the alignment constraint on the struct itself. The former might affect performance as noted in a0fa4941903272c48b050d24e93eec819eff51bd. The latter introduces padding bits whenever necessary in order to ensure that sizeof(gen_workspace[N])==N*sizeof(gen_workspace) holds which is done by this patch. - - - - - 1 changed file: - rts/sm/GCThread.h Changes: ===================================== rts/sm/GCThread.h ===================================== @@ -83,7 +83,7 @@ // platforms. #define GEN_WORKSPACE_ALIGNMENT CACHELINE_SIZE -typedef struct gen_workspace_ { +typedef struct ATTRIBUTE_ALIGNED(GEN_WORKSPACE_ALIGNMENT) gen_workspace_ { generation * gen; // the gen for this workspace struct gc_thread_ * my_gct; // the gc_thread that contains this workspace @@ -109,7 +109,7 @@ typedef struct gen_workspace_ { bdescr * part_list; StgWord n_part_blocks; // count of above StgWord n_part_words; -} gen_workspace ATTRIBUTE_ALIGNED(GEN_WORKSPACE_ALIGNMENT); +} gen_workspace; /* ---------------------------------------------------------------------------- GC thread object View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/16b5251e2ea0bf5f2a95f6fb7047b1e3... -- View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/commit/16b5251e2ea0bf5f2a95f6fb7047b1e3... You're receiving this email because of your account on gitlab.haskell.org.