"loadinternal: cannot find runtime/cgo" with base: core20, go.mod but no cgo in code
Metadata
Current evaluation
Core20 Go plugin builds with CGO_ENABLED=0 still invoke external linking and fail; removing the plugin-added -linkmode=external succeeds, but no root cause or fix is recorded.
Suggested action: keep open
Reason: The reporter supplied lp1883265.tar.gz, exact linker errors, and a controlled override showing that `go install -p 2 ./...` succeeds without the plugin-generated `-ldflags -linkmode=external`, isolating a likely plugin defect. Maintainers tested a fixture and requested a full example, but no diagnosis, fix, or resolution followed.
Evaluated by: mr-cal-bot
Impact:
38
Quick Win:
20
Complexity:
42
Confidence:
86
Actionability:
90
Issue body
Following https://snapcraft.io/docs/go-plugin, with a hello-world type application using golang 1.13, go.mod, base: core20, but with no cgo, using this:
base: core20
parts:
foo:
plugin: go
go-channel: 1.13/stable
source: .
source-type: git
stage-packages:
- gcc
build-environment:
- CGO_ENABLED: "0" # didn't help
Then building I get:
$ snapcraft
...
Pulling foo
Cloning into '/root/parts/foo/src'...
done.
Building foo
+ go mod download
+ go install -p 2 -ldflags -linkmode=external ./...
# github.com/canonical/foo/cmd/foo
loadinternal: cannot find runtime/cgo
/snap/go/5828/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: cannot find Scrt1.o: No such file or directory
/usr/bin/ld: cannot find crti.o: No such file or directory
collect2: error: ld returned 1 exit status
Failed to build 'foo'.
Recommended resolution:
Check the build logs and ensure the part's configuration and sources are correct.
Run the same command again with --debug to shell into the environment if you wish to introspect this failure.
[2]
I tried staging different things like build-essential and libc6-dev which gave different, but failing output always related to ld.
What did work was:
base: core20
parts:
foo:
plugin: go
go-channel: 1.13/stable
source: .
source-type: git
build-environment:
- CGO_ENABLED: "0" # may not be required
override-build: |
go install -p 2 ./...
(note I was able to drop stage-packages too).
I wonder if it makes sense that if CGO_ENABLED=0, you drop -ldflags -linkmode=external? At the very least there seems to be a documentation opportunity.
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha |
Impact:
38
Quick Win:
20
Complexity:
42
Confidence:
86
Actionability:
90
|
keep open | Core20 Go plugin builds with CGO_ENABLED=0 still invoke external linking and fail; removing the plugin-added -linkmode=external succeeds, but no root cause or fix is recorded. | |
| stealth/space-bunny-alpha |
Impact:
45
Quick Win:
33
Complexity:
18
Confidence:
96
Actionability:
90
|
close resolved | Go plugin forced external linking for a pure-Go CGO_ENABLED=0 build; bbc76d92 removed that behavior, and the current plugin runs go install without the flag. | |
| stealth/space-bunny-alpha |
Impact:
42
Quick Win:
29
Complexity:
24
Confidence:
87
Actionability:
92
|
close resolved | The Go plugin forced external linking despite CGO_ENABLED=0, breaking pure-Go core20 builds. Commit bbc76d92 later added pure-Go builds, and current plugin code no longer forces those linker flags. | |
| qwen/qwen3.8-27b |
Impact:
40
Quick Win:
28
Staleness:
90
Complexity:
30
Confidence:
70
Support Request:
20
|
needs triage | Go plugin build fails on core20 with CGO_ENABLED=0 because the plugin passes -ldflags -linkmode=external, causing ld to look for cgo runtime objects. No maintainer response; reporter found override-build workaround and suggested dropping linkmode when CGO is disabled. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
95
Complexity:
40
Confidence:
75
Support Request:
10
|
close stale | Snapcraft go plugin fails building with core20 base and CGO_ENABLED=0 due to linker errors. No maintainer response or labels. Suggests adjusting ldflags or updating docs. | |
| qwen/qwen3.6-35b-a3b |
Staleness:
95
Complexity:
45
Confidence:
85
Support Request:
15
|
close stale | Untriaged bug report regarding Snapcraft's Go plugin failing to link when using core20 base and Go 1.13. Author provided a workaround and suggested plugin behavior changes. No maintainer response in over 5 years. | |
| qwen3.6-35b-a3b-mtp-q6 |
Staleness:
95
Complexity:
15
Confidence:
85
Support Request:
20
|
close stale | Unlabelled report about Snapcraft Go plugin linker failures with core20 base and CGO_ENABLED=0. Author provided a workaround and suggested dropping -linkmode=external or updating docs. No maintainer response in over 5 years. |
Update history
| Date | Change |
|---|---|
| created |
Related issues
No related issues found above the similarity threshold.