Go crypto fallback: use GOEXPERIMENT for opt-in #984
Merged
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.
#965 changed Microsoft Go behavior so that instead of falling back to Go crypto, the build will fail if a backend is enabled and its requirements aren't met.
This caused issues in the Go build and test because in many places, cgo isn't enabled and cross-builds are being done. So, #965 added
-tags=allow_missing_crypto_backend_fallback
to opt out of this behavior, and disabled the crypto backend during the build part of CI, only enabling it during test. Passing the tags to the right parts of the tests is tricky, and other workarounds were needed too to account for using different GOEXPERIMENT values for build vs. test. Once the repo has aVERSION
file, (#982) it gets even more complicated, and ultimately I didn't get this approach working in the 1.21 release branch.This PR changes the
allow_missing_crypto_backend_fallback
tag to aallowcryptofallback
GOEXPERIMENT. This means the complicated workarounds aren't necessary becauseopensslcrypto,allowcryptofallback
follow each other around and take effect in the same places (and they are omitted in the same places).I also added a note to the fallback compile error message that directly addresses the breaking change, for anyone depending on the fallback behavior.
Open to names other than
allowcryptofallback
, although I'm happy with it. Experiments are inherently easier to find than build tags, and someone might have a convoluted build script where they would actually want to use it (although I plan to discourage using it in the FIPS doc), so I figure a reasonable name would be good to have.