-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
go build -trimpath
makes other arguments ignored in debug.BuildInfo
#3906
Comments
AFAIK there is no standard tooling to get the version information from the way we set versions in the resulting binary. Yes, the All of that being said, I don't mind making it something you can opt-out of but it should be made clear it's needed for reproducible builds. I thought we added |
Yeah, this is a longstanding issue of much debate at In any case, if you don't mind it being optional, I can open a PR for it that allows you to override it. |
See #3908 |
Yeah, I find it quite strange that |
Although by that argument, there's all sorts of other areas it could strip. Maybe the value of I think it's a case of their being too smart by half. 😁 |
Description
go build -trimpath
makes the-X
ldflags disappear.The
runc
build command from the Makefile looks like this:where
LDFLAGS_COMMON
is set here:While the provided information is really useful for running
runc version
, e.g.:(and I particular appreciate the go pseudo-version-compatible
commit
)if you run with
-trimpath
, that information is not saved indebug.BuildInfo
, making it harder to use standard tooling to extract it.Here it is built without
-trimpath
:$ go version -m runc runc: go1.19.4 path github.com/opencontainers/runc build -compiler=gc build -ldflags="-X main.gitCommit=v1.1.0-578-g5cf9bb22 -X main.version=1.1.0+dev -linkmode external -extldflags -static-pie " build -tags=seccomp,urfave_cli_no_docs,netgo,osusergo build CGO_ENABLED=1 build CGO_CFLAGS= build CGO_CPPFLAGS= build CGO_CXXFLAGS= build CGO_LDFLAGS= build GOARCH=amd64 build GOOS=linux build GOAMD64=v1
And the default with
-trimpath
:I think this would be good enough if
-trimpath
were optional, so builders can choose to select it or not.Steps to reproduce the issue
make -n static
to get the build commandgo version -m runc
-trimpath
go version -m runc
Describe the results you received and expected
Expected
debug.BuildInfo
to include-X
flags and other ldflags and build-time info.It was missing.
What version of runc are you using?
Latest
main
HEAD as of today (commit 5cf9bb2 from Wed 14 June 2023). Tried much earlier versions, and with different versions of go as well. Same outcome.Host OS information
NA
Host kernel information
NA
The text was updated successfully, but these errors were encountered: