Create _imp__ symbols also when doing ThinLTO by Zoxc · Pull Request #129079 · rust-lang/rust (original) (raw)

When generating a rlib crate on Windows we create dllimport / _imp__ symbols for each global. This effectively makes the rlib contain an import library for itself and allows them to both be dynamically and statically linked. However when doing ThinLTO we do not generate these and thus we end up with missing symbols. Microsoft's link can fix these up (and emits warnings), but lld seems to currently be unable to.

This PR also does this generation for ThinLTO avoiding those issues with lld and also avoids the warnings on link.

This is an workaround for #81408.

cc @lqd