rustc: Fix permission denied error in 'ar' when lto is enabled

The reason that 'ar' can fail with permission denied is that when
link-time optimizations are enabled, rustc copies libraries into a
temporary directory, preserving file permissions, and subsequently
modifies them using 'ar'.

The modification can fail because some package managers may install
libraries in system directories as read-only files, which means the
temporary file also becomes read-only when it is copied.

I have fixed this by giving the temporary file's owner read+write
permissions after the copy.

I have also added a regression test for this issue.
Maybe this could include some more information, e.g. why the `chmod` is necessary, and, if possible, what the user can do to fix it? (As a user, I would find it unintuitive that the compiler is trying to chmod a copy of some external crate; specifically mentioning LTO would be a good start, e.g. `"failed to chmod {} when preparing for LTO: {}"`.)