lxc / distrobuilder

System container image builder for LXC and Incus
https://linuxcontainers.org
Apache License 2.0
549 stars 163 forks source link

Building distrobuilder 3.0 fails (undefined: cmdGlobal) with go 1.21.5 and 1.20.12 #803

Closed ckoe closed 6 months ago

ckoe commented 6 months ago

Build process is running on a Allwinner BananaPi Pro (arm7i), native Debian bookworm (SMP Debian 6.1.67-1 (2023-12-12) armv7l GNU/Linux). I get following error when calling 'make' for distrobuilder-3.0:

distrobuilder/main_build-dir.go:16:12: undefined: cmdGlobal
distrobuilder/main_incus.go:27:12: undefined: cmdGlobal
distrobuilder/main_incus.go:45:4: undefined: typeDescription
distrobuilder/main_incus.go:45:21: undefined: compressionDescription
distrobuilder/main_incus.go:113:4: undefined: typeDescription
distrobuilder/main_incus.go:113:21: undefined: compressionDescription
distrobuilder/main_incus.go:396:8: undefined: addSystemdGenerator
distrobuilder/main_lxc.go:19:12: undefined: cmdGlobal
distrobuilder/main_repack-windows.go:28:10: undefined: cmdGlobal
distrobuilder/main_validate.go:11:15: undefined: cmdGlobal
distrobuilder/main_incus.go:396:8: too many errors

Steps to reproduce: Installed go 1.21.5

$ wget -P ~ https://go.dev/dl/go1.21.5.linux-armv6l.tar.gz
# rm -rf /usr/local/go && tar -C /usr/local -xzf ~/go1.21.5.linux-armv6l.tar.gz
$ /usr/local/go/bin/go version
go version go1.21.5 linux/arm

Installed Debian packages: # apt update && apt install -y debootstrap rsync gpg squashfs-tools git make

Downloaded and unpacked stable tarball for 3.0, called 'make' Build process runs for several minutes, fails only building github.com/lxc/distrobuilder/distrobuilder, with the error above.

I have also tried:

I have invoked go install -x -v ./... directly, to get more details on what is happening It seems that ./distrobuilder/main.go is not included in the executed complile commando line:

WORK=/tmp/go-build3361130780
github.com/lxc/distrobuilder/distrobuilder
mkdir -p $WORK/b001/
cat >/tmp/go-build3361130780/b001/importcfg << 'EOF' # internal
# import config
packagefile bufio=/home/xxx/.cache/go-build/60/60da140b1d580258ad2e6986e237447b1edbddf16294caa1938b86e27bcb9204-d
(...)
packagefile math=/home/xxx/.cache/go-build/2c/2c7f2a48bc171a2f8bb478d36ae818d5fc5b11ac01a2a2f68f512e332f427d5f-d
EOF
cd /home/xxx/distrobuilder-3.0
/usr/local/go/pkg/tool/linux_arm/compile -o $WORK/b001/_pkg_.a -trimpath "$WORK/b001=>" -p main -lang=go1.18 -complete -buildid rK7FDw1ngGmed-b4RSeS/rK7FDw1ngGmed-b4RSeS -goversion go1.21.5 -c=2 -nolocalimports -importcfg $WORK/b001/importcfg -pack ./distrobuilder/chroot.go ./distrobuilder/main_build-dir.go ./distrobuilder/main_incus.go ./distrobuilder/main_lxc.go ./distrobuilder/main_repack-windows.go ./distrobuilder/main_validate.go ./distrobuilder/vm.go
# github.com/lxc/distrobuilder/distrobuilder
distrobuilder/main_build-dir.go:16:12: undefined: cmdGlobal
(...)
distrobuilder/main_incus.go:396:8: too many errors

Any hint? I am sadly no 'go' nerd, but I want to build my own armhf lxc debian images, since armhf support on lxc-ci was dropped.

stgraber commented 6 months ago

Could be that your system isn't capable of building cgo code?

Make sure you have build-essential or similar installed on your system to have a C compiler and C library installed.

ckoe commented 6 months ago

Yes, the packages were missing. For other fools like me: If you use a fresh minimal install and get go directly from upstream without using apt install golang-go -- do not forget to setup your development environment yourself, apt does not do the magic for you.

spiritLHLS commented 5 months ago

Yes, the packages were missing. For other fools like me: If you use a fresh minimal install and get go directly from upstream without using apt install golang-go -- do not forget to setup your development environment yourself, apt does not do the magic for you.

I'm having the same problem, am I missing something? What do you mean by missing personal development environment? (Forgive me for being a newbie and not knowing anything about GO)