File gcc11-typedef-alignment.patch of Package xonotic
Fix build with GCC 11 on x86_64: the alignment attribute is used on a typedef
alias instead of the actual struct type, meaning it doesn't affect alignment
of the type, only of the type used through that alias. However, for arrays
using the typedef that means that while the first element is aligned, further
elements are not aligned. GCC 11 produces an error because this is probably
not intended. The fix is to apply the attribute on the struct itself.
This change should be upstreamable, but maybe upstream wants to do this for
all structs. Discussion: https://gitlab.com/xonotic/darkplaces/-/issues/361.
diff --git a/dpsoftrast.c b/dpsoftrast.c
index d9c72720..3536b1d3 100644
--- a/dpsoftrast.c
+++ b/dpsoftrast.c
@@ -198,7 +198,7 @@ DPSOFTRAST_State_Triangle);
#define DPSOFTRAST_DRAW_MAXSUBSPAN 16
-typedef ALIGN(struct DPSOFTRAST_State_Span_s
+typedef ALIGN(struct) DPSOFTRAST_State_Span_s
{
int triangle; // triangle this span was generated by
int x; // framebuffer x coord
@@ -209,7 +209,7 @@ typedef ALIGN(struct DPSOFTRAST_State_Span_s
int depthbase; // depthbuffer value at x (add depthslope*startx to get first pixel's depthbuffer value)
int depthslope; // depthbuffer value pixel delta
}
-DPSOFTRAST_State_Span);
+DPSOFTRAST_State_Span;
#define DPSOFTRAST_DRAW_MAXSPANS 1024
#define DPSOFTRAST_DRAW_MAXTRIANGLES 128