The broken interaction between -mstackrealign and -mavx512f is a bug that this would hide, and should absolutely be fixed independently. However, at the same time, the rest of the bug is something for which the right fix is to replace the -mstackrealign (which simply papers over the bug) with -mpreferred-stack-boundary=2.
Definitely, but it should be replaced in the gcc code, like the proposed patch does.
Sure. My reason for proposing this patch is that the gcc bug may take some time to be solved and propagate, and in the meantime, working around the bug using the same logic seems anodyne enough.
I think that -mpreferred-stack-boundary=2 is a better solution than force_align_arg_pointer, since the former should only force stack realignment where we actually need it, but I'll leave that for a separate change.
We can't know when it's needed, since .dll.so files can call host functions that require the stack to be aligned.
Ah, that makes sense.