Re-commit r238838, r238844 with fix for host/target endian mismatch and windows buildbot.