go version)?Compiling 1.12.0 release source code using GCC 8.2 gccgo
Yes
go env)?linux amd64
Attempting to build the 1.12 release using GCC 8.2 gccgo fails with:
GOOS=linux GOARCH=amd64 \
GOROOT=/tmp/go-1.12.0 \
GOROOT_FINAL=/opt/go-1.12 \
GOROOT_BOOTSTRAP=/opt/go \
GCCGO=gccgo \
./make.bash
Building Go cmd/dist using /opt/go.
Building Go toolchain1 using /opt/go.
# bootstrap/math/bits
/tmp/go-1.12.0/src/math/bits/bits.go:534:3: error: divideError is not a function; //go:linkname is only supported for functions
//go:linkname divideError runtime.divideError
^
/tmp/go-1.12.0/src/math/bits/bits.go:531:3: error: overflowError is not a function; //go:linkname is only supported for functions
//go:linkname overflowError runtime.overflowError
^
go tool dist: FAILED: /opt/go/bin/go install -gcflags=-l -tags=math_big_pure_go compiler_bootstrap bootstrap/cmd/...: exit status 2
Successful build
Failed build
/cc @ianlancetaylor; I presume this needs some sort of fix to be backported into 1.12.x.
In general I don't think we want to guarantee that the standard library can be built with gccgo. Certainly the runtime package cannot. While we should avoid introducing gratuitous differences it's hard to have no differences at all.
In this case the gccgo copy of math/bits is patched to avoid the problem.
In general we should probably fix gccgo to permit using go:linkname for a variable. While technically it cannot be fully supported, I think that in practice we can treat it as always creating a reference to an externally defined variable.
If you can point us to how to patch either gccgo or go, we'd be happy to apply the patch to our local build and report back. I am curious how the prebuilt packages are built and how it's different from how we're trying to build go, also.
I'm sorry, I'm not quite sure what you are asking.
gccgo comes with its own copy of the Go standard library. It can be found in the gccgo sources in the libgo subdirectory. That copy of the standard library is built using gccgo during the normal gccgo build and install. There are docs on how to do that at https://golang.org/doc/install/gccgo.
I think it could be useful that the gc toolchain can be bootstrapped with gccgo. Since this is in bootstrap code, maybe we want to consider to work around it. Otherwise people who want to bootstrap gc from gccgo would have to bootstrap an older version of gc then bootstrap gc tip from the older gc.
@cherrymui summarizes our situation -- we would like to avoid having to drag along older versions of gc just to bootstrap the latest release tarball using gccgo.
Change https://golang.org/cl/170737 mentions this issue: math/bits: add gccgo-friendly code for compiler bootstrap
@apaprocki This should be fixed now on tip (bootstrap with gccgo now works for me). Please reopen if you run into other issues.
Thanks!
fails on 1.12.7 with gcc-9.1.0 compiled with the gcc-go.
I guess the changes must be after this release?
```Building Go cmd/dist using /opt/test/gcc-go.
Building Go toolchain1 using /opt/test/gcc-go.
/home/michael/compile_by_hand/go/src/math/bits/bits.go:534:3: error: divideError is not a function; //go:linkname is only supported for functions
534 | //go:linkname divideError runtime.divideError
| ^
/home/michael/compile_by_hand/go/src/math/bits/bits.go:531:3: error: overflowError is not a function; //go:linkname is only supported for functions
531 | //go:linkname overflowError runtime.overflowError
| ^
go tool dist: FAILED: /opt/test/gcc-go/bin/go install -gcflags=-l -tags=math_big_pure_go compiler_bootstrap bootstrap/cmd/...: exit status 2
```
Correct. The changes to the math/bits package will be in the upcoming 1.13 release.
Most helpful comment
I think it could be useful that the gc toolchain can be bootstrapped with gccgo. Since this is in bootstrap code, maybe we want to consider to work around it. Otherwise people who want to bootstrap gc from gccgo would have to bootstrap an older version of gc then bootstrap gc tip from the older gc.