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

/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found #58550

Closed
andig opened this issue Feb 15, 2023 · 17 comments
Closed

/lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found #58550

andig opened this issue Feb 15, 2023 · 17 comments
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@andig
Copy link
Contributor

andig commented Feb 15, 2023

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

$ go version
go version go1.20 darwin/arm64

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="arm64"
GOBIN=""
GOCACHE="/Users/andig/Library/Caches/go-build"
GOENV="/Users/andig/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="arm64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/andig/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/andig/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_arm64"
GOVCS=""
GOVERSION="go1.20"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/andig/htdocs/evcc/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/sv/rs_453y57xj86xsbz3kw1mbc0000gn/T/go-build3562167146=/tmp/go-build -gno-record-gcc-switches -fno-common"
GOROOT/bin/go version: go version go1.20 darwin/arm64
GOROOT/bin/go tool compile -V: compile version go1.20
uname -v: Darwin Kernel Version 22.2.0: Fri Nov 11 02:04:44 PST 2022; root:xnu-8792.61.2~4/RELEASE_ARM64_T8103
ProductName:		macOS
ProductVersion:		13.1
BuildVersion:		22C65
lldb --version: lldb-1400.0.38.17
Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)

What did you do?

After upgrading our build environment and go.mod requirement to Go 1.20, users started to see this error message on Ubuntu: evcc-io/evcc#6263. The application does not use CGO.

What did you expect to see?

No error. Same build was working fine with Go ^1.18.

What did you see instead?

GLIBC version required. This output of go version -m should be similar to what the build produces for arm:

build	-buildmode=exe
build	-compiler=gc
build	-ldflags="-X github.com/evcc-io/evcc/server.Version=0.109.2 -X github.com/evcc-io/evcc/server.Commit=3ec2d1b70 -s -w"
build	-tags=release
build	CGO_ENABLED=0
build	GOARCH=arm
build	GOOS=linux
build	GOARM=6
build	vcs=git
build	vcs.revision=3ec2d1b70abf2a5a827e43755f5e94df59eb1add
build	vcs.time=2022-12-19T13:08:03Z
build	vcs.modified=true
@seankhliao
Copy link
Member

What's the output of go version -m on the actual built binary?
There are parts of the stdlib that will use cgo if not explicitly disabled.

@seankhliao seankhliao added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Feb 15, 2023
@seankhliao
Copy link
Member

Looking at the evcc issue, it's your nightly ubuntu builds.
These are linked against glibc.

As we no longer ship precompiled archives for the standard library,
it's up to you to ensure glibc linking (if you use it, eg using net) works.
https://go.dev/doc/go1.20#go-command

root@c737fabce3a0:/# go version -m /usr/bin/evcc
/usr/bin/evcc: go1.20
	path	command-line-arguments
	...
	build	-buildmode=exe
	build	-compiler=gc
	build	-ldflags="-X github.com/evcc-io/evcc/server.Version=0.112.5 -X github.com/evcc-io/evcc/server.Commit=99595b72 -s -w"
	build	-tags=release
	build	CGO_ENABLED=1
	build	CGO_CFLAGS=
	build	CGO_CPPFLAGS=
	build	CGO_CXXFLAGS=
	build	CGO_LDFLAGS=
	build	GOARCH=amd64
	build	GOOS=linux
	build	GOAMD64=v1
root@c737fabce3a0:/# ldd /usr/bin/evcc 
	linux-vdso.so.1 (0x00007fffde69b000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f943b894000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f943bac1000)

Closing as working as intended.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Feb 15, 2023
@andig
Copy link
Contributor Author

andig commented Feb 15, 2023

I'm surprised to find this:

       build	-buildmode=exe
	build	-compiler=gc
	build	-ldflags="-X github.com/evcc-io/evcc/server.Version=0.112.5-next -s -w"
	build	-tags=release
	build	CGO_ENABLED=1
	build	CGO_CFLAGS=
	build	CGO_CPPFLAGS=
	build	CGO_CXXFLAGS=
	build	CGO_LDFLAGS=
	build	GOARCH=arm64
	build	GOOS=linux

since the goreleaser config nowhere mentions to enable cgo.

As we no longer ship precompiled archives for the standard library, it's up to you to ensure glibc linking (if you use it, eg using net) works. https://go.dev/doc/go1.20#go-command

I have unfortunately no idea what that means. I've re-read the go command section and am still puzzled what pre-compiled archives (for what?) have to do with the compiled binary.

it's up to you to ensure glibc linking (if you use it, eg using net) works.

And no idea what that means. net is used. Happy to head over to golang nuts, but maybe a small pointer could already help.

@andig
Copy link
Contributor Author

andig commented Feb 15, 2023

More specifically, when the CGO_ENABLED environment variable is unset, the CC environment variable is unset, and the default C compiler (typically clang or gcc) is not found in the path, CGO_ENABLED defaults to 0. As always, you can override the default by setting CGO_ENABLED explicitly.

I have CGO_ENABLED unset in the build environment. It's confusing that the build would end with CGO_ENABLED=1? Seems this wasn't the case with Go 1.19.

@ianlancetaylor
Copy link
Contributor

CGO_ENABLED=1 is the default and always has been. It's true that in 1.19 if you built the tools with CGO_ENABLED=0, then the tools would in turn default to building programs with CGO_ENABLED=0. I believe that that is no longer true in 1.20.

@andig
Copy link
Contributor Author

andig commented Feb 15, 2023

