Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid cgo dependencies #375

Closed
felixboehm opened this issue Jul 10, 2020 · 8 comments
Closed

Avoid cgo dependencies #375

felixboehm opened this issue Jul 10, 2020 · 8 comments

Comments

@felixboehm
Copy link
Contributor

following https://ops.tips/notes/glibc-golang-learnings/#how-can-i-see-what-requires-cgo
I see these cgo dependencies for ocis:

crypto/x509
github.com/mattn/go-sqlite3
os/user
plugin
runtime/cgo

Ideas howto remove those?

@IljaN
Copy link
Contributor

IljaN commented Jul 12, 2020

os/user dependency could be potentially removed by cs3org/reva#964

@IljaN
Copy link
Contributor

IljaN commented Jul 12, 2020

From https://golang.org/doc/go1.11

The os/user package can now be built in pure Go mode using the build tag "osusergo", independent of the use of the environment variable CGO_ENABLED=0. Previously the only way to use the package's pure Go implementation was to disable cgo support across the entire program.

@IljaN
Copy link
Contributor

IljaN commented Jul 13, 2020

After further research it seems that we can't get rid of cgo fully as the glibc is requried for LDAP-DNS queries and mDNS lookups via golang stdlib.

https://golang.org/pkg/net/#hdr-Name_Resolution

Generally all of cgo can be disabled by CGO_ENABLED=0 but any problems with linking will surface during runtime.

There are some very hacky workarounds which embed the dynamic lib in to the binary:
https://www.arp242.net/static-go.html
https://www.osso.nl/blog/golang-statically-linked/

@refs
Copy link
Member

refs commented Jan 12, 2021

todo: add tradeoffs from not using cgo

@stale
Copy link

stale bot commented Jun 6, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added Status:Stale and removed Status:Stale labels Jun 6, 2021
@refs
Copy link
Member

refs commented Jun 7, 2021

update: these are the current packages using CGo:

~/code/owncloud/ocis/ocis/cmd/ocis mastergo list -f "{{if .CgoFiles}}{{.ImportPath}}{{end}}" $(go list -f "{{.ImportPath}}{{range .Deps}} {{.}}{{end}}") ./...
github.com/mattn/go-sqlite3
net
os/user
plugin
runtime/cgo

@stale
Copy link

stale bot commented Aug 6, 2021

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 10 days if no further activity occurs. Thank you for your contributions.

@pascalwengerter
Copy link
Contributor

@refs could you check again and close if applicable?

@stale stale bot removed the Status:Stale label Aug 31, 2021
@refs refs closed this as completed Sep 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants