add a modified version of the mips64 patch from #4603