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

cmd/go: with -compiler=gccgo, only call runtime.setmodinfo if using a version of gccgo that supports it #42916

Open
dotaheor opened this issue Dec 1, 2020 · 6 comments
Labels
help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@dotaheor
Copy link

dotaheor commented Dec 1, 2020

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

$ go version
go version devel +7f688d18c0 Mon Nov 30 22:14:36 2020 +0000 linux/amd64

Does this issue reproduce with the latest release?

No. It is on tip only.

$ gccgo --version
gccgo (Debian 8.3.0-6) 8.3.0
Copyright (C) 2018 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/dotaheor/.cache/go-build"
GOENV="/home/dotaheor/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/dotaheor/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/dotaheor/go"
GOPRIVATE=""
GOROOT="/usr/bin/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/bin/go/pkg/tool/linux_amd64"
GCCGO="/usr/bin/gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD=""
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-build239828229=/tmp/go-build -gno-record-gcc-switches"

What did you do?

go run -compiler=gccgo example.go

What did you expect to see?

Normal run.

What did you see instead?

# command-line-arguments
/usr/bin/ld: $WORK/b001/_pkg_.a(_go_.o): in function `main.main..init0':
/tmp/go-build/b001/_gomod_.go:5: undefined reference to `runtime.setmodinfo

It is on Debian 10 stable.

@gopherbot gopherbot added this to the Gccgo milestone Dec 1, 2020
@jayconrod
Copy link
Contributor

@dotaheor I wasn't able to reproduce this at the commit you listed.

Could you edit the issue to include the full go env output? It's important for debugging so please don't skip it. Please also let us know the gccgo version you're using, the Linux distribution and version, and any other information that would help us reproduce. If you can reproduce this with a minimal Dockerfile for example, that would be super helpful.

@jayconrod jayconrod added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Dec 1, 2020
@dotaheor
Copy link
Author

dotaheor commented Dec 2, 2020

OK, it is included now. But I looks there is not much useful info in the output.

Other info

  • It is ok to run gccgo solely.
  • It is ok to run gccgo with Go 1.15 command.

@jayconrod
Copy link
Contributor

Thanks, I was able to reproduce the issue using a toolchain built with this Dockerfile:

FROM debian:10
RUN apt-get update
RUN apt-get install -y gccgo git golang
RUN git clone https://go.googlesource.com/go /goroot && \
  cd /goroot/src && \
  git checkout 7f688d18c0 && \
  ./make.bash
ENV PATH=/goroot/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin

This is with: gcc version 8.3.0 (Debian 8.3.0-6)

It looks like this issue was exposed when we enabled GO111MODULE=on by default. I also reproduced it with Go 1.15.5 when that environment variable was set explicitly.

In module mode, we embed version information in linked binaries. The symbol runtime.setmodinfo is used to set that information. It looks like when a binary is linked in module mode, that symbol is missing.

@ianlancetaylor Any idea what might cause this?

cc @bcmills @matloob

@jayconrod jayconrod added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. labels Dec 2, 2020
@ianlancetaylor
Copy link
Contributor

The version of gccgo being used is too old. The runtime.setmodinfo function was introduced in GCC 10.

This is the kind of problem that is inevitable when using the "go" tool from the gc toolchain with gccgo. We try to make them work together, but it's hard to avoid all version mismatch problems. If you want to use gccgo, the best approach is to use the "go" tool that comes with the version of gccgo that you are using.

That said, this is a bug, although not a very important one, so leaving this issue open.

@ianlancetaylor ianlancetaylor changed the title cmd/go: unable to use gccgo cmd/go: with -compiler=gccgo, only call runtime.setmodinfo if using a version of gccgo that supports it Dec 3, 2020
@ianlancetaylor ianlancetaylor added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Dec 3, 2020
@ianlancetaylor ianlancetaylor modified the milestones: Gccgo, Backlog Dec 3, 2020
@gopherbot gopherbot removed the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 3, 2020
@apm-opentt
Copy link

Is there a work around to link runtime.setmodinfo symbol?

@bcmills bcmills modified the milestones: Backlog, Unplanned Oct 5, 2021
@ianlancetaylor
Copy link
Contributor

@apm-opentt I can't think of one. Sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

6 participants