diff --git a/_demo/go/gobuild/demo.go b/_demo/go/gobuild/demo.go index 07626212..70cb4700 100644 --- a/_demo/go/gobuild/demo.go +++ b/_demo/go/gobuild/demo.go @@ -10,6 +10,23 @@ import ( func main() { fmt.Printf("runtime.Compiler = %q\n", runtime.Compiler) + + ctx := build.Default + fmt.Printf("build.Default.Compiler = %q\n", ctx.Compiler) + if ctx.Compiler != "gc" { + panic(fmt.Sprintf("expected build.Default.Compiler to be \"gc\", got %q", ctx.Compiler)) + } + + if len(ctx.ToolTags) == 0 { + panic("expected build.Default.ToolTags to be non-empty") + } + fmt.Printf("build.Default.ToolTags = %v\n", ctx.ToolTags) + + if len(ctx.ReleaseTags) == 0 { + panic("expected build.Default.ReleaseTags to be non-empty") + } + fmt.Printf("build.Default.ReleaseTags count = %d\n", len(ctx.ReleaseTags)) + pkg, err := build.Import("fmt", "", build.FindOnly) if err != nil { panic(err) diff --git a/runtime/internal/lib/go/build/build.go b/runtime/internal/lib/go/build/build.go index f27fb381..f39fc8bb 100644 --- a/runtime/internal/lib/go/build/build.go +++ b/runtime/internal/lib/go/build/build.go @@ -23,6 +23,9 @@ type Context = build.Context //go:linkname cgoSupported internal/platform.CgoSupported func cgoSupported(goos, goarch string) bool +//go:linkname toolTags internal/buildcfg.ToolTags +var toolTags []string + // defaultToolTags should be an internal detail, // but widely used packages access it using linkname. // Notable members of the hall of shame include: @@ -131,10 +134,6 @@ func defaultGOPATH() string { } // buildToolTags returns the tool tags for the current build configuration. -// This is a simplified version that returns basic tags. func buildToolTags() []string { - return []string{ - "gc", - "goexperiment.boringcrypto", - } + return toolTags }