Skip to content

feat(plugingo): extensible build-env factors (GOEXPERIMENT/GODEBUG), ldflags, build_addr#58

Open
raphaelvigee wants to merge 2 commits into
masterfrom
worktree-bridge-cse_01Tv4zcHSxSt39AnqSgv76d6
Open

feat(plugingo): extensible build-env factors (GOEXPERIMENT/GODEBUG), ldflags, build_addr#58
raphaelvigee wants to merge 2 commits into
masterfrom
worktree-bridge-cse_01Tv4zcHSxSt39AnqSgv76d6

Conversation

@raphaelvigee

Copy link
Copy Markdown
Member

Summary

Makes the Go plugin's Factors extensible so users can customize builds beyond goos/goarch/tags, plus a public address composer.

  • Build-env knobsFactors.env (BTreeMap keyed by Go env var) driven by an ENV_FACTORS table. Ships goexperiment→GOEXPERIMENT and godebug→GODEBUG; a new knob is one table row. Knobs round-trip through addrs, land in the hashed env of every build/test/stdlib spec (via build_env_map), and flow through the golist driver (config → GoGolistDef.env → hash) and in-process pkg_analysis go list.
  • Linker flagsFactors.ldflags apply to the link step only: baked into go tool link in generate_link_script (hashed via run), and deliberately excluded from factors_to_args so build_lib archives stay cache-shared across binaries that differ only in link flags.
  • Provider::build_addr(package, factors) — composes the binary build target addr, re-attaching ldflags. Factors is now re-exported from the module.

Usage

//cmd/app:build@goexperiment=rangefunc,godebug=http2debug=1,ldflags="-s -w"

Cache impact

GO_GOLIST_FORMAT_VERSION bumped 10→11 — existing _golist cache entries re-resolve once on next run.

Test plan

  • cargo build clean · cargo clippy --all-targets clean · cargo fmt applied
  • cargo test --lib plugingo:: → 254 passed
  • New tests: addr parsing/round-trip, ldflags exclusion from factors_to_args, hashed-env carry, golist def-hash divergence, link-command injection, build_addr composition/round-trip

🤖 Generated with Claude Code

raphaelvigee and others added 2 commits June 6, 2026 14:31
…ldflags, build_addr

Factors gains an extensible env knob table plus link-only ldflags, and the
provider exposes a public build_addr composer.

- Factors: add `env` (BTreeMap keyed by Go env var) + `ldflags`, driven by an
  ENV_FACTORS table (goexperiment→GOEXPERIMENT, godebug→GODEBUG). New knob = one row.
- Env knobs round-trip through addrs (from_addr / factors_to_args), land in the
  hashed `env` of every build/test/stdlib spec via build_env_map, and flow through
  the golist driver (config → GoGolistDef.env → hash; format version 10→11) and
  in-process pkg_analysis go list.
- Linker flags apply to the link step only: baked into go tool link in
  generate_link_script (hashed via `run`), and deliberately excluded from
  factors_to_args so build_lib archives stay cache-shared across differing ldflags.
- Provider::build_addr(package, factors) composes the binary `build` target addr,
  re-attaching ldflags; Factors re-exported from the module.

Tests cover addr parsing/round-trip, hashed-env carry, golist def-hash divergence,
link-command injection, and build_addr composition.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Surface go build-address composition to BUILD files via the engine's existing
ProviderFunctionDef mechanism, as `heph.go.build_addr(...)`.

- Move the composition to a free addr_util::build_addr(package, factors); the
  inherent Provider::build_addr delegates to it.
- Implement BuildAddrFn (ProviderFn) and advertise it from Provider::functions().
  Args: `package` (positional or named) + optional goos/goarch/tags/goexperiment/
  godebug/ldflags. tags/ldflags accept a list or a string (tags split on ',',
  ldflags on whitespace); goos/goarch default to the host. Returns the composed
  `build` target address as a string.

Reuses the existing ProviderFunctionDef/ProviderFn/FnArgs infrastructure — no
engine changes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@raphaelvigee raphaelvigee force-pushed the worktree-bridge-cse_01Tv4zcHSxSt39AnqSgv76d6 branch from 2fdf3d7 to 3065327 Compare June 6, 2026 12:32
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.

1 participant