-
Notifications
You must be signed in to change notification settings - Fork 39
Closed
Labels
Description
go version -m example reports the go experiment and some other info that can most likely be used to figure out whether a crypto module was used to build example, but it isn't straightforward. I think we can fairly easily add this info in a more consistent way:
https://pkg.go.dev/runtime/debug#BuildSetting
diff --git a/src/cmd/go/internal/load/pkg.go b/src/cmd/go/internal/load/pkg.go
index c0e6265e29d065..fdeb82b0484ec6 100644
--- a/src/cmd/go/internal/load/pkg.go
+++ b/src/cmd/go/internal/load/pkg.go
@@ -2430,6 +2430,9 @@ func (p *Package) setBuildInfo(ctx context.Context, autoVCS bool) {
if key, val := cfg.GetArchEnv(); key != "" && val != "" {
appendSetting(key, val)
}
+ if ok := cfg.BuildContext.MatchTag("goexperiment.opensslcrypto"); ok {
+ appendSetting("goexperiment.opensslcrypto", "on")
+ }
// Add VCS status if all conditions are true:
//
diff --git a/src/go/build/build.go b/src/go/build/build.go
index 48adcfed5cf3cb..8f757a87c09257 100644
--- a/src/go/build/build.go
+++ b/src/go/build/build.go
@@ -2021,6 +2021,10 @@ func (ctxt *Context) matchTag(name string, allTags map[string]bool) bool {
return false
}
+func (ctxt *Context) MatchTag(tag string) bool {
+ return ctxt.matchTag(tag, nil)
+}
+
// goodOSArchFile returns false if the name contains a $GOOS or $GOARCH
// suffix which does not match the current system.
// The recognized name formats are:This works as expected with go version -m, and other tools can probably be adapted to read the data directly from Go binaries if necessary (e.g. a Go toolset isn't present).