aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/go/internal/work/exec.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/cmd/go/internal/work/exec.go')
-rw-r--r--src/cmd/go/internal/work/exec.go22
1 files changed, 21 insertions, 1 deletions
diff --git a/src/cmd/go/internal/work/exec.go b/src/cmd/go/internal/work/exec.go
index 0b8e5d2330..6ecd4dcf2c 100644
--- a/src/cmd/go/internal/work/exec.go
+++ b/src/cmd/go/internal/work/exec.go
@@ -22,6 +22,7 @@ import (
"path/filepath"
"regexp"
"runtime"
+ "sort"
"strconv"
"strings"
"sync"
@@ -2991,7 +2992,26 @@ func (b *Builder) dynimport(a *Action, p *load.Package, objdir, importGo, cgoExe
return err
}
- linkobj := str.StringList(ofile, outObj, mkAbsFiles(p.Dir, p.SysoFiles))
+ // Gather .syso files from this package and all (transitive) dependencies.
+ var syso []string
+ seen := make(map[*Action]bool)
+ var gatherSyso func(*Action)
+ gatherSyso = func(a1 *Action) {
+ if seen[a1] {
+ return
+ }
+ seen[a1] = true
+ if p1 := a1.Package; p1 != nil {
+ syso = append(syso, mkAbsFiles(p1.Dir, p1.SysoFiles)...)
+ }
+ for _, a2 := range a1.Deps {
+ gatherSyso(a2)
+ }
+ }
+ gatherSyso(a)
+ sort.Strings(syso)
+ str.Uniq(&syso)
+ linkobj := str.StringList(ofile, outObj, syso)
dynobj := objdir + "_cgo_.o"
ldflags := cgoLDFLAGS