diff --git a/src/cmd/go/build.go b/src/cmd/go/build.go index b980a6b9d3..11ad561c46 100644 --- a/src/cmd/go/build.go +++ b/src/cmd/go/build.go @@ -350,7 +350,7 @@ func buildModeInit() { codegenArg = "-fPIC" } else { switch platform { - case "linux/amd64", "linux/arm", "linux/arm64", + case "linux/amd64", "linux/arm", "linux/arm64", "linux/386", "android/amd64", "android/arm": codegenArg = "-shared" case "darwin/amd64": diff --git a/src/cmd/link/internal/ld/lib.go b/src/cmd/link/internal/ld/lib.go index 4289455252..40c784851a 100644 --- a/src/cmd/link/internal/ld/lib.go +++ b/src/cmd/link/internal/ld/lib.go @@ -318,7 +318,9 @@ func (mode *BuildMode) Set(s string) error { } *mode = BuildmodeCArchive case "c-shared": - if goarch != "amd64" && goarch != "arm" && goarch != "arm64" { + switch goarch { + case "386", "amd64", "arm", "arm64": + default: return badmode() } *mode = BuildmodeCShared @@ -1696,7 +1698,8 @@ func stkcheck(up *Chain, depth int) int { // should never be called directly. // only diagnose the direct caller. // TODO(mwhudson): actually think about this. - if depth == 1 && s.Type != obj.SXREF && !DynlinkingGo() && Buildmode != BuildmodePIE { + if depth == 1 && s.Type != obj.SXREF && !DynlinkingGo() && + Buildmode != BuildmodePIE && Buildmode != BuildmodeCShared { Diag("call to external function %s", s.Name) } return -1 diff --git a/src/cmd/link/internal/x86/asm.go b/src/cmd/link/internal/x86/asm.go index b41c3514b4..830a7e6af9 100644 --- a/src/cmd/link/internal/x86/asm.go +++ b/src/cmd/link/internal/x86/asm.go @@ -51,7 +51,7 @@ func addcall(ctxt *ld.Link, s *ld.LSym, t *ld.LSym) { } func gentext() { - if !ld.DynlinkingGo() && ld.Buildmode != ld.BuildmodePIE { + if !ld.DynlinkingGo() && ld.Buildmode != ld.BuildmodePIE && ld.Buildmode != ld.BuildmodeCShared { return }