diff options
author | Maciek Borzecki | 2018-04-18 10:14:09 +0200 |
---|---|---|
committer | Maciek Borzecki | 2018-04-18 10:16:20 +0200 |
commit | 5b0a5c57f66df6cd9f5e3eddbbbe6a63825965e8 (patch) | |
tree | 803850e5fdd13b5ff17051160726cb9f5d3924f4 | |
parent | bfedfe231208a3daadb127320fbcc2ab6495757c (diff) | |
download | aur-5b0a5c57f66df6cd9f5e3eddbbbe6a63825965e8.tar.gz |
snapd: switch to building with go instead of go-pie
Building statically linked PIE binaries appears to be broken in both Go upstream
and Arch packages. The toolchain ignores CGO_ENABLED=0, does not fail when
building and produces dynamically linked binaries. The output looks like this:
$ CGO_ENABLED=0 go build -o snap-exec github.com/snapcore/snapd/cmd/snap-exec
# github.com/snapcore/snapd/cmd/snap-exec
loadinternal: cannot find runtime/cgo
Since snap-exec *must* be built statically, switch to building with regular Go
toolchain. Tweak static build command, instead of disabling cgo, leave it
enabled and pass -static to ld.
Signed-off-by: Maciek Borzecki <maciek.borzecki@gmail.com>
-rw-r--r-- | .SRCINFO | 2 | ||||
-rw-r--r-- | PKGBUILD | 9 |
2 files changed, 6 insertions, 5 deletions
@@ -7,7 +7,7 @@ pkgbase = snapd-git arch = x86_64 license = GPL3 makedepends = git - makedepends = go-pie + makedepends = go makedepends = go-tools makedepends = libseccomp makedepends = libcap @@ -12,7 +12,7 @@ pkgrel=1 arch=('x86_64') url="https://github.com/snapcore/snapd" license=('GPL3') -makedepends=('git' 'go-pie' 'go-tools' 'libseccomp' 'libcap' 'systemd' 'xfsprogs' 'python-docutils') +makedepends=('git' 'go' 'go-tools' 'libseccomp' 'libcap' 'systemd' 'xfsprogs' 'python-docutils') # the following checkdepends are only required for static checks and unit tests, # both are currently disabled # checkdepends=('python' 'squashfs-tools' 'indent' 'shellcheck') @@ -63,15 +63,16 @@ build() { cd "$GOPATH/src/${_gourl}" XDG_CONFIG_HOME="$srcdir" ./get-deps.sh - gobuild="go build -x -v" + gobuild="go build -x -v -buildmode=pie" + gobuild_static="go build -x -v -buildmode=pie -ldflags=-extldflags=-static" # Build/install snap and snapd $gobuild -o $GOPATH/bin/snap "${_gourl}/cmd/snap" $gobuild -o $GOPATH/bin/snapctl "${_gourl}/cmd/snapctl" $gobuild -o $GOPATH/bin/snapd "${_gourl}/cmd/snapd" $gobuild -o $GOPATH/bin/snap-seccomp "${_gourl}/cmd/snap-seccomp" # build snap-exec and snap-update-ns completely static for base snaps - $gobuild -o $GOPATH/bin/snap-update-ns -ldflags '-extldflags "-static"' "${_gourl}/cmd/snap-update-ns" - CGO_ENABLED=0 $gobuild -o $GOPATH/bin/snap-exec "${_gourl}/cmd/snap-exec" + $gobuild_static -o $GOPATH/bin/snap-update-ns "${_gourl}/cmd/snap-update-ns" + $gobuild_static -o $GOPATH/bin/snap-exec "${_gourl}/cmd/snap-exec" # Generate data files such as real systemd units, dbus service, environment # setup helpers out of the available templates |