// we use to coordinate between gcc and ourselves.
// We already put _cgo_ at the beginning, so the main
// concern is other cgo wrappers for the same functions.
- // Use the beginning of the 32 bytes hash of the input to disambiguate.
- h := hash.New32()
+ // Use the beginning of the 16 bytes hash of the input to disambiguate.
+ h := hash.New16()
io.WriteString(h, *importPath)
var once sync.Once
var wg sync.WaitGroup
func TypeHash(t *Type) uint32 {
p := t.LinkString()
- // Using 32 bytes hash is overkill, but reduces accidental collisions.
- h := hash.Sum32([]byte(p))
+ // Using 16 bytes hash is overkill, but reduces accidental collisions.
+ h := hash.Sum16([]byte(p))
return binary.LittleEndian.Uint32(h[:4])
}
// GCLocalsSym generates a content-addressable sym containing data.
func (ctxt *Link) GCLocalsSym(data []byte) *LSym {
- sum := hash.Sum32(data)
+ sum := hash.Sum16(data)
str := base64.StdEncoding.EncodeToString(sum[:16])
return ctxt.LookupInit(fmt.Sprintf("gclocals·%s", str), func(lsym *LSym) {
lsym.P = data
goarch = f[1]
}
- hash := hash.Sum32([]byte(fmt.Sprintf("%v-%v-%v-%v", srcfname, flags, printCode, printGnuAsm)))
+ hash := hash.Sum16([]byte(fmt.Sprintf("%v-%v-%v-%v", srcfname, flags, printCode, printGnuAsm)))
tmp := t.TempDir()
hello := filepath.Join(tmp, fmt.Sprintf("hello-%x.exe", hash))
args := []string{"build", "-o", hello}