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

disable use of cgo only for the ci builds #182

Merged
merged 3 commits into from
Mar 14, 2018

Conversation

sameersbn
Copy link
Contributor

If you set CGO_ENABLED=0, the go tool has to rebuild all the standard lib packages at $GOROOT.
GOROOT may be a system path on the developer host and thus would require dev's to execute make as a
privileged user.

This PR re-enables the use of cgo by default, while disabling it in CI builds

Makefile Outdated
@@ -12,7 +13,7 @@ EMBEDDED_STATIC = generated/statik/statik.go
default: kubeapps

kubeapps: $(EMBEDDED_STATIC)
CGO_ENABLED=0 $(GO) build -i -o $(BINARY) $(GO_FLAGS) $(IMPORT_PATH)
CGO_ENABLED=$(CGO_ENABLED) $(GO) build -i -o $(BINARY) $(GO_FLAGS) $(IMPORT_PATH)
Copy link
Contributor

Choose a reason for hiding this comment

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

is this needed? wouldn't it already be in the env?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it does not exist in the env in the default case.

Copy link
Contributor

Choose a reason for hiding this comment

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

right, but the default is CGO_ENABLED=1 right? if you ran go build without the env var, it shouldn't try to install anything?

Copy link
Contributor Author

@sameersbn sameersbn Mar 14, 2018

Choose a reason for hiding this comment

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

from https://golang.org/cmd/cgo/

The cgo tool is enabled by default for native builds on systems where it is expected to work. It is disabled by default when cross-compiling.

So yes, I believe we can remove it like you pointed out.

from https://golang.org/cmd/cgo/

> The cgo tool is enabled by default for native builds on systems where
> it is expected to work. It is disabled by default when
> cross-compiling.
Copy link
Contributor

@prydonius prydonius left a comment

Choose a reason for hiding this comment

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

lgtm - and confirmed in travis logs from go env output that CGO_ENABLED=0.

@prydonius prydonius merged commit 2316779 into vmware-tanzu:master Mar 14, 2018
@sameersbn sameersbn deleted the cgo-enabled branch March 14, 2018 09:23
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.

2 participants