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

fix(build): instruct users to use GOTAGS, not GOFLAGS #6843

Merged
merged 2 commits into from Jan 28, 2020

Conversation

Stebalien
Copy link
Member

GOFLAGS will override all the flags. If we just want to set a tag e.g., enable OpenSSL, we should set GOTAGS=openssl.

fixes #6622 (comment)

GOFLAGS will _override_ all the flags. If we just want to set a tag e.g., enable
OpenSSL, we should set GOTAGS=openssl.

fixes #6622 (comment)
@olizilla
Copy link
Member

I wasn't clear on the source of the issue, so I did some digging... and it seems some make lore has been invoked...

If a variable has been set with a command argument (see Overriding Variables), then ordinary assignments in the makefile are ignored.
https://www.gnu.org/software/make/manual/html_node/Override-Directive.html#Override-Directive

so when we

$ make -n build GOFLAGS=-tags=openssl

...The append has no affect, as GOFLAGS was already defined.

https://github.com/ipfs/go-ipfs/blob/37884530221654fe57870db31ec7a178963b633e/mk/golang.mk#L9-L14

so the use of += here is misleading, as you pointed out.

To save us from future misreadings, either GOFLAGS should append, in which case we want to specify override, or we should assign the default value for GOFLAGS as part of the ?= statement...

Appending with override

# Try to make building as reproducible as possible by stripping the go path.
override GOFLAGS += "-asmflags=all='-trimpath=$(GOPATH)'" "-gcflags=all='-trimpath=$(GOPATH)'"
$(warning $(GOFLAGS))

usage:

$ make -n build GOFLAGS=-tags=openssl
mk/golang.mk:15: -tags=openssl "-asmflags=all='-trimpath=/Users/oli/Code/go'" "-gcflags=all='-trimpath=/Users/oli/Code/go'"

$ make -n build
mk/golang.mk:15:  "-asmflags=all='-trimpath=/Users/oli/Code/go'" "-gcflags=all='-trimpath=/Users/oli/Code/go'"

No appending, just a default value

# Try to make building as reproducible as possible by stripping the go path.
GOFLAGS ?= "-asmflags=all='-trimpath=$(GOPATH)'" "-gcflags=all='-trimpath=$(GOPATH)'"
unexport GOFLAGS
$(warning $(GOFLAGS))

usage

$ make -n build GOFLAGS=-tags=openssl
mk/golang.mk:13: -tags=openssl

$ make -n build
mk/golang.mk:13: "-asmflags=all='-trimpath=/Users/oli/Code/go'" "-gcflags=all='-trimpath=/Users/oli/Code/go'"

Copy link
Member

@olizilla olizilla left a comment

Choose a reason for hiding this comment

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

This change works as is, so is fine to merge, but I think we should fix the GOFLAGS definition as per #6843 (comment)

@Stebalien
Copy link
Member Author

Yeah, I'll go through the variables in a followup PR.

@Stebalien Stebalien merged commit e8f7f0a into master Jan 28, 2020
@Stebalien Stebalien deleted the fix/docker-tags branch January 28, 2020 15:13
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.

Docker built go-ipfs fails to report its commit version
2 participants