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

x/build: releaselet for Go 1.16 produces binary that can't link cgo on Ubuntu 14.04 #43996

Open
evanj opened this issue Jan 29, 2021 · 6 comments
Open

Comments

@evanj
Copy link
Contributor

@evanj evanj commented Jan 29, 2021

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

$ go version

go1.16rc1

Does this issue reproduce with the latest release?

Yes.

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

go env Output
$ go env

GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.16rc1"
GCCGO="gccgo"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/shared/go.mod"
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-build704623638=/tmp/go-build -gno-record-gcc-switches"

What did you do?

  1. Download Go 1.16rc1 linux amd64 release on to a Ubuntu 14.04 Trusty system
  2. Attempt to link a Go program that uses Cgo.

What did you expect to see?

A correctly linked binary.

What did you see instead?

/usr/local/go/pkg/tool/linux_amd64/link -o $WORK/b001/exe/a.out -importcfg $WORK/b001/importcfg.link -buildmode=exe -buildid=dx0H7nktY5bJLfxiNI0p/uqwImzVISJS7i4MYRZEk/TLUSJTYITbUnYwoTsd1m/dx0H7nktY5bJLfxiNI0p -extld=gcc $WORK/b001/_pkg_.a
# github.com/evanj/linkexample/cgobasic
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /tmp/go-link-642826874/000006.o: unrecognized relocation (0x2a) in section `.text'
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

This program builds correctly with Go 1.15.7, or if I run all.bash to build Go 1.16rc1 locally.

My guess at what is happening

I think this means Go 1.16rc1 was built on a version of Linux with binutils > 2.24, which seems to be what happened with a previous similar issue: #31293

It could be that this is expected: Ubuntu 14.04 Trusty is End of Life and no longer supported, and the workaround is to build your own version of the Go tools. However, if this is expected, a mention in the release notes would be nice, and maybe a mention in the minimum requirements wiki page? https://github.com/golang/go/wiki/MinimumRequirements

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Jan 29, 2021

For the record, the relocation is R_X86_64_REX_GOTPCRELX.

I don't think this affects https://golang.org/wiki/MinimumRequirements. The minimum requirements remain the same. This only applies to the binary release. I don't know what guidelines we might have for the binary releases.

CC @dmitshur @toothrot @cagedmantis

@dmitshur
Copy link
Member

@dmitshur dmitshur commented Jan 29, 2021

Yes, we have started using a newer distribution of Linux to build the binaries as of Go 1.16. The rationale is described in #40561 (comment). I'll copy it here:

Rationale: Debian 8 "Jessie" Long Term Support (LTS) has ended on June 30, 2020 (see https://wiki.debian.org/LTS). We want to start using the next stable release, Debian 9 "Stretch", which has LTS support until June 2022.

From https://wiki.ubuntu.com/Releases, I see that Ubuntu 14.04 LTS (first released in 2014) standard support ended on April 2019, and EOL is on April 2022.

@dmitshur dmitshur changed the title Go 1.16rc1: Cgo unrecognized relocation (0x2a) on Ubuntu 14.04 x/build: releaselet for Go 1.16 produces binary that can't link cgo on Ubuntu 14.04 Jan 29, 2021
@gopherbot gopherbot added the Builders label Jan 29, 2021
@gopherbot gopherbot added this to the Unreleased milestone Jan 29, 2021
@dmitshur dmitshur modified the milestones: Unreleased, Go1.16 Jan 29, 2021
@evanj
Copy link
Contributor Author

@evanj evanj commented Jan 29, 2021

Thank you! Then from my perspective, this issue could be closed, although I would love it if this were documented this somewhere? This information is not easy to find. Some information that seems to be the current policy:

  • Mac OS X: The release notes will describe the minimum version of Mac OS X that are supported both by binary releases of Go tools, and by binaries produced by those tools. This will include all Mac OS X releases still receiving security updates at the time of the release, and may include older versions. This is paraphrased from this issue: #23011

  • Linux: The requirements for binaries produced by the Go tools are documented on the wiki: https://github.com/golang/go/wiki/MinimumRequirements ; The requirements for binary releases are undocumented. This issues suggests that binary releases will support the oldest supported Debian LTS release at the time of the Go release. This means binary releases should also work on newer Debian distributions, and other distributions with compatible tool chains and libraries. To support other distribution, you should build the Go tools from source.

  • Windows: The requirements for both binary releases and binaries produced by the Go tools are documented on the wiki: https://github.com/golang/go/wiki/MinimumRequirements

My suggestion would be to update the wiki page with some additional detail about the Linux binary release requirements, and link to the wiki page from the Release Policy: https://golang.org/doc/devel/release.html#policy ; but honestly any place other than the Go issue tracker would be appreciated! I will be happy to submit some change somewhere, but given that I don't know where it should go, nor what it should say, it might be easier for someone else to do it. Thanks for the rapid clarification!

@odeke-em
Copy link
Member

@odeke-em odeke-em commented Feb 11, 2021

Thank you for the report @evanj, and for answering questions Ian, and Dmitri!

@evanj, thanks for the suggestions and conclusion in #43996 (comment), this then frees up this issue from holding up Go1.16. In regards to sending a change, I am not sure where else this could go, but for a start, please send a change to the Wiki and as Go1.17 and others progress, perhaps we can raise this with the @golang/release team to help decide where else to document these requirements.

@adam-azarchs
Copy link
Contributor

@adam-azarchs adam-azarchs commented Feb 19, 2021

For what it's worth, this is also breaking linkage on Ubuntu 14 (trusty). That's also out of support of course, but more recently so. That's binutils 2.24. While I haven't tested on CentOS 6 (which is of course also out of support but still in widespread use by sysadmins who are still procrastinating on the whole systemd thing), CentOS6 uses binutils 2.23. Ubuntu 16 (xenial), with binutils 2.26, does seem to work.

Unfortunately too many of our customers still use CentOS6 to allow us to drop support, so we have to continue building there, which makes this problematic for us. We can probably get by with updating binutils, or if this is really just a problem with the binaries we can build our own go binaries.

@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Feb 20, 2021

It's really just a problem with the binaries. If you build your own binaries on the systems in question you will not see this problem.

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