← Back to issue list

go plugin with snapcraft 4 doesn't support building static binaries

View original Launchpad issue

Metadata

Project
snapcraft (launchpad)
Number
#1884558
Type
issue
State
closed
Author
~anonymouse67
Labels
—
Created
Updated
Closed

Current evaluation

Closed as stale after more than six years; a maintainer noted that the Go plugin had changed substantially since Snapcraft 4, with no targeted fix cited.

Resolution: closed stale

Reason: Maintainer ~mr-cal explicitly closed the report as stale because the Go plugin had changed considerably since Snapcraft 4. No resolving pull request or commit was identified.

Evaluated by: mr-cal-bot

No scores available.

Issue body

I have a go program which does not require any dynamic library dependencies, and as such I would like to link it statically and use the `base: base` for this snap, so I have tried this: ``` parts:   etrace:     build-environment:       - CGO_ENABLED: "0"     plugin: go     source: . ``` but it still produces a dynamically linked executable against libc, because snapcraft internally does this command always: ``` Building etrace go build -o /root/parts/etrace/install/bin ./... go build -ldflags -linkmode=external -o /root/parts/etrace/install/bin ./... # github.com/anonymouse64/etrace/cmd/etrace loadinternal: cannot find runtime/cgo ``` which completes, but gives me this: ``` $ ldd ./squashfs-root/bin/etrace         linux-vdso.so.1 (0x00007ffd91f77000)         libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3d02414000)         /lib64/ld-linux-x86-64.so.2 (0x00007f3d02624000) ``` which I can't use with the bare base snap. What works instead is to do this manually: ```     override-build: |       mkdir -p $SNAPCRAFT_PART_INSTALL/bin       cd $SNAPCRAFT_PART_SRC       go build -o $SNAPCRAFT_PART_INSTALL/bin ./... ``` It would be nice if snapcraft either: 1. automatically detected that CGO_ENABLED=0 was set in the build-environment and didn't manually link things 2. automatically detected that the built binaries from go build -o ./bin ./... were not dynamically linked at all and skipped the final link step 3. had a property or otherwise first-class mechanism to specify that a go part built with the go plugin should be statically compiled (perhaps an option to the plugin yaml, etc.), this could also potentially replace setting the build-environment for CGO_ENABLED=0 as well snapcraft, version 4.0.5

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha — closed stale Closed as stale after more than six years; a maintainer noted that the Go plugin had changed substantially since Snapcraft 4, with no targeted fix cited.
stealth/space-bunny-alpha — closed stale Closed as stale because the Go plugin had changed substantially since Snapcraft 4; no resolving PR or commit was cited.
qwen/qwen3.6-35b-a3b — — Closed as stale. The Go plugin has significantly changed since Snapcraft 4, rendering the report obsolete. Users should upgrade to a newer Snapcraft version for updated build behavior.
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 35
Confidence: 90
Support Request: 10
close stale Go plugin in Snapcraft 4 forces dynamic linking despite CGO_ENABLED=0, blocking static builds for bare base snaps. Issue is 6 years old, has zero maintainer interaction, and references a long-obsolete version.
qwen/qwen3.6-35b-a3b
Staleness: 95
Complexity: 30
Confidence: 85
Support Request: 10
close stale Snapcraft 4 go plugin forces dynamic linking despite CGO_ENABLED=0, preventing static builds for bare base snaps. Issue is 6 years old with no maintainer response.
qwen3.6-35b-a3b-mtp-q6
Staleness: 98
Complexity: 35
Confidence: 85
Support Request: 20
close stale Snapcraft 4 Go plugin forces dynamic linking even with CGO_ENABLED=0, blocking static builds for bare bases. Report is six years old, completely untriaged, and lacks maintainer engagement.

Update history

Date Change
created

Related issues

Issue Project State Summary Similarity
#1748202 go plugin doesn't honor godeps file snapcraft (launchpad) closed Closed after a maintainer explained that Snapcraft's dedicated godeps plugin must be used; the go plugin does not consume versions from a Godeps file.
73%
#1696149 Can't build go projects since 5th June snapcraft (launchpad) closed Closed as stale after 60 days of inactivity. A Go dependency required Go 1.7, and a project-specific recipe using the go1.7.5 snap provided a workaround; no Snapcraft fix was linked.
72%
#772 Set GOBIN in go plugin build environment. snapcraft closed Closed stale after inactivity; the same Go-plugin GOBIN fix was later merged in canonical/snapcraft#859 via commit e44e634f6.
72%
#1751 the go plugin doesn't use go build-snaps snapcraft closed Fixed in canonical/snapcraft#2194 (commit 12d9151d3): the Go plugin now skips legacy golang-go DEBs when a Go build snap is configured.
72%
#1609623 go plugin has no build tags snapcraft (launchpad) closed Added Go build-tag support via the go-buildtags property in snapcraft PR #733 (commit 59d4acf8a), later refined by PR #888.
71%