feat(plugingo): extensible build-env factors (GOEXPERIMENT/GODEBUG), ldflags, build_addr#58
Open
raphaelvigee wants to merge 2 commits into
Open
feat(plugingo): extensible build-env factors (GOEXPERIMENT/GODEBUG), ldflags, build_addr#58raphaelvigee wants to merge 2 commits into
raphaelvigee wants to merge 2 commits into
Conversation
…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>
2fdf3d7 to
3065327
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Makes the Go plugin's
Factorsextensible so users can customize builds beyondgoos/goarch/tags, plus a public address composer.Factors.env(BTreeMap keyed by Go env var) driven by anENV_FACTORStable. Shipsgoexperiment→GOEXPERIMENTandgodebug→GODEBUG; a new knob is one table row. Knobs round-trip through addrs, land in the hashedenvof every build/test/stdlib spec (viabuild_env_map), and flow through the golist driver (config →GoGolistDef.env→ hash) and in-processpkg_analysisgo list.Factors.ldflagsapply to the link step only: baked intogo tool linkingenerate_link_script(hashed viarun), and deliberately excluded fromfactors_to_argssobuild_libarchives stay cache-shared across binaries that differ only in link flags.Provider::build_addr(package, factors)— composes the binarybuildtarget addr, re-attachingldflags.Factorsis now re-exported from the module.Usage
Cache impact
GO_GOLIST_FORMAT_VERSIONbumped 10→11 — existing_golistcache entries re-resolve once on next run.Test plan
cargo buildclean ·cargo clippy --all-targetsclean ·cargo fmtappliedcargo test --lib plugingo::→ 254 passedfactors_to_args, hashed-env carry, golist def-hash divergence, link-command injection,build_addrcomposition/round-trip🤖 Generated with Claude Code