You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I work on go-rules for Buck2 and miss an option to add BuildInfo information that can be retrieved from a go binary without executing it with tools like readelf, go version or similar. Bazel have a similar request from its users.
I'm happy to do a PR in Go 😀
Implementation ideas
1. Re-use "go:buildinfo" section
Buck/Bazel can add information the same way as go build does by supplying -importcfg with modinfo section.
Then this data can be accessed via readelf/etc, go version or debug/buildinfo.BuildInfo.Settings field.
The BuildSetting is a key-value structure and can be used for Buck/Bazel data or user provided data.
This doesn't require any changes in Golang project code, just confirmation from you that we can "rely" on this behaviour of cmd/ld and debug/buildinfo.
Alternatively cmd/ld can have a flag like -buildsetting key:value to enable us (and go build users via -ldflags option) to add custom data to this structure.
2. Add custom sections
Add a new flag -section name:value (or -section name:value_filepath) to cmd/ld to enable linker to put arbitrary data into binaries.
In this case a user can define its of format for this data but also will need to implement their own tools to read data.
The text was updated successfully, but these errors were encountered:
Adding a new custom section and adding additional data to the .go.buildinfo section sound like two different things. What kind of data do you want to add? Who exactly is going to retrieve that data?
Data like binary-name, build-id, vcs-revision, build-context, etc.
Who exactly is going to retrieve that data?
Our internal tools that read binaries during their lifecycle.
Adding a new custom section and adding additional data to the .go.buildinfo section sound like two different things.
Yes and if we add data to ".go.buildinfo" we also need to integrate our tools with it.
If we add a custom section we can read it without extra modifications in our tools the same way we read buildinfo added to C/C++/etc binaries.
Proposal Details
I work on go-rules for Buck2 and miss an option to add BuildInfo information that can be retrieved from a go binary without executing it with tools like
readelf
,go version
or similar.Bazel have a similar request from its users.
I'm happy to do a PR in Go 😀
Implementation ideas
1. Re-use "go:buildinfo" section
Buck/Bazel can add information the same way as
go build
does by supplying-importcfg
withmodinfo
section.Then this data can be accessed via
readelf
/etc,go version
ordebug/buildinfo.BuildInfo.Settings
field.The
BuildSetting
is a key-value structure and can be used for Buck/Bazel data or user provided data.This doesn't require any changes in Golang project code, just confirmation from you that we can "rely" on this behaviour of
cmd/ld
anddebug/buildinfo
.Alternatively
cmd/ld
can have a flag like-buildsetting key:value
to enable us (andgo build
users via-ldflags
option) to add custom data to this structure.2. Add custom sections
Add a new flag
-section name:value
(or-section name:value_filepath
) tocmd/ld
to enable linker to put arbitrary data into binaries.In this case a user can define its of format for this data but also will need to implement their own tools to read data.
The text was updated successfully, but these errors were encountered: