mirror of https://github.com/golang/go.git
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/22478 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
e607abbfd6
commit
19912e1d0a
|
|
@ -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, "}")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue