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

updated go sources which can read ldflags #3282

Merged
merged 1 commit into from
Jun 14, 2023

Conversation

deitch
Copy link
Contributor

@deitch deitch commented Jun 14, 2023

A problem with go binaries is that when built with go build, they do not include their main module information, e.g.:

/tmp/fscrypt: go1.18.6
	path	github.com/google/fscrypt/cmd/fscrypt
	mod	github.com/google/fscrypt	(devel)
	dep	github.com/golang/protobuf	v1.2.0	h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM=
	dep	github.com/pkg/errors	v0.8.0	h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
	dep	github.com/urfave/cli	v1.20.0	h1:fDqGv3UG/4jbVl/QkFwEdddtEDjh/5Ov6X+0B/3bPaw=
	dep	golang.org/x/crypto	v0.0.0-20180820150726-614d502a4dac	h1:7d7lG9fHOLdL6jZPtnV4LpI41SbohIJ1Atq7U991dMg=
	dep	golang.org/x/sys	v0.0.0-20180828065106-d99a578cf41b	h1:cmOZLU2i7CLArKNViO+ZCQ47wqYFyKEIpbGWp+b6Uoc=
	build	-compiler=gc
	build	-ldflags="-s -w -X \"main.version=v0.2.4\" -X \"main.buildTime=Fri Dec 16 11:03:45 UTC 2022\" -extldflags \"\""
	build	CGO_ENABLED=1
	build	CGO_CFLAGS="-O2 -Wall"
	build	CGO_CPPFLAGS=
	build	CGO_CXXFLAGS=
	build	CGO_LDFLAGS=
	build	GOARCH=amd64
	build	GOOS=linux
	build	GOAMD64=v1
	build	vcs=git
	build	vcs.revision=b41569d397d3e66099cde07d8eef36b2f42dd0ec
	build	vcs.time=2019-07-28T02:24:19Z
	build	vcs.modified=true

See the mod line at the beginning above.

This is a core golang issue which we will not solve here. However, we have started in previous PRs to ensure that the ldflags include -X main.Version=<version>, which some utilities know how to read and interpret.

Those utilities include syft, and now, the utility that collects the go sources.

This PR updates our version of that utility to be able to read the main.Version.

Signed-off-by: Avi Deitcher <avi@deitcher.net>
@deitch deitch requested review from eriknordmark and rvs as code owners June 14, 2023 10:22
Copy link
Contributor

@eriknordmark eriknordmark left a comment

Choose a reason for hiding this comment

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

LGTM

@eriknordmark eriknordmark merged commit f5a32f9 into lf-edge:master Jun 14, 2023
@deitch deitch deleted the bump-go-collected-sources branch June 14, 2023 17:15
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.

2 participants