microsoft / go

The Microsoft build of the Go toolset
BSD 3-Clause "New" or "Revised" License
283 stars 27 forks source link

Make `nobackend.go` build constraint an inverse of the other backends (and add test) #953

Closed dagood closed 1 year ago

dagood commented 1 year ago

In https://github.com/microsoft/go/pull/950 I wrote a test/generator that parses the build constraints for each backend and constructs a simple inverse. We could use that code to generate the constraint for nobackend.go so that it is always enabled when none of the backends' conditions are met.

This could allow "silent" unintended usage of Go crypto. GOEXPERIMENT=cngcrypto GOOS=linux go build would not end up using a backend. However, this is in line with some other behavior: GOEXPERIMENT=opensslcrypto GOOS=linux CGO_ENABLED=0 go build behaves similarly today.

It seems to me we should still make sure GOEXPERIMENT=systemcrypto never silently uses Go crypto, though. Based on the issues I saw in https://github.com/microsoft/go/pull/950, this might mean GOEXPERIMENT=systemcrypto go tool dist test won't work (unless we make more test changes), but since systemcrypto is a fairly simple alias, this might be ok.

dagood commented 1 year ago

@qmuntal and I discussed this in Go sync:

To fix the test suite, a few ideas: