"loadinternal: cannot find runtime/cgo" with base: core20, go.mod but no cgo in code
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Snapcraft |
New
|
Undecided
|
Chris Patterson |
Bug Description
Following https:/
base: core20
parts:
foo:
plugin: go
go-channel: 1.13/stable
source: .
source-type: git
stage-packages:
- gcc
build-
- CGO_ENABLED: "0" # didn't help
Then building I get:
$ snapcraft
...
Pulling foo
Cloning into '/root/
done.
Building foo
+ go mod download
+ go install -p 2 -ldflags -linkmode=external ./...
# github.
loadinternal: cannot find runtime/cgo
/snap/go/
/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-
- 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.
Changed in snapcraft: | |
assignee: | nobody → Chris Patterson (cjp256) |
I was not able to reproduce. Can you share a full example? I tried with https:/ /github. com/snapcore/ snapcraft/ tree/master/ tests/spread/ plugins/ v2/snaps/ go-mod- hello and a modified snapcraft.yaml to mirror what you're using:
name: go-mod-hello
version: "1.0"
summary: A simple go project using go.mod
description: |
This is a basic go snap. It just prints a hello world brought in from
a version pinned go package using go.mod.
grade: devel
base: core20
confinement: strict
apps:
go-mod-hello:
command: bin/go-mod-hello
parts: environment:
hello:
source: .
plugin: go
go-channel: 1.13/stable
stage-packages:
- gcc
build-
- CGO_ENABLED: "0"