Thank you both.

I've re-run the golang-releaser build with 1.19 and it ends up with CGO_ENABLED=1, too. With 1.19 that doesn't hurt apparently, with 1.20 it does. I'm not a compiler person and totally fail to make the connection from the Go release notes to the problem observed. I do understand that dynamic linking requires the link targets to be available at runtime. What I don't get is what has changed between 1.19 and 1.20 that makes it behave differently with regards to runtime behaviour.

Happy to not get an answer, solved by forcing the build to CGO_ENABLED=0 which I suspected to be the default all the time. I could imagine though that the change in behaviour will confuse other devs, too.

@seankhliao
Copy link
Member

see #57328

@pplmx
Copy link

pplmx commented Feb 24, 2023

hi, there
how to fix it? I need CGO_ENABLED=1(build a shared object from the go project).
I rollback the go from 1.20.1 to 1.19.6, and the go.mod downgrade to 1.18, this issue still occurred.

@andig
Copy link
Contributor Author

andig commented Feb 24, 2023

AFAIU, for CGO_ENABLED=1, you'll need to use a glibc version during compile that matches (or is lower) than the one on your target runtime system.

@pplmx
Copy link

pplmx commented Feb 24, 2023

Host OS is ubuntu 22.04(I build the so here)
Running Container is ubuntu 18.04(Running the program here)
I need

  1. build the so file on ubuntu 18.04, and then run it on the container 18.04, right?
  2. Or upgrade my container os version?

cwarden added a commit to cwarden/force that referenced this issue Apr 19, 2023
Explicitly disable CGO when building binaries.  As of Go 1.20, we get
dynamic executables when using standard libary packages that have both
cgo and pure Go implementations.

Fixes errors in which release binaries may fail because the correct
version of libc can't be linked at runtime.

See golang/go#58550
vvidovic pushed a commit to croz-ltd/dpcmder that referenced this issue May 17, 2023
New Go version causes different linking behaviour in produced
executable. On older Linux machines the following error occured:
```
dpcmder: /lib64/libc.so.6: version 'GLIBC_2.32' not found (required by dpcmder)
dpcmder: /lib64/libc.so.6: version 'GLIBC_2.34' not found (required by dpcmder)
```

See:
- golang/go#58550
razo7 added a commit to razo7/self-node-remediation that referenced this issue May 24, 2023
When Golang is 1.20 and hosted OS in CI is Ubuntu-22.04, then we need to set CGO_ENABLED to zero, golang/go#58550, for the controller-gen binary
razo7 added a commit to razo7/self-node-remediation that referenced this issue May 24, 2023
When Golang is 1.20 and hosted OS in CI is Ubuntu-22.04, then we need to set CGO_ENABLED to zero, golang/go#58550, for the controller-gen binary
thomastaylor312 pushed a commit to cosmonic-labs/netreap that referenced this issue Aug 2, 2023
* Disable cgo

As part of the Go 1.20 release it seems like the default for `CGO_ENABLED` is no longer carried over from the tools. This leads to linking issues on systems that use different versions of glibc from what the base image uses. See golang/go#58550 for more details.

This change should fix #16

* Slim down the final image.

Use `scratch` as a base image since we're generating a static binary
anyway. Also be more explicity about the platform and target OS during
the build.

* Refactor endpoint handling and reconcilliation.

DRAFT

With the release of Nomad 1.6 it's possible to get the network address
of the allocation from Nomad. The change to enable this is only in the
client library and does not require updating the Nomad server. The IP
was sent back by older Nomad versions, it just wasn't available in the
client.

This enables refactoring the endpoint reconcilliation to make use of the
IP address to identify the endpoint within Cilium.

There is no longer a dependency on Consul for policies.

Additional, endpoints are now labelled with the task group and task
information as services can be created at those levels.

* Tidy

* Update the readme and add some basic tests.

Remove unused flags from the readme and command line and refactor the
code to allow for testing.

* Slightly better logging of labels

* Always update labels on reconcile.

* Fixes and align with upstream Dockerfile

* Missed one

* Reduce Dockerfile diff further

* Restore periodic reconcilliation of endpoints

* Remove stray return
michal-kopczynski added a commit to michal-kopczynski/kubectl-curl that referenced this issue Nov 1, 2023
benmcclelland added a commit to versity/versitygw that referenced this issue Dec 1, 2023
We were getting the following error on el7:
$ ./versitygw -h
./versitygw: /lib64/libc.so.6: version `GLIBC_2.32' not found (required by ./versitygw)
./versitygw: /lib64/libc.so.6: version `GLIBC_2.34' not found (required by ./versitygw)

The temporary fix is to disable cgo in the builds per this issue:
golang/go#58550

We will need to visit per distro builds once we need to re-enable
cgo.
@lunicon
Copy link

lunicon commented Dec 26, 2023

Try to use bullseye official docker image like golang:1.21-bullseye
It user glib 2.31

jbrodriguez added a commit to jbrodriguez/unbalance that referenced this issue Jan 26, 2024
jbrodriguez added a commit to jbrodriguez/unbalance that referenced this issue Jan 26, 2024
frittentheke added a commit to frittentheke/openstack-exporter that referenced this issue Feb 27, 2024
niedbalski pushed a commit to openstack-exporter/openstack-exporter that referenced this issue Mar 7, 2024
@Tectract

This comment was marked as off-topic.

@golang golang locked as resolved and limited conversation to collaborators Mar 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

9 participants