Fixes bug 7727; fix on 0.2.4.10-alpha.
This beats our old implementation, which wouldn't work when cross-compiling