Skip to content

build(vendor): restore the go-tpm-tools sources the TPM simulator needs - #21

Merged
wgkingk merged 1 commit into
1.9.1-alauda-4.5from
fix/vendor-go-tpm-tools-sources
Nov 27, 2026
Merged

wgkingk merged 1 commit into
1.9.1-alauda-4.5from
fix/vendor-go-tpm-tools-sources

Conversation

@wgkingk

@wgkingk wgkingk commented Nov 27, 2026

Copy link
Copy Markdown
Collaborator

Why

The first CI run on the fork (run 45965358394, on #20) failed: six Ginkgo suites did not compile.

vendor/github.com/google/go-tpm-tools/simulator/internal/internal_cgo.go:46:11: fatal error: Platform.h: No such file or directory

go mod vendor drops the C sources of github.com/google/go-tpm-tools. Upstream's make vendor re-extracts the release tarball of the go.mod version into vendor/ for this reason, and upstream v1.9.x tracks 451 .h/.c files there. The fork kept only one: it was re-vendored with plain go mod vendor in 6945ef4 ("support alauda baremetal"). Every branch since inherits that, including 1.9.1-alauda and 1.9.1-alauda-4.6. The local test runs in #15, #16 and #18 had to work around it with -mod=mod.

What

The vendor target's extraction step, for GO_TPM_TAG=v0.4.9 (from go.mod):

tar xaf go-tpm-tools.tar.gz --strip-components=1 -C vendor/github.com/google/go-tpm-tools
  • Files are only added (833). The 7 Go files that were already vendored are byte-identical. Nothing outside vendor/github.com/google/go-tpm-tools/ changes: go.mod, go.sum and vendor/modules.txt are untouched.
  • Some files match go-tpm-tools' own .gitignore and were added with -f: simulator/ms-tpm-20-ref/TPMCmd/tpm/src/main/*.c (the simulator #includes them), cmd/gotpm/, go.work and go.work.sum. Upstream tracks these too. All 840 files of the tarball are tracked.
  • Tarball sha256: a2eb3739afa65b60c351550c6c0541f17c5af6a22837da3690fcd6e44ef354bf.

Impact

Test-only. Release builds already avoid the missing files:

  • the operator image is built with CGO_ENABLED=0;
  • os-build's Dockerfile.register downloads the same tarball before it builds elemental-register with cgo.

Consumers do not need to move their pins for this.

Verification

Local, from vendor only (GOFLAGS=-mod=vendor GOPROXY=off CGO_ENABLED=1):

  • go build ./... and go vet on the affected packages: OK. The only output is the known function main is undeclared for the generator-only generate.go and utils/mockgen.go.
  • go test -race on the six suites that failed to compile in CI: pkg/tpm, pkg/install, pkg/server, cmd/operator/operator and cmd/register pass. pkg/register passes 61 of 64. The 3 failures are the known cannot retrieve MAC address from any network interface in this NIC-less container, the same 3 that fail on the base commit.

This PR's own Unit tests run is the real check: GitHub runners have a NIC and envtest, so all 16 suites should run.

After merge: merge 1.9.1-alauda-4.5 forward into 1.9.1-alauda-4.6, then bring that into #20.

🤖 Generated with Claude Code

`go mod vendor` drops the C sources of github.com/google/go-tpm-tools, so
the vendored simulator does not compile with cgo ("Platform.h: No such
file or directory"). Upstream's `make vendor` re-extracts the release
tarball of the go.mod version into vendor/ for exactly this reason. The
fork lost those files when it was re-vendored with plain `go mod vendor`
in 6945ef4, and every branch since has inherited that.

Extract the v0.4.9 tarball the way the `vendor` target does. Files are
only added: the 7 Go files already vendored are identical. Some of them
match go-tpm-tools' own .gitignore, among them TPMCmd/tpm/src/main/*.c,
which the simulator includes, so they are added with -f; upstream tracks
them too. go.mod, go.sum and vendor/modules.txt do not change.

Release builds are not affected: the operator is built with
CGO_ENABLED=0, and os-build restores the same sources before it builds
elemental-register. This fixes the cgo unit tests (pkg/install,
pkg/register, pkg/server, pkg/tpm, cmd/operator, cmd/register), which
failed to compile in CI.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wgkingk
wgkingk merged commit c7568f9 into 1.9.1-alauda-4.5 Nov 27, 2026
1 check passed
wgkingk added a commit that referenced this pull request Nov 27, 2026
Brings in #21 (restore the go-tpm-tools sources the TPM simulator needs)
via #22, so the cgo unit tests compile on this branch too.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wgkingk
wgkingk deleted the fix/vendor-go-tpm-tools-sources branch November 27, 2026 09:17
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