Page MenuHomeFreeBSD

Mk/Uses/go.mk: Allow Go port selection with GO_PORT
ClosedPublic

Authored by dmgk on Jun 9 2019, 2:51 PM.
Tags
None
Referenced Files
Unknown Object (File)
Feb 17 2024, 11:50 AM
Unknown Object (File)
Feb 17 2024, 11:50 AM
Unknown Object (File)
Feb 17 2024, 11:50 AM
Unknown Object (File)
Feb 17 2024, 11:50 AM
Unknown Object (File)
Feb 17 2024, 11:38 AM
Unknown Object (File)
Jan 15 2024, 8:56 PM
Unknown Object (File)
Jan 13 2024, 2:40 PM
Unknown Object (File)
Dec 26 2023, 10:44 AM

Details

Summary

Add support for Go default version selection to allow easier ports testing with
lang/go-devel (https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=238374)

Diff Detail

Repository
rP FreeBSD ports repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

~120 ports unfortunately do not use USES=go and declare a build dependency on lang/go themselves. They should be updated to use GO_DEFAULT too.

~120 ports unfortunately do not use USES=go and declare a build dependency on lang/go themselves. They should be updated to use GO_DEFAULT too.

I'd advocate for replacing explicit BUILD_DEPENDS with USES=go, even if only for adding a configurable build dependency and giving the port access to GO_ENV and GO_BUILDFLAGS.
We have semi-regular fallouts because ports are missing some build flag or env variable that becomes required in the next Go version (e.g. recent GOCACHE failures), it would be much easier to have these managed in one place. Go 1.13 (which is due in 2 months) will be especially disruptive because of changes to modules handling [1] and (possibly) GOPROXY [2].

[1] https://github.com/golang/go/issues/31857
[2] https://proxy.golang.org/

Well, DEFAULT_VERSIONS is a user facing variable something users can set to choose the version they want to use. I have a feeling this is only for testing purposes, so it would probably be better to patch your local installation. Otherwise, people would end up setting go=go14 and complain things break.

In D20570#444928, @mat wrote:

Well, DEFAULT_VERSIONS is a user facing variable something users can set to choose the version they want to use. I have a feeling this is only for testing purposes, so it would probably be better to patch your local installation. Otherwise, people would end up setting go=go14 and complain things break.

Correct, go-devel is primarily for testing by port maintainers. The idea was to make this testing easier so most failures can be caught and fixed before the new lang/go version lands.
Out of ~250 Go ports we have in the tree ~30 currently fail to build with go-devel and although most fixes are trivial, maintainers have no easy way to do a quick QA with the upcoming version or verify submitted fix - most probably won't bother to modify lang/go or build current Go master branch from sources.

Setting go=go14 would break things and shouldn't be allowed, though it's not clear where would be the best place to add version validation due to the unfortunate 50/50 split between ports using go.mk and not using it. I was hoping that some consensus could be reached and explicit BUILD_DEPENDS=go:lang/go can be replaced with USES=go so all configuration can be managed in one place.

In D20570#444950, @dg_syrec.org wrote:
In D20570#444928, @mat wrote:

Well, DEFAULT_VERSIONS is a user facing variable something users can set to choose the version they want to use. I have a feeling this is only for testing purposes, so it would probably be better to patch your local installation. Otherwise, people would end up setting go=go14 and complain things break.

Correct, go-devel is primarily for testing by port maintainers. The idea was to make this testing easier so most failures can be caught and fixed before the new lang/go version lands.

I had the same intentions for GHC (Haskell compiler) and solved it by making PORTVERSION variable overridable. This still allows building different GHC versions, but at the same time hides that fact from regural users.

I would probably change it to:

LANG_GO_PORT?=     lang/go
BUILD_DEPENDS+=    ${GO_CMD}:${LANG_GO_PORT}

or something similar, so that you can set LANG_GO_PORT=lang/go-devel in your make.conf, while preventing users from breaking their systems.

Do not set DEFAULT_VERSION to prevent users breaking their systems by setting go=go14,
add simple Go port selection with GO_PORT instead.

dmgk retitled this revision from Mk/bsd.default-versions.mk, Mk/Uses/go.mk: Add GO_DEFAULT version selection to Mk/Uses/go.mk: Allow Go port selection with GO_PORT.Jun 11 2019, 12:32 PM
In D20570#445269, @mat wrote:

while preventing users from breaking their systems.

Is this the only reason against using DEFAULT_VERSIONS here? I do not see how GO_PORT would prevent that problem since you can still set it to lang/go14 in make.conf. It is just now obscured and hidden deeper in the framework.

Setting go=go14 would not even remotely work for anything given that lang/go14 installs the go command in a separate prefix outside of the default PATH as /usr/local/go14/bin/go only. Port builds would not even really start with that.

go=go14 could also be explicitly disallowed with some extra code.

In D20570#445296, @dg_syrec.org wrote:

Do not set DEFAULT_VERSION to prevent users breaking their systems by setting go=go14,
add simple Go port selection with GO_PORT instead.

Could you add a note about GO_PORT to the top of go.mk and make it clear that it can only be set in make.conf for testing purposes and not by individual ports [1]? Otherwise we will probably see port submissions that set GO_PORT=lang/go14.

[1] (N.B. At least with GO_DEFAULT the framework would have code in place to prevent that already.)

This revision was not accepted when it landed; it landed in state Needs Review.Jun 23 2019, 11:50 AM
This revision was automatically updated to reflect the committed changes.