Page MenuHomeFreeBSD

Mk/Uses/go.mk: Remove support for installing Go libs and sources; add initial modules support
ClosedPublic

Authored by dmgk on Mar 13 2019, 1:48 PM.

Details

Summary
  • Remove support for installing compiled Go libs into GO_LIBDIR and source code into GO_SRCDIR [1]
  • Restrict build to only main packages by adding -buildmode=exe to GO_BUILDFLAGS [2]
  • Add modules argument for initial support for building in module-aware mode. Current support is basic and does two things:
    • disables adding post-extract target and avoids creation of GOPATH dir structure (not needed in module mode)
    • disables network access during build by adding -mod=vendor to GO_BUILDFLAGS [3]

Note: this depends on https://reviews.freebsd.org/D19568

[1] https://www.freebsd.org/doc/en/books/porters-handbook/book.html#go-libs
[2] https://golang.org/cmd/go/#hdr-Build_modes
[3] https://golang.org/cmd/go/#hdr-Modules_and_vendoring

Test Plan

exp-run

Diff Detail

Repository
rP FreeBSD ports repository
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

dmgk removed a reviewer: O5: Ports Framework. dmgk removed 1 blocking reviewer(s): portmgr.Mar 14 2019, 12:25 PM
This revision is now accepted and ready to land.Mar 14 2019, 12:25 PM
This revision now requires review to proceed.Mar 14 2019, 12:25 PM

Make go.mk work with either GO_PKGNAME/GH_SUBDIR or both.

If both GO_PKGNAME and GH_SUBDIR are set, GO_PKGNAME takes precedence. If
GO_PKGNAME is unset, set it from GH_SUBDIR. Unset GH_SUBDIR and let
post-extract target to setup GOPATH hierarchy.

0mp added inline comments.
Mk/Uses/go.mk
36 ↗(On Diff #55472)

I am not sure, but shouldn't we document how to use this new modules argument somewhere in this file?

95 ↗(On Diff #55472)

Should it be PREFIX instead of LOCALBASE?

Use PREFIX instead of LOCALBASE in do-install.

dmgk added inline comments.
Mk/Uses/go.mk
95 ↗(On Diff #55472)

It probably should, thanks for noticing.

dmgk added inline comments.
Mk/Uses/go.mk
36 ↗(On Diff #55472)

I was going to submit an update to the PHB's Go section when/if this gets merged.

  • Do not undef GH_SUBDIR
  • Put back GO_WRKDIR_BIN and GO_WRKDIR_SRC, they are used by many ports in build and install targets
  • Do not silence build

Build failures and fixes with ports r497574:

# poudriere bulk -C -j112a $(find /usr/ports -name Makefile | xargs egrep 'USES=.*\sgo(\W|$)' | sed -E 's|^/usr/ports/([^/]+/[^/]+)/.*$|\1|')

In D19570#424428, @dg_syrec.org wrote:

Build failures and fixes with ports r497574:

# poudriere bulk -C -j112a $(find /usr/ports -name Makefile | xargs egrep 'USES=.*\sgo(\W|$)' | sed -E 's|^/usr/ports/([^/]+/[^/]+)/.*$|\1|')

I took care of the ones that work with the previous USES=go too (all except for mail/mailhog).

Mk/Uses/go.mk
36 ↗(On Diff #55472)

Since you are going to explain modules in the PHB anyway, I think a comment at the top of this file to explain what it does would still be nice. Similar to what other USES modules do.

@tobik Thank you for the commits Tobias. mail/mailhog is unrelated to this review I added by mistake along with other build failures.

Update file comments: add a short ARGS description; describe how variables work in modules mode; add a note about GO_PKGNAME/GH_SUBDIR relationship.

dmgk marked an inline comment as done.Apr 3 2019, 2:28 PM

This looks ready to me.

Is there anything left to do? @jlaffaye

This revision was not accepted when it landed; it landed in state Needs Review.Apr 8 2019, 4:46 PM
This revision was automatically updated to reflect the committed changes.