Skip to content

build: Makefile and OBJECTFS.md inject a main.Version that does not exist #353

Closed

Description

@scttfrdmn

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:

  1. Drop the dead flags. LDFLAGS := -ldflags="-s -w". Matches what release.yml does. VERSION, COMMIT and BUILD_TIME stay useful in the Makefile for make version and for naming packages.
  2. Make them real — move the version to a var, or an internal/version package with Version/Commit/BuildTime vars. This conflicts with CLAUDE.md's "the version constant in cmd/objectfs/main.go is the only authority", and with release.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

  1. added this to the Future Work milestone on Aug 4, 2026
  2. added
    type: bug
    priority: low
    area: build
    area: docs
    effort: xs
    on Aug 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: buildarea: docseffort: xspriority: lowtype: bug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions