Native 64-bit builds

This set of changes introduces a working native 64-bit Linux build target (0.4.40).

This is primarily the prior work of Shixin Zeng (@zsx, see #142) and Ladislav Mecir (@ladislav, see #178) but minimally restructured and rebased on top of current master.