testing/lxd: lxd-agent and lxd-p2c need to be statically linked
Hi,
The two binaries compiled with testing/lxd need to be statically linked according to upstream. The reason is because these two binaries are copied across 9p into the virtual machines when they're initialized.
These virtual machines may not have musl, and as a result lxd-agent refuses to start inside of them. Leading to all sorts of fun, such as not being able to change a password, or login via lxc exec
.
I've had a bit of a look at Statically compiled Go programs, always, even with cgo, using musl and this example https://github.com/twpayne/chezmoi/commit/cfa3fd2674bc7cd74cbf506f52ebe15723365133 but still seem to be getting some issues (https://gitlab.alpinelinux.org/dngray/aports/-/commit/aa8f20d33cfcbcab2f5c64e5bbc020aae57a022d):
# _/home/dngray/lxd/src/lxd-4.7/lxd-p2c
/usr/lib/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lintl
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lintl
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lintl
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lintl
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lintl
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lintl
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lintl
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lintl
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lacl
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lintl
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lsqlite3
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -lraft
/usr/lib/gcc/x86_64-alpine-linux-musl/9.3.0/../../../../x86_64-alpine-linux-musl/bin/ld: cannot find -ldqlite
collect2: error: ld returned 1 exit status
If someone familiar with Go, and packaging on Alpine Linux, could give me some tips that would be much appreciated.