> GCC supports an "aligned" attribute to specify a minimum alignment for > types/objects. However, if an object is allocated on the stack and > its alignment exceeds the "preferred stack boundary", then GCC 4.2 > silently ignores the alignment.
[...] > Since newer GCC properly support overly aligned stack allocations, it > seems prudent to at least make base GCC emit a warning if its going to > ignore an alignment request. [...] > I verified this doesn't break an amd64 kernel build, but I haven't had > time to look beyond that. Sharing in case anyone's interested and/or > wants to test further themselves. I love this. I have verified that kernels for all our gcc4 platforms still build with this diff. Miod > Index: gcc/cfgexpand.c > =================================================================== > RCS file: /home/matthew/cvs-mirror/cvs/src/gnu/gcc/gcc/cfgexpand.c,v > retrieving revision 1.4 > diff -u -p -r1.4 cfgexpand.c > --- gcc/cfgexpand.c 6 May 2014 23:32:34 -0000 1.4 > +++ gcc/cfgexpand.c 20 Jun 2014 22:55:53 -0000 > @@ -159,8 +159,10 @@ get_decl_align_unit (tree decl) > > align = DECL_ALIGN (decl); > align = LOCAL_ALIGNMENT (TREE_TYPE (decl), align); > - if (align > PREFERRED_STACK_BOUNDARY) > + if (align > PREFERRED_STACK_BOUNDARY) { > + warning (0, "ignoring alignment for stack allocated %q+D", decl); > align = PREFERRED_STACK_BOUNDARY; > + } > if (cfun->stack_alignment_needed < align) > cfun->stack_alignment_needed = align; > >