cmd/cgo: add import path to hash

This avoids name conflicts when two identical packages use cgo.
This can happen in practice when the same package is vendored multiple
times in a single build.

Fixes #23555

Change-Id: I9f0ec6db9165dcf9cdf3d314c668fee8ada18f9c
Reviewed-on: https://go-review.googlesource.com/118739
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
Ian Lance Taylor 2018-06-13 15:49:52 -07:00
parent 7bc99ffa05
commit 3a7cbfaa40
4 changed files with 37 additions and 0 deletions

View file

@ -17,6 +17,7 @@ import (
"go/ast"
"go/printer"
"go/token"
"io"
"io/ioutil"
"os"
"path/filepath"
@ -279,6 +280,7 @@ func main() {
// concern is other cgo wrappers for the same functions.
// Use the beginning of the md5 of the input to disambiguate.
h := md5.New()
io.WriteString(h, *importPath)
fs := make([]*File, len(goFiles))
for i, input := range goFiles {
if *srcDir != "" {