Skip to content

fix: statically linked binary (CGO_ENABLED=0)#234

Merged
kian99 merged 1 commit into
canonical:masterfrom
troyanov:no-cgo
Apr 29, 2026
Merged

fix: statically linked binary (CGO_ENABLED=0)#234
kian99 merged 1 commit into
canonical:masterfrom
troyanov:no-cgo

Conversation

@troyanov
Copy link
Copy Markdown
Member

Resolves: #233

Copy link
Copy Markdown
Contributor

@kian99 kian99 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've taken a look at the dependencies and we don't rely on any libraries that require cgo so I expect this change is safe and is a good idea.

Copy link
Copy Markdown

@SimoneDutto SimoneDutto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

searching around how to find out if your packages use CGO, people were suggesting that just building successfully the package with CGO doesn't give the certainty it will not error out at runtime.
The command suggested to inspect the packages to look for cgo dependency is:

go list -f "{{if .CgoFiles}}{{.ImportPath}}{{end}}" $(go list -f "{{.ImportPath}}{{range .Deps}} {{.}}{{end}}")

The output of that is:

net
os/user
runtime/cgo

so it might be not-safe to do this, but i'm not an expert on CGO

@kian99
Copy link
Copy Markdown
Contributor

kian99 commented Apr 29, 2026

searching around how to find out if your packages use CGO, people were suggesting that just building successfully the package with CGO doesn't give the certainty it will not error out at runtime. The command suggested to inspect the packages to look for cgo dependency is:

go list -f "{{if .CgoFiles}}{{.ImportPath}}{{end}}" $(go list -f "{{.ImportPath}}{{range .Deps}} {{.}}{{end}}")

The output of that is:

net
os/user
runtime/cgo

so it might be not-safe to do this, but i'm not an expert on CGO

Those packages are well-known ones in the standard library that can use cgo if it's enabled. The net one for example is mostly around the use of the DNS resolver. There are some niche use cases where the pure Go implementation might cause an issue over the glibc implementation but the uses of cgo in net and os/user are well understood (check the source or Google) and only effect niche scenarios.

@SimoneDutto
Copy link
Copy Markdown

searching around how to find out if your packages use CGO, people were suggesting that just building successfully the package with CGO doesn't give the certainty it will not error out at runtime. The command suggested to inspect the packages to look for cgo dependency is:

go list -f "{{if .CgoFiles}}{{.ImportPath}}{{end}}" $(go list -f "{{.ImportPath}}{{range .Deps}} {{.}}{{end}}")

The output of that is:

net
os/user
runtime/cgo

so it might be not-safe to do this, but i'm not an expert on CGO

Those packages are well-known ones in the standard library that can use cgo if it's enabled. The net one for example is mostly around the use of the DNS resolver. There are some niche use cases where the pure Go implementation might cause an issue over the glibc implementation but the uses of cgo in net and os/user are well understood (check the source or Google) and only effect niche scenarios.

Ah ok, nice!

@kian99
Copy link
Copy Markdown
Contributor

kian99 commented Apr 29, 2026

@troyanov Can you please sign your commit?

Resolves: canonical#233
Signed-off-by: Anton Troyanov <anton.troyanov@canonical.com>
@troyanov
Copy link
Copy Markdown
Member Author

@troyanov Can you please sign your commit?

Sure. Should be signed now.

@kian99 kian99 merged commit 4552942 into canonical:master Apr 29, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Candid binary is linked against GLIBC from the host

3 participants