Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gccgo: fail to bootstrap go1.21 #60913

Closed
zhsj opened this issue Jun 21, 2023 · 3 comments
Closed

gccgo: fail to bootstrap go1.21 #60913

zhsj opened this issue Jun 21, 2023 · 3 comments
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Milestone

Comments

@zhsj
Copy link
Contributor

zhsj commented Jun 21, 2023

What version of Go are you using (go version)?

$ go version
go version go1.18 gccgo (Debian 12.3.0-4) 12.3.0 linux/amd64

Does this issue reproduce with the latest release?

Haven't tested with gcc13.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE="on"
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/zsj/.cache/go-build"
GOENV="/home/zsj/.config/go/env"
GOEXE=""
GOEXPERIMENT="fieldtrack,regabiwrappers"
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/zsj/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/zsj/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn"
GOROOT="/usr"
GOSUMDB="sum.golang.google.cn"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/gcc/x86_64-linux-gnu/12"
GOVCS=""
GOVERSION="go1.18 gccgo (Debian 12.3.0-4) 12.3.0"
GCCGO="/usr/bin/x86_64-linux-gnu-gccgo-12"
GOAMD64="v1"
AR="ar"
CC="x86_64-linux-gnu-gcc-12"
CXX="x86_64-linux-gnu-g++-12"
CGO_ENABLED="1"
GOMOD="/home/zsj/Workspaces/debian/package/pkg-go/golang/src/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4044047194=/tmp/go-build -gno-record-gcc-switches -funwind-tables"

What did you do?

GOROOT_BOOTSTRAP=$(go-12 env GOROOT) ./make.bash

What did you expect to see?

No error.

