Manually rebase @mingwandroid's patches against this version, plus my own patch to link the import library rather than the DLL, for LLD support.