Better detection for certain broken cross-compiling situations.

Fixes bug 9869; patch from Benedikt Gollatz.