IMO the root of all these problems is that the MPI standard is based on a lot of magic global state, and thus libraries that use MPI do not compose.

The right way to fix this is to kill this global state.

That would mean allowing a single MPI_Session per process, and recommending libraries that use MPI that they should take a pointer/reference/... of this single MPI session instead of creating it by themselves (which is akin to calling Init/FInalize).