What did you see instead?

      |                            ^
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/internal/profile/profile.go:14:28: error: import file 'internal/lazyregexp' not found
   14 |         "internal/lazyregexp"
      |                            ^
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/internal/profile/legacy_profile.go:22:24: error: reference to undefined name 'lazyregexp'
   22 |         countStartRE = lazyregexp.New(`\A(\w+) profile: total \d+\n\z`)
      |                        ^
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/internal/profile/legacy_profile.go:23:24: error: reference to undefined name 'lazyregexp'
   23 |         countRE      = lazyregexp.New(`\A(\d+) @(( 0x[0-9a-f]+)+)\n\z`)
      |                        ^
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/internal/profile/legacy_profile.go:25:24: error: reference to undefined name 'lazyregexp'
   25 |         heapHeaderRE = lazyregexp.New(`heap profile: *(\d+): *(\d+) *\[ *(\d+): *(\d+) *\] *@ *(heap[_a-z0-9]*)/?(\d*)`)
      |                        ^
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/internal/profile/legacy_profile.go:26:24: error: reference to undefined name 'lazyregexp'
   26 |         heapSampleRE = lazyregexp.New(`(-?\d+): *(-?\d+) *\[ *(\d+): *(\d+) *] @([ x0-9a-f]*)`)
      |                        ^
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/internal/profile/legacy_profile.go:28:30: error: reference to undefined name 'lazyregexp'
   28 |         contentionSampleRE = lazyregexp.New(`(\d+) *(\d+) @([ x0-9a-f]*)`)
      |                              ^
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/internal/profile/legacy_profile.go:30:23: error: reference to undefined name 'lazyregexp'
   30 |         hexNumberRE = lazyregexp.New(`0x[0-9a-f]+`)
      |                       ^
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/internal/profile/legacy_profile.go:32:26: error: reference to undefined name 'lazyregexp'
   32 |         growthHeaderRE = lazyregexp.New(`heap profile: *(\d+): *(\d+) *\[ *(\d+): *(\d+) *\] @ growthz`)
      |                          ^
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/internal/profile/legacy_profile.go:34:33: error: reference to undefined name 'lazyregexp'
   34 |         fragmentationHeaderRE = lazyregexp.New(`heap profile: *(\d+): *(\d+) *\[ *(\d+): *(\d+) *\] @ fragmentationz`)
      |                                 ^
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/internal/profile/legacy_profile.go:36:26: error: reference to undefined name 'lazyregexp'
   36 |         threadzStartRE = lazyregexp.New(`--- threadz \d+ ---`)
      |                          ^
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/internal/profile/legacy_profile.go:37:26: error: reference to undefined name 'lazyregexp'
   37 |         threadStartRE  = lazyregexp.New(`--- Thread ([[:xdigit:]]+) \(name: (.*)/(\d+)\) stack: ---`)
      |                          ^
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/internal/profile/legacy_profile.go:39:22: error: reference to undefined name 'lazyregexp'
   39 |         procMapsRE = lazyregexp.New(`([[:xdigit:]]+)-([[:xdigit:]]+)\s+([-rwxp]+)\s+([[:xdigit:]]+)\s+([[:xdigit:]]+):([[:xdigit:]]+)\s+([[:digit:]]+)\s*(\S+)?`)
      |                      ^
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/internal/profile/legacy_profile.go:41:23: error: reference to undefined name 'lazyregexp'
   41 |         briefMapsRE = lazyregexp.New(`\s*([[:xdigit:]]+)-([[:xdigit:]]+):\s*(\S+)(\s.*@)?([[:xdigit:]]+)?`)
      |                       ^
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/internal/profile/legacy_profile.go:634:9: error: range clause must have array, slice, string, map, or channel type
  634 |         for _, s := range hexStrings {
      |         ^
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/internal/profile/profile.go:195:13: error: reference to undefined name 'lazyregexp'
  195 | var libRx = lazyregexp.New(`([.]so$|[.]so[._][0-9]+)`)
      |             ^
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/internal/profile/legacy_profile.go:634:13: error: invalid type for range clause
  634 |         for _, s := range hexStrings {
      |             ^
note: module requires Go 1.20
# bootstrap/cmd/compile/internal/types
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/cmd/compile/internal/types/goversion.go:10:28: error: import file 'internal/lazyregexp' not found
   10 |         "internal/lazyregexp"
      |                            ^
/home/zsj/Workspaces/debian/package/pkg-go/golang/src/cmd/compile/internal/types/goversion.go:84:19: error: reference to undefined name 'lazyregexp'
   84 | var goVersionRE = lazyregexp.New(`^go([1-9]\d*)\.(0|[1-9]\d*)$`)
      |                   ^
note: module requires Go 1.20
# bootstrap/cmd/cgo
/usr/bin/ld: warning: stub.o: missing .note.GNU-stack section implies executable stack
/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
/usr/bin/ld: $WORK/b014/_pkg_.a(_go_.o):(.data.rel.ro.bootstrap_1internal_1abi.FuncPCABIInternal..f+0x0): undefined reference to `bootstrap_1internal_1abi.FuncPCABIInternal'
/usr/bin/ld: $WORK/b014/_pkg_.a(_go_.o):(.data.rel.ro.bootstrap_1internal_1abi.FuncPCABI0..f+0x0): undefined reference to `bootstrap_1internal_1abi.FuncPCABI0'
collect2: error: ld returned 1 exit status
# bootstrap/cmd/link
/usr/bin/ld: warning: stub.o: missing .note.GNU-stack section implies executable stack
/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
/usr/bin/ld: $WORK/b014/_pkg_.a(_go_.o):(.data.rel.ro.bootstrap_1internal_1abi.FuncPCABIInternal..f+0x0): undefined reference to `bootstrap_1internal_1abi.FuncPCABIInternal'
/usr/bin/ld: $WORK/b014/_pkg_.a(_go_.o):(.data.rel.ro.bootstrap_1internal_1abi.FuncPCABI0..f+0x0): undefined reference to `bootstrap_1internal_1abi.FuncPCABI0'
collect2: error: ld returned 1 exit status
# bootstrap/cmd/asm
/usr/bin/ld: warning: stub.o: missing .note.GNU-stack section implies executable stack
/usr/bin/ld: NOTE: This behaviour is deprecated and will be removed in a future version of the linker
/usr/bin/ld: $WORK/b014/_pkg_.a(_go_.o):(.data.rel.ro.bootstrap_1internal_1abi.FuncPCABIInternal..f+0x0): undefined reference to `bootstrap_1internal_1abi.FuncPCABIInternal'
/usr/bin/ld: $WORK/b014/_pkg_.a(_go_.o):(.data.rel.ro.bootstrap_1internal_1abi.FuncPCABI0..f+0x0): undefined reference to `bootstrap_1internal_1abi.FuncPCABI0'
collect2: error: ld returned 1 exit status
go tool dist: FAILED: /usr/bin/go install -tags=math_big_pure_go compiler_bootstrap purego bootstrap/cmd/...: exit status 2

@gopherbot gopherbot added this to the Gccgo milestone Jun 21, 2023
@ianlancetaylor
Copy link
Contributor

Interesting. This seems to be because Go 1.17 (the required bootstrap compiler version) has internal/lazyregexp, and permits it to be imported by the tools that it is building. When using gccgo as the bootstrap compiler, gccgo does not permit this. gccgo does have a list of internal packages that it installs in order to build the gc toolchain, but internal/lazyregexp is not on that list.

@ianlancetaylor ianlancetaylor modified the milestones: Gccgo, Go1.21 Jun 21, 2023
@gopherbot
Copy link

Change https://go.dev/cl/505036 mentions this issue: cmd/dist, internal/abi: support bootstrapping with gccgo

@gopherbot
Copy link

Change https://go.dev/cl/504798 mentions this issue: compiler, libgo: support bootstrapping gc compiler

@dmitshur dmitshur added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Jun 22, 2023
gopherbot pushed a commit to golang/gofrontend that referenced this issue Jun 23, 2023
In the Go 1.21 release the package internal/profile imports
internal/lazyregexp.  That works when bootstrapping with Go 1.17,
because that compiler has internal/lazyregep and permits importing it.
We also have internal/lazyregexp in libgo, but since it is not installed
it is not available for importing.  This CL adds internal/lazyregexp
to the list of internal packages that are installed for bootstrapping.

The Go 1.21, and earlier, releases have a couple of functions in
the internal/abi package that are always fully intrinsified.
The gofrontend recognizes and intrinsifies those functions as well.
However, the gofrontend was also building function descriptors
for references to the functions without calling them, which
failed because there was nothing to refer to.  That is OK for the
gc compiler, which guarantees that the functions are only called,
not referenced.  This CL arranges to not generate function descriptors
for these functions.

For golang/go#60913

Change-Id: I6a071e378205e5e90cfaebad23aca33dcfcef074
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/504798
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
nstester pushed a commit to nstester/gcc that referenced this issue Jun 23, 2023
In the Go 1.21 release the package internal/profile imports
internal/lazyregexp.  That works when bootstrapping with Go 1.17,
because that compiler has internal/lazyregep and permits importing it.
We also have internal/lazyregexp in libgo, but since it is not installed
it is not available for importing.  This CL adds internal/lazyregexp
to the list of internal packages that are installed for bootstrapping.

The Go 1.21, and earlier, releases have a couple of functions in
the internal/abi package that are always fully intrinsified.
The gofrontend recognizes and intrinsifies those functions as well.
However, the gofrontend was also building function descriptors
for references to the functions without calling them, which
failed because there was nothing to refer to.  That is OK for the
gc compiler, which guarantees that the functions are only called,
not referenced.  This CL arranges to not generate function descriptors
for these functions.

For golang/go#60913

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/504798
kraj pushed a commit to kraj/gcc that referenced this issue Jun 24, 2023
In the Go 1.21 release the package internal/profile imports
internal/lazyregexp.  That works when bootstrapping with Go 1.17,
because that compiler has internal/lazyregep and permits importing it.
We also have internal/lazyregexp in libgo, but since it is not installed
it is not available for importing.  This CL adds internal/lazyregexp
to the list of internal packages that are installed for bootstrapping.

The Go 1.21, and earlier, releases have a couple of functions in
the internal/abi package that are always fully intrinsified.
The gofrontend recognizes and intrinsifies those functions as well.
However, the gofrontend was also building function descriptors
for references to the functions without calling them, which
failed because there was nothing to refer to.  That is OK for the
gc compiler, which guarantees that the functions are only called,
not referenced.  This CL arranges to not generate function descriptors
for these functions.

For golang/go#60913

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/504798
kraj pushed a commit to kraj/gcc that referenced this issue Jun 24, 2023
In the Go 1.21 release the package internal/profile imports
internal/lazyregexp.  That works when bootstrapping with Go 1.17,
because that compiler has internal/lazyregep and permits importing it.
We also have internal/lazyregexp in libgo, but since it is not installed
it is not available for importing.  This CL adds internal/lazyregexp
to the list of internal packages that are installed for bootstrapping.

The Go 1.21, and earlier, releases have a couple of functions in
the internal/abi package that are always fully intrinsified.
The gofrontend recognizes and intrinsifies those functions as well.
However, the gofrontend was also building function descriptors
for references to the functions without calling them, which
failed because there was nothing to refer to.  That is OK for the
gc compiler, which guarantees that the functions are only called,
not referenced.  This CL arranges to not generate function descriptors
for these functions.

For golang/go#60913

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/504798
bradfitz pushed a commit to tailscale/go that referenced this issue Jul 15, 2023
The required gc bootstrap compiler, 1.17, has an internal/lazyregexp
package. It permits that package to be imported by internal/profile
while bootstrapping. The gccgo compiler also has an internal/lazyregexp
package, but it does not permit the gc compiler to import it.

Permit bootstrapping with gccgo by adding internal/lazyregexp to the
list of bootstrap directories.

The gccgo compiler recognizes the magic functions internal/abi.FuncPCABI0
and FuncPCABIInternal, but only in the internal/abi package, not
in the bootstrapping internal/abi package.

Permit bootstrapping with gccgo by adding definitions of those functions
with build tags so that they are only used by gccgo.

Fixes golang#60913

Change-Id: I3a78848d545db13314409d170d63f4cc737ca12e
Reviewed-on: https://go-review.googlesource.com/c/go/+/505036
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
rsh-raj pushed a commit to rsh-raj/gcc that referenced this issue Oct 6, 2023
In the Go 1.21 release the package internal/profile imports
internal/lazyregexp.  That works when bootstrapping with Go 1.17,
because that compiler has internal/lazyregep and permits importing it.
We also have internal/lazyregexp in libgo, but since it is not installed
it is not available for importing.  This CL adds internal/lazyregexp
to the list of internal packages that are installed for bootstrapping.

The Go 1.21, and earlier, releases have a couple of functions in
the internal/abi package that are always fully intrinsified.
The gofrontend recognizes and intrinsifies those functions as well.
However, the gofrontend was also building function descriptors
for references to the functions without calling them, which
failed because there was nothing to refer to.  That is OK for the
gc compiler, which guarantees that the functions are only called,
not referenced.  This CL arranges to not generate function descriptors
for these functions.

For golang/go#60913

Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/504798
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. release-blocker
Projects
None yet
Development

No branches or pull requests

4 participants