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

net/http: compiled binary on Debian 12(bookworm) cannot run on Debian 11(bullseye) #60937

Closed
marjune163 opened this issue Jun 22, 2023 · 2 comments

Comments

@marjune163
Copy link

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

$ go version
go version go1.20.5 linux/amd64

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="/home/marjune/.cache/go-build"
GOENV="/home/marjune/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/marjune/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/marjune/go"
GOPRIVATE=""
GOPROXY="https://goproxy.cn,direct"
GOROOT="/opt/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/opt/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20.5"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
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 -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1850243235=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 12 (bookworm)
Release:        12
Codename:       bookworm
$ uname -a
Linux host7 6.1.0-9-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.27-1 (2023-05-08) x86_64 GNU/Linux
$ cat test.go
package main

import (
        "fmt"
        "net/http"
)

func main() {
        fmt.Println(http.ListenAndServe)
}

$ go version
go version go1.20.5 linux/amd64

$ go build -o test test.go

$ ./test
0x60f7a0

Then copy this built binary test to a Debian 11 system and run:

$ lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 11 (bullseye)
Release:        11
Codename:       bullseye
uname -a
Linux debian 5.10.0-20-amd64 #1 SMP Debian 5.10.158-2 (2022-12-13) x86_64 GNU/Linux
$ ./test
./test: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by ./test)
./test: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./test)

What did you expect to see?

Run test program without issue and print out the address of http.ListenAndServe.

What did you see instead?

./test: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by ./test)
./test: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by ./test)
@marjune163
Copy link
Author

I also tried copy this test binary to CentOS Stream release 8, got the same issue.

@marjune163 marjune163 changed the title affected/package: net/http compiled binary on Debian 12(bookworm) cannot run on Debian 11(bullseye) net/http: compiled binary on Debian 12(bookworm) cannot run on Debian 11(bullseye) Jun 22, 2023
@mpx
Copy link
Contributor

mpx commented Jun 22, 2023

This is working as intended. By default Go links with C. Older versions of Debian (and Glibc) typically don't support binaries linked against newer versions.

It should work if you avoid the C dependency with CGO_ENABLED=0 go build.

Go+CGO binaries should always be linked against the oldest platform you intend to support since later versions are typically backwards compatible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants