go get tries to rebuild standard library
The following bug was reported by Mo0O a couple of days ago on the #alpine-devel IRC channel.
16:08 < Mo0O> hi there
16:08 < Mo0O> it looks like the alpine golang pkg is broken, all standard library packages are missing
16:08 < Mo0O> do you confirm that?
16:10 < RieSh2be> hello, 3.4 or edge?
16:10 < Mo0O> RieSh2be: edge
16:11 < Mo0O> go1.7rc3
16:12 <@ncopa> hum
16:12 <@ncopa> ok, will have a look at that. if i forget, then please file a bug for it
16:12 <@ncopa> on bugs.a.o
16:13 < Mo0O> on a fresh install, trying a `go get` for any random package tries to install package like `runtime/internal/sys`, for example
I looked a bit into this and was able to reproduce this issue, however the assumption that all standard library packages are missing is wrong. What seems to be happening is the following: Since go 1.5 `go build -a` also applies to the standard library https://go-review.googlesource.com/\#/c/10761/ for reasons unknown to me the go compiler seems to be of the opinion that the standard library needs be rebuild. Since you can’t modify files in /usr/lib/go as an ordinary user you get a permission error.
This seems to be related to the fact that we enable `-buildmode=pie` by default. After removing the patch from the aports tree I was no longer able to reproduce the issue. It only seems to occur when go itself is compiled with `-buildmode=pie` thus this might actually be an upstream bug. As a workaround I modified the patch a bit and build go itself with `-buildmode=default` but all go packages can still be compiled with `-buildmode=pie`. The patch is attached.
To fix this issue for real we could make use of the following change https://go-review.googlesource.com/\#/c/22432/ which would allow us to figure out why the go compiler believes that the standard library needs to be rebuild when the compiler itself is build with `-buildmode=pie`.
Assigning this to Timo since he wrote the original patch.
(from redmine: issue id 6029, created on 2016-08-11)