Repository navigation
Description
Makefile:11 and OBJECTFS.md:613 both pass -ldflags "-X main.Version=...", and there is no main.Version to set.
cmd/objectfs/main.go:23 declares the version inside a const block. The linker cannot rewrite a constant, so the flag is accepted and silently ignored. Demonstrated:
$ go build -ldflags="-s -w -X main.Version=FAKE-VERSION" -o /tmp/objfs-probe ./cmd/objectfs
$ /tmp/objfs-probe --version
objectfs version 0.11.0
make build, make build-all, make build-linux, make build-darwin, make install and make package all use that LDFLAGS, so every one of them passes three dead symbols (main.Version, main.Commit, main.BuildTime).
This is not a new finding. .github/workflows/release.yml:127 already carries the explanation, and the v0.10.3 changelog entry documents removing the identical injection from the release workflow and the Dockerfile. These two are the copies that removal did not reach — DEVELOPMENT.md:444 was a third and is fixed in #198's branch.
Not urgent: the flags do nothing rather than something wrong, and release.yml asserts the tag and the constant agree, so a release cannot ship a mislabeled version. What it costs is a reader believing the build injects a version when it does not — the same class as the five-different-version-numbers problem CLAUDE.md calls out.
Two candidate fixes, and they are not equivalent:
- Drop the dead flags.
LDFLAGS := -ldflags="-s -w". Matches whatrelease.ymldoes.VERSION,COMMITandBUILD_TIMEstay useful in the Makefile formake versionand for naming packages. - Make them real — move the version to a
var, or aninternal/versionpackage withVersion/Commit/BuildTimevars. This conflicts withCLAUDE.md's "theversionconstant incmd/objectfs/main.gois the only authority", and withrelease.yml's reasoning that a checked constant is a better shape than a link-time injection that leaves the source disagreeing with the artifact. Commit and build time have no constant to disagree with, though, so there is a real argument for injecting those two.
Recommend (1) for Makefile and OBJECTFS.md now, and treating "should the binary report its commit and build time at all" as a separate question. If it should, --version needs to print them, which it currently does not.
Verification: grep -rn "main.Version\|main.Commit\|main.BuildTime" --include="*.go" --include="*.md" --include="Makefile" --include="*.yml" . returns only historical CHANGELOG.md prose; make build && ./bin/objectfs --version still reports the constant.
Activity
fix: the overflow guard overflowed, and armv7 shipped from an unbuilt…