Re: Golang debug/buildinfo

From: Dmitri Goutnik <dmgk_at_freebsd.org>
Date: Sat, 28 May 2022 00:03:38 UTC
Hi Ben,

On 22-05-27 22:31:52, Ben Lavery-Griffiths wrote:
> Hey all,
> 
> I maintain the www/gohugo port, with the upgrade to Go 1.18 they project has switched to using debug/buildinfo (https://pkg.go.dev/runtime/debug#BuildInfo), this gets certain information from VCS, as opposed to passing the values in via ldflags.
> 
> Presuming more and more Go projects will use this mechanism, does anyone know how we will be dealing with this for building ports?

Currently, go.mk explicitly disables embedding VCS information in binaries by 
passing -buildvcs=false flag. Embedding VCS info will not work for port builds 
because it required git (or other VCS, depending on the repository [1]), which 
is not available in clean build environments. Other BuildInfo data (compiler 
version, settings etc) should be available.

In cases when upstream code is not able to handle missing VCS info, it will 
probably need to be patched. I'd consider this situation an upstream bug as it 
effectively prevents packaging.

[2] provides more background on this issue.

[1] https://tip.golang.org/doc/go1.18#go-version
[2] https://github.com/golang/go/issues/51748

> Many thanks,
> Ben
> 

Best regards,

-- 
Dmitri Goutnik
dg@syrec.org / dmgk@FreeBSD.org