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/
(cd _build/bin && GOPATH=$(pwd)/..  GOCACHE=/tmp/go-build CGO_LDFLAGS_ALLOW="/.*/libseccomp.a" go build
# ensure that libseccomp is not dynamically linked
ldd _build/bin/snap-seccomp =>  (0x00007ffccb55a000) => /lib/x86_64-linux-gnu/ (0x00007f540f612000) => /lib/x86_64-linux-gnu/ (0x00007f540f3f5000) => /lib/x86_64-linux-gnu/ (0x00007f540f02b000)
	/lib64/ (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:

VERSION="20.04.2 LTS (Focal Fossa)"
PRETTY_NAME="Ubuntu 20.04.2 LTS"

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