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.
Could you add a comment explaining this (so that it is easier for someone to deduce the purpose of the test in future)? Something like

> the compiler needs to copy and modify the rlib file when performing LTO, so we should ensure that it can cope with the original rlib being read-only.