Commit 19912e1d authored by Robert Griesemer's avatar Robert Griesemer

cmd/dist: sort entries in zcgo.go generated file for deterministic build

This simplifies comparison of object files across different builds
by ensuring that the strings in the zcgo.go always appear in the
same order.

Change-Id: I3639ea4fd10e0d645b838d1bbb03cd33deca340e
Reviewed-on: https://go-review.googlesource.com/22478Reviewed-by: 's avatarMatthew Dempsky <mdempsky@google.com>
parent e607abbf
......@@ -7,6 +7,7 @@ package main
import (
"bytes"
"fmt"
"sort"
)
/*
......@@ -48,6 +49,15 @@ func mkzdefaultcc(dir, file string) {
//
// It is invoked to write go/build/zcgo.go.
func mkzcgo(dir, file string) {
// sort for deterministic zcgo.go file
var list []string
for plat, hasCgo := range cgoEnabled {
if hasCgo {
list = append(list, plat)
}
}
sort.Strings(list)
var buf bytes.Buffer
fmt.Fprintf(&buf,
......@@ -56,10 +66,8 @@ func mkzcgo(dir, file string) {
"package build\n"+
"\n"+
"var cgoEnabled = map[string]bool{\n")
for plat, hasCgo := range cgoEnabled {
if hasCgo {
fmt.Fprintf(&buf, "\t%q: true,\n", plat)
}
for _, plat := range list {
fmt.Fprintf(&buf, "\t%q: true,\n", plat)
}
fmt.Fprintf(&buf, "}")
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment