From bcf6f9fd4c601a2f51d737a6390a7e909096729a Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Tue, 17 Sep 2019 21:12:35 -0700 Subject: [PATCH] internal/goroot: for -compiler=gccgo, only look for .gox files Fixes #34358 Change-Id: I3022ac88e1ad595dc72c0063852b8d4a1ec3f0ba Reviewed-on: https://go-review.googlesource.com/c/go/+/196120 Run-TryBot: Ian Lance Taylor TryBot-Result: Gobot Gobot Reviewed-by: Bryan C. Mills --- src/cmd/go/testdata/script/mod_m.txt | 15 +++++++++++++++ src/internal/goroot/gc.go | 15 +++------------ 2 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 src/cmd/go/testdata/script/mod_m.txt diff --git a/src/cmd/go/testdata/script/mod_m.txt b/src/cmd/go/testdata/script/mod_m.txt new file mode 100644 index 00000000000..a6edeac7bba --- /dev/null +++ b/src/cmd/go/testdata/script/mod_m.txt @@ -0,0 +1,15 @@ +# It's absurd, but builds with -compiler=gccgo used to fail to build module m. +# golang.org/issue/34358 + +cd m +go build +exists m$GOEXE +rm m$GOEXE +[exec:gccgo] go build -compiler=gccgo +[exec:gccgo] exists m$GOEXE + +-- m/go.mod -- +module m +-- m/main.go -- +package main +func main() {} diff --git a/src/internal/goroot/gc.go b/src/internal/goroot/gc.go index 9d846d8c49a..0f541d734b0 100644 --- a/src/internal/goroot/gc.go +++ b/src/internal/goroot/gc.go @@ -121,18 +121,9 @@ func (gd *gccgoDirs) isStandard(path string) bool { } for _, dir := range gd.dirs { - full := filepath.Join(dir, path) - pkgdir, pkg := filepath.Split(full) - for _, p := range [...]string{ - full, - full + ".gox", - pkgdir + "lib" + pkg + ".so", - pkgdir + "lib" + pkg + ".a", - full + ".o", - } { - if fi, err := os.Stat(p); err == nil && !fi.IsDir() { - return true - } + full := filepath.Join(dir, path) + ".gox" + if fi, err := os.Stat(full); err == nil && !fi.IsDir() { + return true } }