Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add cache key for all Go SDK invocations (Cherry pick of #14897) #14902

Merged
merged 1 commit into from Mar 24, 2022

Conversation

tdyas
Copy link
Contributor

@tdyas tdyas commented Mar 24, 2022

Problem

At my company, we tried to upgrade from Go 1.16 to Go 1.17, but Pants invocations with the Go backend were failing with errors similar to the following:

pants.engine.process.ProcessExecutionFailure: Process 'Link Go binary: ./package_analyzer' failed with exit code 1.
stdout:
cannot find package internal/buildcfg (using -importcfg)
cannot find package internal/itoa (using -importcfg)
cannot find package go/internal/typeparams (using -importcfg)
cannot find package internal/abi (using -importcfg)
cannot find package internal/goexperiment (using -importcfg)

As it turns out, the Go backend was using a cached stdlib import analysis from Go 1.16 to produce the import config, and the "missing" packages are packages introduced in Go 1.17. The Go version was not incorporated into the cache key for Go SDK invocations to prevent this issue. This occurs because the hash of the Go tooling is not part of the input root any more because we invoke Go from a system path and don't fingerprint it.

Solution

Incorporate version, GOOS, and GOARCH into Go SDK invocations as cache key.

[ci skip-rust]

[ci skip-build-wheels]

## Problem

At my company, we tried to upgrade from Go 1.16 to Go 1.17, but Pants invocations with the Go backend were failing with errors similar to the following:

```
pants.engine.process.ProcessExecutionFailure: Process 'Link Go binary: ./package_analyzer' failed with exit code 1.
stdout:
cannot find package internal/buildcfg (using -importcfg)
cannot find package internal/itoa (using -importcfg)
cannot find package go/internal/typeparams (using -importcfg)
cannot find package internal/abi (using -importcfg)
cannot find package internal/goexperiment (using -importcfg)
```

As it turns out, the Go backend was using a cached stdlib import analysis from Go 1.16 to produce the import config, and the "missing" packages are packages introduced in Go 1.17. The Go version was not incorporated into the cache key for Go SDK invocations to prevent this issue. This occurs because the hash of the Go tooling is not part of the input root any more because we invoke Go from a system path and don't fingerprint it.

## Solution

Incorporate version, GOOS, and GOARCH into Go SDK invocations as cache key.

[ci skip-rust]

[ci skip-build-wheels]
@tdyas tdyas merged commit f8de434 into pantsbuild:2.10.x Mar 24, 2022
@tdyas tdyas deleted the cp_cache_key_2.10 branch March 24, 2022 17:20
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.

None yet

2 participants