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

Comments

@dotaheor
Copy link

@dotaheor 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

@jayconrod jayconrod commented Dec 1, 2020

@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.

@dotaheor
Copy link
Author

@dotaheor 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

@jayconrod jayconrod commented Dec 2, 2020

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

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Dec 3, 2020

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 removed this from the Gccgo milestone Dec 3, 2020
@ianlancetaylor ianlancetaylor added this to the Backlog milestone Dec 3, 2020
@apm-opentt
Copy link

@apm-opentt apm-opentt commented Oct 5, 2021

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

@bcmills bcmills removed this from the Backlog milestone Oct 5, 2021
@bcmills bcmills added this to the Unplanned milestone Oct 5, 2021
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Oct 5, 2021

@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
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
6 participants