Unable to build 1.0.1 with LTO
Hi! I am currently rebuilding cni-plugins as a package for Arch Linux. In the meantime we have switched to LTO by default (which can be switched off per package). Unfortunately this fails with cni-plugins:
Building plugins
bandwidth
# github.com/containernetworking/plugins/plugins/meta/bandwidth
_cgo_callers: relocation target x_cgo_callers not defined
_cgo_init: relocation target x_cgo_init not defined
_cgo_mmap: relocation target x_cgo_mmap not defined
_cgo_munmap: relocation target x_cgo_munmap not defined
_cgo_notify_runtime_init_done: relocation target x_cgo_notify_runtime_init_done not defined
_cgo_sigaction: relocation target x_cgo_sigaction not defined
_cgo_thread_start: relocation target x_cgo_thread_start not defined
runtime._cgo_setenv: relocation target x_cgo_setenv not defined
runtime._cgo_unsetenv: relocation target x_cgo_unsetenv not defined
runtime.cgo_yield: relocation target _cgo_yield not defined
.rela: relocation target _cgo_yield not defined
.rela: relocation target x_cgo_setenv not defined
.rela: relocation target x_cgo_unsetenv not defined
.rela: relocation target x_cgo_init not defined
.rela: relocation target x_cgo_thread_start not defined
.rela: relocation target x_cgo_notify_runtime_init_done not defined
.rela: relocation target x_cgo_callers not defined
.rela: relocation target x_cgo_mmap not defined
.rela: relocation target x_cgo_munmap not defined
.rela: relocation target x_cgo_sigaction not defined`
Full build log: cni-plugins-1.0.1-build.log
We are currently building the plugins as follows:
export GOFLAGS="-buildmode=pie -trimpath -mod=readonly -modcacherw"
export CGO_LDFLAGS="${LDFLAGS}"
export CGO_CFLAGS="${CFLAGS}"
export CGO_CPPFLAGS="${CPPFLAGS}"
export CGO_CXXFLAGS="${CXXFLAGS}"
./build_linux.sh
Here CFLAGS, CPPFLAGS, CXXFLAGS and LDFLAGS are our distribution wide build flags.
Is this intentional or a bug?
@dcbw this problem is still around with 1.2.0.
Using a stale bot to hide this problem is not really great, as it means that this is likely never going to be fixed and actively discourages people to even report bugs :cry:
Yeah, I suspect I need to tweak the stale bot's settings :-/. It's nice to have some old things cleaned out but it's too aggressive.
(FYI I added a "keep" label for things that shouldn't go stale).
@dvzrv none of us have enough go internals knowledge to fix this; do you know someone who could help out?
It seems to me with 1.3.0 enabling LTO builds just fine, so perhaps this can be closed?
In case you try it @dvzrv, perhaps you can also add -X github.com/containernetworking/plugins/pkg/utils/buildversion.BuildVersion=${pkgver}' flag, so binaries show version properly:
$ /opt/cni/bin/bandwidth -v
CNI bandwidth plugin version unknown
CNI protocol versions supported: 0.3.0, 0.3.1, 0.4.0, 1.0.0
Similar issue to https://github.com/microsoft/CBL-Mariner/issues/6339.