Implement bare-bones cross compilation support

This also refactored many things along the way, I would recommend reading each commit individually rather than them all as a whole.

Closes #119