opencontainers / runc

CLI tool for spawning and running containers according to the OCI specification
https://www.opencontainers.org/
Apache License 2.0
11.78k stars 2.1k forks source link

let runc work with glibc lt 2.32 in go 1.22.x #4310

Closed lifubang closed 3 months ago

lifubang commented 3 months ago

For some libct users, it's hard to let them deal with the bug before go 1.22.4 with glibc version < 2.32, so let's do a hack to let runc can work for the entire go 1.22 versions.

kolyshkin commented 3 months ago

@lifubang have you checked it locally? It doesn't work for me:

[kir@kir-tp1 runc]$ GO=go1.22.3 make all
rm -f libcontainer/dmz/binary/runc-dmz
go1.22.3 generate -tags "seccomp urfave_cli_no_docs " ./libcontainer/dmz
make[1]: Entering directory '/home/kir/git/runc/libcontainer/dmz'
gcc -fno-asynchronous-unwind-tables -fno-ident -s -Os -nostdlib -lgcc -static -o binary/runc-dmz _dmz.c
strip -gs binary/runc-dmz
make[1]: Leaving directory '/home/kir/git/runc/libcontainer/dmz'
go1.22.3 build -trimpath "-buildmode=pie"  -tags "seccomp urfave_cli_no_docs " -ldflags "-X main.gitCommit=v1.2.0-rc.1-85-gbef89d46 -X main.version=1.2.0-rc.1+dev " -o runc .
# github.com/opencontainers/runc
/home/kir/sdk/go1.22.3/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /tmp/go-link-4194289539/000025.o: in function `x_cgo_getstackbound':
/_/GOROOT/src/runtime/cgo/gcc_stack_unix.c:25:(.text+0x1a): undefined reference to `__wrap_pthread_getattr_np'
collect2: error: ld returned 1 exit status

make: *** [Makefile:78: runc-bin] Error 1
lifubang commented 3 months ago

I checked it with glibc 2.31 in go 1.22.3, but didn't check glibc gt 2.31. Ah, I know what's wrong with this failure, I'll fix it soon. This is because #cgo LDFLAGS: -Wl,--wrap=pthread_getattr_np should not be in #if macro check, golang won't check this check.