Snapd snap build failure

I am trying to build the snapd snap. It is based on 2.49.1 but has been changed to use Go modules, 1.16 and a few other miscellaneous things to get there.

Building the binaries snap, snapd, etc. are working fine. It’s just the debian package inside the snapcraft build that is failing.

Is there anything definitive in here that’s helpful? Thanks!

# ensure we generated a static build
# ensure snap-seccomp is build with a static libseccomp on Ubuntu
sed -i "s|#cgo LDFLAGS:|#cgo LDFLAGS: /usr/lib/x86_64-linux-gnu/libseccomp.a|" _build/src/github.com/snapcore/snapd/cmd/snap-seccomp/main.go
(cd _build/bin && GOPATH=$(pwd)/..  GOCACHE=/tmp/go-build CGO_LDFLAGS_ALLOW="/.*/libseccomp.a" go build  github.com/snapcore/snapd/cmd/snap-seccomp)
# ensure that libseccomp is not dynamically linked
ldd _build/bin/snap-seccomp
	linux-vdso.so.1 =>  (0x00007ffccb55a000)
	libseccomp.so.2 => /lib/x86_64-linux-gnu/libseccomp.so.2 (0x00007f540f612000)
	libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f540f3f5000)
	libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f540f02b000)
	/lib64/ld-linux-x86-64.so.2 (0x00007f540f85e000)
test "$(ldd _build/bin/snap-seccomp | grep libseccomp)" = ""
debian/rules:166: recipe for target 'override_dh_auto_build' failed
make[1]: *** [override_dh_auto_build] Error 1
make[1]: Leaving directory '/root/parts/snapd-deb/build'
debian/rules:109: recipe for target 'build' failed
make: *** [build] Error 2
dpkg-buildpackage: error: debian/rules build gave error exit status 2

If it’s helpful the host is:

NAME="Ubuntu"
VERSION="20.04.2 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.2 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal

Out of curiosity, why are you trying to build the snapd snap with a newer version of Go and using modules?

Also the issue is that your build is generating a dynamically linked snap-seccomp. I think that you need to change the build flags for Go 1.16 to get a static binary, I seem to recall reading about some kind of change in the flags around that for Got 1.16.

1 Like

Well more or less I’m trying to learn snapd. I also really dislike Go when it required GOPATH and external dependency management (I lived it for a couple of years). As well as, to me, 1.10 is quite old now and there was a feature in 1.16 I wanted to test with snapd.

I was able to build snapd fine, by itself, that’s no issue. It was just the snap build that was failing.

Thanks for the tip, I’ll give it a look!

1 Like

Also, to reiterate (as I’ve said on other threads) I’m quite impressed by the quality of the snapd code, its level of testing, etc.

I have a job so I know how things like using the latest version of X depends a lot of the time on having a real need (or forced requirement) before you are able to justify doing so. So it’s not a criticism of snapd.

But, as it happens in this capacity for me this is for fun. So that’s what I wanted to do. :slight_smile:

1 Like