Created attachment 208543 [details] Patch to Makefile to set version information Updated the Makefile to set the version in the binary when the port is built. Using version information from the port Makefile.
Build info is available at https://gitlab.com/swills/freebsd-ports/pipelines/91089520
Created attachment 208544 [details] elvish-0.12_1.patch v1 This can be done without patching or gmake by setting GO_BUILDFLAGS in port Makefile. I'll commit the attached patch if you approve :)
(In reply to Dmitri Goutnik from comment #2) I'm all for going with the simpler/easier route, would using the GO_BUILDFLAG ensure that the other variables get set at build time? The "get" target in the Projects make file just does the following: go get -ldflags "-X github.com/elves/elvish/buildinfo.Version=$(VERSION) \ -X github.com/elves/elvish/buildinfo.GoRoot=$(shell go env GOROOT) \ -X github.com/elves/elvish/buildinfo.GoPath=$(shell go env GOPATH)" . So to ensure that the build info also gets set correctly wouldn't the GO_BUILDFLAG need to be updated to the whole value of the ldflags argument i.e. GO_BUILDFLAGS= -ldflags="-X github.com/elves/elvish/buildinfo.Version=${DISTVERSIONPREFIX}${DISTVERSION} -X ithub.com/elves/elvish/buildinfo.GoRoot=$(shell go env GOROOT) -X github.com/elves/elvish/buildinfo.GoPath=$(shell go env GOPATH)" To ensure that everything is set correctly? The main reason for wanting these set is if a user finds a bug/issue that should be reported upstream they may want/need this information in the upstream bug report. Example (output from another box so version info may be a bit different): [~]─> elvish -version 0.12.r530.ge2a3f2d8 [~]─> elvish -buildinfo Version: 0.12.r530.ge2a3f2d8 Go version: go1.13 GOROOT at build time: unknown GOPATH at build time: unknown Having the GOROOT and GOPATH at build time may be something the upstream devs may want/need in debugging an issue To me this feels like at that point we are recreating the projects "get" target in our Makefile. If this is what would be recommended then I'll be happy to reroll my patch and upload it here as i'm trying to learn this process and eran my "maintainer" status :)
I checked the sources and GoRoot/GoPath aren't used for anything except for printing back whatever was set with -ldflags. I'm at loss how knowing GOROOT/GOPATH would be useful for any debugging - the fact that executable was produced is an indicator that GOROOT/GOPATH were set to some reasonable values that worked. There's nothing else in the Makefile and buildall.sh that would be useful for building the port, quite the contrary, using it would make porting harder and bringing in gmake dependency just to build one simple target seems superfluous.
I only brought it up, as I'm sure the project had some reason why the would have variables and the '-buildinfo' flag. I was just trying to keep this build as close to how the upstream would would be following their make target. Like you I'm not sure what there reasoning is, I might reach out to the upstream devs and ask them. It works just fine without it just spits out "unknown" like in the example in my previous comment. I'll reroll my patch without the build dependency on `gmake` and just set everything in the GO_BUILDFLAG variable.
(In reply to Adam Jimerson from comment #5) https://github.com/elves/elvish/issues/861
(In reply to Dmitri Goutnik from comment #6) Thanks, you beat me to it. Good to know that now that those two variables are considered not needed any more so won't bother setting them in the port. In that case lets go with your suggested patch as it will be cleaner than mine.
(In reply to Adam Jimerson from comment #7) It seems like the only change might be to add the `-trimpath` argument to the GO_BUILDFLAG as upstream tends to start using that as well https://github.com/elves/elvish/issues/861#issuecomment-546107146
Comment on attachment 208544 [details] elvish-0.12_1.patch v1 This is better than mine.
Created attachment 208589 [details] elvish-0.12_1.patch v2 With -trimpath and -s -w to omit debug info.
Comment on attachment 208589 [details] elvish-0.12_1.patch v2 Looks good to me
Quick question, when I change the "?" to a "+" for the maintainer-approval flag on the patch you submitted on here shouldn't that show up somewhere?
(In reply to Adam Jimerson from comment #12) Normally, Bugzilla should show "maintainer-approval+" on the patch when you set it to "+" and save, but it might not work with patches submitted by a committer (as I recall from pre-committer days).
(In reply to Dmitri Goutnik from comment #13) Okay just curious as I didn't see any change
A commit references this bug: Author: dmgk Date: Fri Oct 25 12:07:31 UTC 2019 New revision: 515605 URL: https://svnweb.freebsd.org/changeset/ports/515605 Log: shells/elvish: Set version information, omit debug info PR: 241446 Approved by: Adam Jimerson <vendion@gmail.com> (maintainer), araujo (mentor) Differential Revision: https://reviews.freebsd.org/D22149 Changes: head/shells/elvish/Makefile
Committed, thanks!
Thank you for your help! :)