Implement flexible target specification

See commit message.
The comment in the PR about the 64bit ABI changes needed.