It sounds like you are running into some version of
https://golang.org/issue/18968. But to be honest I don't understand
what is forcing internal link mode. The linker defaults to using
external link mode with PIE. Using -linkmode=internal will override
that, but I don't see where any explicit -linkmode=internal would come
from.
And come to think of it the error seems to be happening at the wrong
time. The go_bootstrap build is built with the existing toolchain,
not the new one. I'm not sure what is happening.
> I also tried the following patch, but it did not help:
>
> --- go.orig/src/cmd/link/internal/ld/config.go 2017-04-07
> 16:54:08.000000000 +0000
> +++ go/src/cmd/link/internal/ld/config.go 2017-04-27 13:44:30.878077639
> +0000
> @@ -195,12 +195,8 @@
> case BuildmodeCShared:
> return true, "buildmode=c-shared"
> case BuildmodePIE:
> - switch obj.GOOS + "/" + obj.GOARCH {
> - case "linux/amd64":
> - default:
> - // Internal linking does not support TLS_IE.
> - return true, "buildmode=pie"
> - }
> + // Internal linking does not support TLS_IE.
> + return true, "buildmode=pie"
> case BuildmodePlugin:
> return true, "buildmode=plugin"
> case BuildmodeShared:
No, I wouldn't expect that to help, because the code that calls
mustLinkExternal already has an override to force external linking
mode for PIE. Something is passing -linkmode=internal but I'm not
sure what.
I assume you are not setting GO_EXTLINK_ENABLED in the environment.
> I am wondering how the default buildmode could be changed to PIE natively.
> Perhaps a build time configuration (environment) option for the default
> build mode could be added?
Yes, perhaps.
Ian