Skip to content

build: inject BuildTime + Commit ldflags into the mobile binary#8900

Open
myleshorton wants to merge 1 commit into
mainfrom
fisk/build-stamp
Open

build: inject BuildTime + Commit ldflags into the mobile binary#8900
myleshorton wants to merge 1 commit into
mainfrom
fisk/build-stamp

Conversation

@myleshorton

@myleshorton myleshorton commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

What

Extend EXTRA_LDFLAGS (already carrying common.Version) with:

  • common.BuildTime — UTC RFC3339 build timestamp
  • common.Commit — short git SHA

Both flow into the existing android/macOS/iOS gomobile-bind targets via EXTRA_LDFLAGS. Windows-safe (powershell branch for the timestamp).

Why

Pairs with getlantern/radiance (getlantern/radiance#556) to make a shipped binary self-describing. A 9.1.14 TestFlight build linked a stale, pre-fix keepcurrent despite go.mod declaring the fix; a build-time + commit stamp (with radiance now logging linked dep versions) makes such a stale build obvious in logs and crash reports instead of silent.

🤖 Generated with Claude Code

https://claude.ai/code/session_01WGpKfgkbfdJwwsTaouMDoR

Summary by CodeRabbit

  • New Features
    • Builds now include additional metadata, such as build time and commit information, alongside the version number.

Extend EXTRA_LDFLAGS (already carrying common.Version) with common.BuildTime
(UTC) and common.Commit so gomobile/native builds stamp when and from what
commit they were built. Pairs with radiance's build-info logging to make a
stale build — one whose linked deps don't match go.mod — visible in logs and
crash reports.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGpKfgkbfdJwwsTaouMDoR
Copilot AI review requested due to automatic review settings July 8, 2026 12:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the existing Go linker flag injection for mobile builds so the produced binaries carry additional build-identifying metadata (build timestamp and git commit), helping correlate shipped artifacts with source and dependency state.

Changes:

  • Adds a UTC RFC3339 BUILD_TIME stamp (with a PowerShell branch for Windows).
  • Adds a short GIT_COMMIT stamp and injects both into EXTRA_LDFLAGS alongside the existing common.Version.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread Makefile
Comment on lines +78 to +84
ifeq ($(OS),Windows_NT)
BUILD_TIME ?= $(shell powershell -NoProfile -Command "[DateTime]::UtcNow.ToString('yyyy-MM-ddTHH:mm:ssZ')")
else
BUILD_TIME ?= $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
endif
GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
EXTRA_LDFLAGS ?= -X '$(RADIANCE_REPO)/common.Version=$(APP_VERSION_PUBSPEC)' -X '$(RADIANCE_REPO)/common.BuildTime=$(BUILD_TIME)' -X '$(RADIANCE_REPO)/common.Commit=$(GIT_COMMIT)'
@coderabbitai

coderabbitai Bot commented Jul 8, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 3fcce485-8050-4b1e-9676-88b7d9d6e3ef

📥 Commits

Reviewing files that changed from the base of the PR and between f954364 and bd2d4e1.

📒 Files selected for processing (1)
  • Makefile

📝 Walkthrough

Walkthrough

The Makefile's default EXTRA_LDFLAGS was expanded to stamp common.BuildTime and common.Commit in addition to common.Version. New variables BUILD_TIME (platform-dependent) and GIT_COMMIT (git short hash) were introduced to supply these values.

Changes

Build ldflags stamping

Layer / File(s) Summary
Add build metadata variables and update ldflags
Makefile
Adds BUILD_TIME and GIT_COMMIT variables and updates EXTRA_LDFLAGS to stamp common.Version, common.BuildTime, and common.Commit via linker flags.

Estimated code review effort: 1 (Trivial) | ~5 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main change: adding BuildTime and Commit ldflags to the mobile build.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fisk/build-stamp

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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