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.
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.